org.jdom

Class CDATA

Implemented Interfaces:
Cloneable, Serializable

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 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.
See Also:
Serialized Form

Field Summary

Fields inherited from class org.jdom.Text

value

Fields inherited from class org.jdom.Content

parent

Constructor Summary

CDATA()
This is the protected, no-args constructor standard in all JDOM classes.
CDATA(String string)
This constructor creates a new CDATA 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 CDATA node.
void
append(Text text)
This will append the content of another Text node to this node.
Text
setText(String str)
This will set the value of this CDATA node.
String
toString()
This returns a String representation of the CDATA node, suitable for debugging.

Methods inherited from class org.jdom.Text

append, append, clone, getText, getTextNormalize, getTextTrim, getValue, normalizeString, setText, toString

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

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

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

View More Examples of CDATA(String string)
   1:         requestDocument.getRootElement().setAttribute("name", "Report_007") ;
   2:         CDATA cdata = new CDATA(testTextAccumulator) ;
   3:         Element bodyElement = new Element("Body") ;
   4:         bodyElement.addContent(cdata) ;
   5:         requestDocument.getRootElement().addContent(bodyElement) ;

View Full Code Here
   1:             Element msg = new Element("message");
   2:             msg.addContent(new CDATA(line));
   3:             msg.setAttribute("priority", "info");
   4:             if (currentElement == null) {
   5:                 buildLogElement.addContent(msg);

View Full Code Here
   1:         try {
   2:             cd = new CDATA(comment);
   3:         } catch (org.jdom.IllegalDataException e) {
   4:             LOG.error(e);
   5:             cd = new CDATA("Unable to parse comment.  It contains illegal data.");

View Full Code Here
   1:             try {
   2:                 cd = new CDATA(comment);
   3:             } catch (org.jdom.IllegalDataException e) {
   4:         ...
   5:             try {
   6:                 cd = new CDATA(comment);
   7:             } catch (org.jdom.IllegalDataException e) {
   8:                 LOG.error(e);
   9:                 cd = new CDATA(

View Full Code Here
   1:             Element documentGateXmlElement = new Element("DocumentGateXML");
   2:             CDATA cdata = new CDATA(documentAsXML);
   3:             documentGateXmlElement.addContent(cdata);
   4:             doc.getRootElement().addContent(documentUUIDElement);
   5:             doc.getRootElement().addContent(documentGateXmlElement);

View Full Code Here

Method Details

append

public void append(String str)
This will append character content to whatever content already exists within this CDATA node.
Overrides:
append in interface Text
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)) or the CDATA end delimiter ]]>.

append

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

setText

public Text setText(String str)
This will set the value of this CDATA node.
Overrides:
setText in interface Text
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)) or the CDATA end delimiter ]]>.

toString

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