org.jdom

Class Text

Implemented Interfaces:
Cloneable, Serializable
Known Direct Subclasses:
CDATA

public class Text
extends Content

Character-based XML content. Provides a modular, parentable method of representing text. Text makes no guarantees about the underlying textual representation of character data, but does expose that data as a Java String.
See Also:
Serialized Form

Field Summary

protected String
value
The actual character content

Fields inherited from class org.jdom.Content

parent

Constructor Summary

Text()
This is the protected, no-args constructor standard in all JDOM classes.
Text(String str)
This constructor creates a new Text node, with the supplied string value as it's character content.

Method Summary

void
append(String str)
This will append character content to whatever content already exists within this Text node.
void
append(Text text)
This will append the content of another Text node to this node.
Object
clone()
This will return a clone of this Text node, with the same character content, but no parent.
String
getText()
This returns the value of this Text node as a Java String.
String
getTextNormalize()
This returns the textual content with all surrounding whitespace removed and internal whitespace normalized to a single space.
String
getTextTrim()
This returns the textual content with all surrounding whitespace removed.
String
getValue()
Returns the XPath 1.0 string value of this element, which is the text itself.
static String
normalizeString(String str)
This returns a new string with all surrounding whitespace removed and internal whitespace normalized to a single space.
Text
setText(String str)
This will set the value of this Text node.
String
toString()
This returns a String representation of the Text node, suitable for debugging.

Methods inherited from class org.jdom.Content

clone, detach, equals, getDocument, getParent, getParentElement, getValue, hashCode, setParent

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

value

protected String value
The actual character content

Constructor Details

Text

protected Text()
This is the protected, no-args constructor standard in all JDOM classes. It allows subclassers to get a raw instance with no initialization.

Text

public Text(String str)
This constructor creates a new Text node, with the supplied string value as it's character content.
Parameters:
str - the node's character content.
Throws:
IllegalDataException - if str contains an illegal character such as a vertical tab (as determined by Verifier.checkCharacterData(String))
Usages and Demos :

View More Examples of Text(String str)
   1:         }
   2:         pElt.addContent(new org.jdom.Text(sContent));
   3:     }
   4: 
   5:     private org.jdom.output.XMLOutputter getXMLOutputter(String encoding) {

View Full Code Here
   1:          Element name = new Element("name");
   2:          name.addContent(new Text(Table.getSQLName(elementDef.getElementName())));
   3:          Element desc = new Element("desc");
   4:         ...
   5:          desc.addContent(new Text(elementDef.getElementName()));
   6:          table.addContent(name);
   7:          table.addContent(desc);

View Full Code Here
   1:       String fullPath = reviewIssue.getReviewIFile().getFullPath().toString();
   2:       String thisNormalizedDescription = new Text(this.description).getTextNormalize();
   3:         ...
   4:       String normalizedDescription = new Text(reviewIssue.getDescription()).getTextNormalize();
   5:       if (this.reviewIFile.getFullPath().toString().equals(fullPath)
   6:           && this.reviewer.equals(reviewIssue.getReviewer())
   7:           && this.assignedTo.equals(reviewIssue.getAssignedTo())

View Full Code Here
   1:                 String string = ((Text) value).getText();
   2:                 element.addContent(new Text(string));
   3:             }
   4:         ...
   5:                 if (string != null && !string.equals("")) {
   6:                     element.addContent(new Text(string));
   7:                 }
   8:             }
   9:         }

View Full Code Here
   1:             (Severity) severityKeyManager.getItemObject(severityKey),
   2:             new org.jdom.Text(this.summaryText.getText()).getText(),
   3:             this.descriptionText.getText(), this.annotationText.getText(), 
   4:             this.revisionText.getText(),
   5:             (Resolution) resolutionKeyManager.getItemObject(resolutionKey),

View Full Code Here

Method Details

append

public void append(String str)
This will append character content to whatever content already exists within this Text node.
Parameters:
str - character content to append.
Throws:
IllegalDataException - if str contains an illegal character such as a vertical tab (as determined by Verifier.checkCharacterData(String))

append

public void append(Text text)
This will append the content of another Text node to this node.
Parameters:
text - Text node to append.

clone

public Object clone()
This will return a clone of this Text node, with the same character content, but no parent.
Overrides:
clone in interface Content
Returns:
Text - cloned node.

getText

public String getText()
This returns the value of this Text node as a Java String.
Returns:
String - character content of this node.
Usages and Demos :

View More Examples of getText()
   1: import org.jdom.JDOMException;
   2: import org.jdom.Text;
   3: import org.jdom.xpath.XPath;
   4:         ...
   5:     {
   6:         if( element instanceof Text )
   7:         {
   8:         ...
   9:             Text t = (Text)element;
  10:         ...
  11:             String s = t.getText();

View Full Code Here

getTextNormalize

public String getTextNormalize()
This returns the textual content with all surrounding whitespace removed and internal whitespace normalized to a single space. If only whitespace exists, the empty string is returned.
Returns:
normalized text content or empty string

getTextTrim

public String getTextTrim()
This returns the textual content with all surrounding whitespace removed. If only whitespace exists, the empty string is returned.
Returns:
trimmed text content or empty string

getValue

public String getValue()
Returns the XPath 1.0 string value of this element, which is the text itself.
Overrides:
getValue in interface Content
Returns:
the text
Usages and Demos :

View More Examples of getValue()
   1: import org.jdom.ProcessingInstruction;
   2: import org.jdom.Text;
   3: import org.jdom.Verifier;
   4:         ...
   5: 
   6:     public static String removeIllegalChars(String text) {
   7:         ...
   8:         if ((text == null) || (text.trim().length() == 0))
   9:             return text;
  10:         ...
  11:         public static boolean equivalent(Text t1, Text t2) {
  12:             String v1 = t1.getValue();

View Full Code Here

normalizeString

public static String normalizeString(String str)
This returns a new string with all surrounding whitespace removed and internal whitespace normalized to a single space. If only whitespace exists, the empty string is returned.

Per XML 1.0 Production 3 whitespace includes: #x20, #x9, #xD, #xA

Parameters:
str - string to be normalized.
Returns:
normalized string or empty string

setText

public Text setText(String str)
This will set the value of this Text node.
Parameters:
str - value for node's content.
Returns:
the object on which the method was invoked
Throws:
IllegalDataException - if str contains an illegal character such as a vertical tab (as determined by Verifier.checkCharacterData(String))

toString

public String toString()
This returns a String representation of the Text node, suitable for debugging. If the XML representation of the Text node is desired, either getText() or XMLOutputter.outputString(Text) should be used.
Overrides:
toString in interface Object
Returns:
String - information about this node.