Top Description Fields Constructors Methods
org.jdom2

public Class Text

extends Content
Class Inheritance
Known Direct Subclasses
org.jdom2.located.LocatedText, org.jdom2.CDATA
Imports
org.jdom2.output.Format

An XML character sequence. 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.
Authors
Brett McLaughlin, Jason Hunter, Bradley S. Huffman

Field Summary

Modifier and TypeField and Description
pack-priv static final String
private static final long
protected String
value

The actual character content

Inherited from org.jdom2.Content:
ctypeparent

Constructor Summary

AccessConstructor and Description
protected
Text(Content.CType
The CType to set for this Text-based Content.
ctype
)

CData type extends Text, and it needs to be able to change the Content type of this Content.

protected
Text()

This is the protected, no-args constructor standard in all JDOM classes.

public
Text(String
the node's character content.
str
)

This constructor creates a new Text node, with the supplied string value as its character content.

Method Summary

Modifier and TypeMethod and Description
public void
append(String
character content to append.
str
)

This will append character content to whatever content already exists within this Text node.

public void
append(Text
Text node to append.
text
)

This will append the content of another Text node to this node.

public Text
clone()

Overrides org.jdom2.Content.clone.

Return a deep clone of this instance.
public Text
detach()

Overrides org.jdom2.Content.detach.

Detaches this child from its parent or does nothing if the child has no parent.
public Element
getParent()

Overrides org.jdom2.Content.getParent.

Return this child's parent, or null if this child is currently not attached.
public String

Returns:

String - character content of this node.
getText
()

This returns the value of this Text node as a Java String.

public String

Returns:

normalized text content or empty string
getTextNormalize
()

This returns the textual content with all surrounding whitespace removed and internal whitespace normalized to a single space.

public String

Returns:

trimmed text content or empty string
getTextTrim
()

This returns the textual content with all surrounding whitespace removed.

public String

Returns:

the text
getValue
()

Implements abstract org.jdom2.Content.getValue.

Returns the XPath 1.0 string value of this element, which is the text itself.
public static String

Returns:

normalized string or empty string
normalizeString
(String
string to be normalized.
str
)

This returns a new string with all surrounding whitespace removed and internal whitespace normalized to a single space.

protected Text
setParent(Parent
new parent element
parent
)

Overrides org.jdom2.Content.setParent.

Sets the parent of this Content.
public Text

Returns:

the object on which the method was invoked
setText
(String
value for node's content.
str
)

This will set the value of this Text node.

public String

Returns:

String - information about this node.
toString
()

Overrides java.lang.Object.toString.

This returns a String representation of the Text node, suitable for debugging.
Inherited from org.jdom2.Content:
equalsgetCTypegetDocumentgetNamespacesInheritedgetNamespacesInScopegetNamespacesIntroducedgetParentElementhashCode

Field Detail

EMPTY_STRINGback to summary
pack-priv static final String EMPTY_STRING
serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.jdom2.Content.serialVersionUID.

JDOM2 Serialization. In this case, Text is simple.

valueback to summary
protected String value

The actual character content

Constructor Detail

Textback to summary
protected Text(Content.CType ctype)

CData type extends Text, and it needs to be able to change the Content type of this Content.

Parameters
ctype:Content.CType

The CType to set for this Text-based Content.

Textback to summary
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.

Textback to summary
public Text(String str)

This constructor creates a new Text node, with the supplied string value as its character content.

Parameters
str:String

the node's character content.

Exceptions
IllegalDataException:
if str contains an illegal character such as a vertical tab (as determined by org.jdom2.Verifier#checkCharacterData)

Method Detail

appendback to summary
public void append(String str)

This will append character content to whatever content already exists within this Text node.

Parameters
str:String

character content to append.

Exceptions
IllegalDataException:
if str contains an illegal character such as a vertical tab (as determined by org.jdom2.Verifier#checkCharacterData)
appendback to summary
public void append(Text text)

This will append the content of another Text node to this node.

Parameters
text:Text

Text node to append.

cloneback to summary
public Text clone()

Overrides org.jdom2.Content.clone.

Doc from org.jdom2.CloneBase.clone.

Return a deep clone of this instance. Even if this instance has a parent, the returned clone will not.

All JDOM core classes are Cloneable, and never throw CloneNotSupportedException. Additionally all Cloneable JDOM classes return the correct type of instance from this method and there is no need to cast the result (co-variant return value).

Subclasses of this should still call super.clone() in their clone method.

Returns:Text

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
detachback to summary
public Text detach()

Overrides org.jdom2.Content.detach.

Doc from org.jdom2.Content.detach.

Detaches this child from its parent or does nothing if the child has no parent.

This method can be overridden by particular Content subclasses to return a specific type of Content (co-variant return type). All overriding subclasses must call super.detach();

Returns:Text

this child detached

Annotations
@Override
getParentback to summary
public Element getParent()

Overrides org.jdom2.Content.getParent.

Doc from org.jdom2.Content.getParent.

Return this child's parent, or null if this child is currently not attached. The parent can be either an Element or a Document.

This method can be overridden by particular Content subclasses to return a specific type of Parent (co-variant return type). All overriding subclasses must call super.getParent();

Returns:Element

this child's parent or null if none

Annotations
@Override
getTextback to summary
public String getText()

This returns the value of this Text node as a Java String.

Returns:String

String - character content of this node.

getTextNormalizeback to summary
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:String

normalized text content or empty string

getTextTrimback to summary
public String getTextTrim()

This returns the textual content with all surrounding whitespace removed. If only whitespace exists, the empty string is returned.

Returns:String

trimmed text content or empty string

getValueback to summary
public String getValue()

Implements abstract org.jdom2.Content.getValue.

Returns the XPath 1.0 string value of this element, which is the text itself.

Returns:String

the text

Annotations
@Override
normalizeStringback to summary
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

string to be normalized.

Returns:String

normalized string or empty string

setParentback to summary
protected Text setParent(Parent parent)

Overrides org.jdom2.Content.setParent.

Doc from org.jdom2.Content.setParent.

Sets the parent of this Content. The caller is responsible for removing any pre-existing parentage.

This method can be overridden by particular Content subclasses to return a specific type of Content (co-variant return type). All overriding subclasses must call super.setParent(Parent);

Parameters
parent:Parent

new parent element

Returns:Text

the target element

Annotations
@Override
setTextback to summary
public Text setText(String str)

This will set the value of this Text node.

Parameters
str:String

value for node's content.

Returns:Text

the object on which the method was invoked

Exceptions
IllegalDataException:
if str contains an illegal character such as a vertical tab (as determined by org.jdom2.Verifier#checkCharacterData)
toStringback to summary
public String toString()

Overrides java.lang.Object.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 org.jdom2.output.XMLOutputter#outputString(Text) should be used.

Returns:String

String - information about this node.

Annotations
@Override