org.cdmckay.coffeedom
Class CDATA

java.lang.Object
  extended by org.cdmckay.coffeedom.Content
      extended by org.cdmckay.coffeedom.Text
          extended by org.cdmckay.coffeedom.CDATA
All Implemented Interfaces:
Serializable, Cloneable

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.

Author:
Dan Schaffer, Brett McLaughlin, Jason Hunter, Bradley S. Huffman, Victor Toni, Cameron McKay
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.cdmckay.coffeedom.Text
value
 
Fields inherited from class org.cdmckay.coffeedom.Content
parent
 
Constructor Summary
protected CDATA()
          This is the protected, no-args constructor standard in all CoffeeDOM 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.
 CDATA clone()
          This will return a clone of this Text node, with the same character content, but no parent.
 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.
 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.cdmckay.coffeedom.Text
getParent, getText, getTextNormalize, getTextTrim, getValue, normalizeString
 
Methods inherited from class org.cdmckay.coffeedom.Content
equals, getDocument, getParentElement, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CDATA

protected CDATA()
This is the protected, no-args constructor standard in all CoffeeDOM 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 ]]>.
Method Detail

setText

public Text setText(String str)
This will set the value of this CDATA node.

Overrides:
setText in class 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 ]]>.

append

public void append(String str)
This will append character content to whatever content already exists within this CDATA node.

Overrides:
append in class 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 class Text
Parameters:
text - Text node to append.

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.

Overrides:
setParent in class Text
Parameters:
parent - new parent element
Returns:
the target element

clone

public CDATA clone()
Description copied from class: Text
This will return a clone of this Text node, with the same character content, but no parent.

Overrides:
clone in class Text
Returns:
Text - cloned node.

detach

public CDATA detach()
Description copied from class: Content
Detaches this child from its parent or does nothing if the child has no parent.

Overrides:
detach in class Text
Returns:
this child detached

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 Text.getText() or XMLOutputter.output(CDATA, java.io.Writer) should be used.

Overrides:
toString in class Text
Returns:
String - information about this node.


Copyright © 2011. All Rights Reserved.