Class CDATA
java.lang.Object
org.jdom2.Content
org.jdom2.Text
org.jdom2.CDATA
- All Implemented Interfaces:
Serializable, Cloneable, NamespaceAware
- Direct Known Subclasses:
LocatedCDATA
An XML CDATA section. Represents character-based content within an XML
document that should be output within special CDATA tags. Semantically it's
identical to a simple
Text object, but output behavior is different.
CDATA makes no guarantees about the underlying textual representation of
character data, but does expose that data as a Java String.- Author:
- Dan Schaffer, Brett McLaughlin, Jason Hunter, Bradley S. Huffman, Victor Toni, Rolf Lear
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Content
Content.CType -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis will append character content to whatever content already exists within thisCDATAnode.voidThis will append the content of anotherTextnode to this node.clone()Return a deep clone of this instance.detach()Detaches this child from its parent or does nothing if the child has no parent.protected CDATASets the parent of this Content.This will set the value of thisCDATAnode.toString()This returns aStringrepresentation of theCDATAnode, suitable for debugging.Methods inherited from class Text
getParent, getText, getTextNormalize, getTextTrim, getValue, normalizeStringMethods inherited from class Content
equals, getCType, getDocument, getNamespacesInherited, getNamespacesInScope, getNamespacesIntroduced, getParentElement, hashCode
-
Constructor Details
-
CDATA
protected CDATA()This is the protected, no-args constructor standard in all JDOM classes. It allows subclassers to get a raw instance with no initialization. -
CDATA
This constructor creates a newCDATAnode, with the supplied string value as its character content.- Parameters:
string- the node's character content.- Throws:
IllegalDataException- ifstrcontains an illegal character such as a vertical tab (as determined byVerifier.checkCharacterData(String)) or the CDATA end delimiter]]>.
-
-
Method Details
-
setText
This will set the value of thisCDATAnode.- Overrides:
setTextin classText- 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(String)) or the CDATA end delimiter]]>.
-
append
This will append character content to whatever content already exists within thisCDATAnode.- Overrides:
appendin classText- Parameters:
str- character content to append.- Throws:
IllegalDataException- ifstrcontains an illegal character such as a vertical tab (as determined byVerifier.checkCharacterData(String)) or the CDATA end delimiter]]>.
-
append
-
toString
This returns aStringrepresentation of theCDATAnode, suitable for debugging. If the XML representation of theCDATAnode is desired, eitherorText.getText()XMLOutputter.output(CDATA, java.io.Writer)should be used. -
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.
-
detach
Description copied from class:ContentDetaches 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(); -
setParent
Description copied from class:ContentSets 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);
-