Package org.jdom
Class Text
- java.lang.Object
-
- org.jdom.Content
-
- org.jdom.Text
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known 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.- Version:
- $Revision: 1.25 $, $Date: 2007/11/10 05:28:59 $
- Author:
- Brett McLaughlin, Jason Hunter, Bradley S. Huffman
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(java.lang.String str)This will append character content to whatever content already exists within thisTextnode.voidappend(Text text)This will append the content of anotherTextnode to this node.java.lang.Objectclone()This will return a clone of thisTextnode, with the same character content, but no parent.java.lang.StringgetText()This returns the value of thisTextnode as a JavaString.java.lang.StringgetTextNormalize()This returns the textual content with all surrounding whitespace removed and internal whitespace normalized to a single space.java.lang.StringgetTextTrim()This returns the textual content with all surrounding whitespace removed.java.lang.StringgetValue()Returns the XPath 1.0 string value of this element, which is the text itself.static java.lang.StringnormalizeString(java.lang.String str)This returns a new string with all surrounding whitespace removed and internal whitespace normalized to a single space.TextsetText(java.lang.String str)This will set the value of thisTextnode.java.lang.StringtoString()This returns aStringrepresentation of theTextnode, suitable for debugging.-
Methods inherited from class org.jdom.Content
detach, equals, getDocument, getParent, getParentElement, hashCode, setParent
-
-
-
-
Constructor Detail
-
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(java.lang.String str)
This constructor creates a newTextnode, with the supplied string value as it's character content.- Parameters:
str- the node's character content.- Throws:
IllegalDataException- ifstrcontains an illegal character such as a vertical tab (as determined byVerifier.checkCharacterData(java.lang.String))
-
-
Method Detail
-
getText
public java.lang.String getText()
This returns the value of thisTextnode as a JavaString.- Returns:
String- character content of this node.
-
getTextTrim
public java.lang.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
-
getTextNormalize
public java.lang.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
-
normalizeString
public static java.lang.String normalizeString(java.lang.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(java.lang.String str)
This will set the value of thisTextnode.- Parameters:
str- value for node's content.- Returns:
- the object on which the method was invoked
- Throws:
IllegalDataException- ifstrcontains an illegal character such as a vertical tab (as determined byVerifier.checkCharacterData(java.lang.String))
-
append
public void append(java.lang.String str)
This will append character content to whatever content already exists within thisTextnode.- Parameters:
str- character content to append.- Throws:
IllegalDataException- ifstrcontains an illegal character such as a vertical tab (as determined byVerifier.checkCharacterData(java.lang.String))
-
append
public void append(Text text)
This will append the content of anotherTextnode to this node.- Parameters:
text- Text node to append.
-
getValue
public java.lang.String getValue()
Returns the XPath 1.0 string value of this element, which is the text itself.
-
toString
public java.lang.String toString()
This returns aStringrepresentation of theTextnode, suitable for debugging. If the XML representation of theTextnode is desired, eitherorgetText()XMLOutputter.outputString(Text)should be used.- Overrides:
toStringin classjava.lang.Object- Returns:
String- information about this node.
-
-