Package org.jdom
Class CDATA
- java.lang.Object
-
- org.jdom.Content
-
- org.jdom.Text
-
- org.jdom.CDATA
-
- All Implemented Interfaces:
Serializable
,Cloneable
,NamespaceAware
- Direct Known Subclasses:
LocatedCDATA
public class CDATA extends Text
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 simpleText
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.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jdom.Content
Content.CType
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(String str)
This will append character content to whatever content already exists within thisCDATA
node.void
append(Text text)
This will append the content of anotherText
node to this node.CDATA
clone()
Return a deep clone of this instance.CDATA
detach()
Detaches this child from its parent or does nothing if the child has no parent.protected CDATA
setParent(Parent parent)
Sets the parent of this Content.CDATA
setText(String str)
This will set the value of thisCDATA
node.String
toString()
This returns aString
representation of theCDATA
node, suitable for debugging.-
Methods inherited from class org.jdom.Text
getParent, getText, getTextNormalize, getTextTrim, getValue, normalizeString
-
Methods inherited from class org.jdom.Content
equals, getCType, getDocument, getNamespacesInherited, getNamespacesInScope, getNamespacesIntroduced, getParentElement, hashCode
-
-
-
-
Constructor Detail
-
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
public CDATA(String string)
This constructor creates a newCDATA
node, with the supplied string value as it's character content.- Parameters:
string
- the node's character content.- Throws:
IllegalDataException
- ifstr
contains an illegal character such as a vertical tab (as determined byVerifier.checkCharacterData(java.lang.String)
) or the CDATA end delimiter]]>
.
-
-
Method Detail
-
setText
public CDATA setText(String str)
This will set the value of thisCDATA
node.- Overrides:
setText
in classText
- Parameters:
str
- value for node's content.- Returns:
- the object on which the method was invoked
- Throws:
IllegalDataException
- ifstr
contains an illegal character such as a vertical tab (as determined byVerifier.checkCharacterData(java.lang.String)
) or the CDATA end delimiter]]>
.
-
append
public void append(String str)
This will append character content to whatever content already exists within thisCDATA
node.- Overrides:
append
in classText
- Parameters:
str
- character content to append.- Throws:
IllegalDataException
- ifstr
contains an illegal character such as a vertical tab (as determined byVerifier.checkCharacterData(java.lang.String)
) or the CDATA end delimiter]]>
.
-
append
public void append(Text text)
This will append the content of anotherText
node to this node.
-
toString
public String toString()
This returns aString
representation of theCDATA
node, suitable for debugging. If the XML representation of theCDATA
node is desired, either
orText.getText()
XMLOutputter2.output(CDATA, java.io.Writer)
should be used.
-
clone
public CDATA 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 vaue).
Subclasses of this should still call super.clone() in their clone method.
-
detach
public CDATA detach()
Description copied from class:Content
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()
;
-
setParent
protected CDATA setParent(Parent parent)
Description copied from class:Content
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)
;
-
-