## org.jdom
Class CDATA

    java.lang.Object
      |
      +--org.jdom.CDATA

public class CDATA
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

`CDATA` represents character-based content within an XML document represented by JDOM. It is intended to provide a modular, printable method of representing CDATA. Additionally, `CDATA` makes no guarantees about the underlying textual representation of character data, but does expose that data as a Java `String`.

Version:
  $Revision: 1.20 $, $Date: 2002/03/12 07:11:39 $
Author:
  Dan Schaffer, Brett McLaughlin, Jason Hunter, Bradley S. Huffman
See Also:
  Serialized Form

Field Summary
`protected java.lang.Object` `parent` This `CDATA` node's parent.
`protected java.lang.String` `value` The actual character content

Constructor Summary
`protected` `CDATA()` This is the protected, no-args constructor standard in all JDOM classes.
`` `CDATA(java.lang.String str)` This constructor creates a new `CDATA` node, with the supplied string value as it's character content.

Method Summary
`void` `append(CDATA cdata)` This will append the content of another `CDATA` node to this node.
`void` `append(java.lang.String str)` This will append character content to whatever content already exists within this `CDATA` node.
`java.lang.Object` `clone()` This will return a clone of this `CDATA` node, with the same character content, but no parent.
`CDATA` `detach()` Detaches the `CDATA` from its parent, or does nothing if the `CDATA` has no parent.
`boolean` `equals(java.lang.Object ob)` This tests for equality of this `CDATA` to the supplied `Object`, explicitly using the == operator.
`Document` `getDocument()` This retrieves the owning ``Document`` for this `CDATA`, or null if not a currently a member of a ``Document``.
`Element` `getParent()` This will return the parent of this `CDATA` node, which is always a JDOM ``Element``.
`java.lang.String` `getText()` This returns the value of this `CDATA` node as a Java `String`.
`java.lang.String` `getTextNormalize()` This returns the textual content with all surrounding whitespace removed and internal whitespace normalized to a single space.
`java.lang.String` `getTextTrim()` This returns the textual content with all surrounding whitespace removed.
`int` `hashCode()` This will generate a hash code for this node.
`protected CDATA` `setParent(Element parent)` This will set the parent of the `CDATA` node to the supplied ``Element``.
`CDATA` `setText(java.lang.String str)` This will set the value of this `CDATA` node.
`java.lang.String` `toString()` This returns a `String` representation of the `CDATA` node, suitable for debugging.

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### value

    protected java.lang.String value

  The actual character content

### parent

    protected java.lang.Object parent

  This `CDATA` node's parent.

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(java.lang.String str)

  This constructor creates a new `CDATA` node, with the supplied string value as it's character content.

  Parameters:
    `str` - the node's character content.

Method Detail

### getText

    public java.lang.String getText()

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

  Returns:
    `String` - character content of this node.

### getTextTrim

    public java.lang.String getTextTrim()

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

  Returns:
    trimmed cdata content or empty string

### getTextNormalize

    public java.lang.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:
    normalized cdata content or empty string

### setText

    public CDATA setText(java.lang.String str)

  This will set the value of this `CDATA` node.

  Parameters:
    `str` - value for node's content.

### append

    public void append(java.lang.String str)

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

  Parameters:
    `str` - character content to append.

### append

    public void append(CDATA cdata)

  This will append the content of another `CDATA` node to this node.

  Parameters:
    `cdata` - CDATA node to append.

### getParent

    public Element getParent()

  This will return the parent of this `CDATA` node, which is always a JDOM ``Element``.

  Returns:
    `Element` - this node's parent.

### getDocument

    public Document getDocument()

  This retrieves the owning ``Document`` for this `CDATA`, or null if not a currently a member of a ``Document``.

  Returns:
    `Document` owning this `CDATA`, or null.

### setParent

    protected CDATA setParent(Element parent)

  This will set the parent of the `CDATA` node to the supplied ``Element``. This method is intentionally left as `protected` so that only JDOM internals use it.

  If you need an instance of this `CDATA` node with a new parent, you should get a copy of this node with ``clone()`` and set it on the desired (new) parent `Element`.

  Parameters:
    `parent` - parent for this node.

### detach

    public CDATA detach()

  Detaches the `CDATA` from its parent, or does nothing if the `CDATA` has no parent.

  Returns:
    `CDATA` - this `CDATA` modified.

### toString

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

  Overrides:
    toString in class java.lang.Object
  Returns:
    `String` - information about this node.

### hashCode

    public final int hashCode()

  This will generate a hash code for this node.

  Overrides:
    hashCode in class java.lang.Object
  Returns:
    `int` - hash code for this node.

### clone

    public java.lang.Object clone()

  This will return a clone of this `CDATA` node, with the same character content, but no parent.

  Overrides:
    clone in class java.lang.Object
  Returns:
    `CDATA` - cloned node.

### equals

    public final boolean equals(java.lang.Object ob)

  This tests for equality of this `CDATA` to the supplied `Object`, explicitly using the == operator.

  Overrides:
    equals in class java.lang.Object
  Parameters:
    `ob` - `Object` to compare to
  Returns:
    whether the `CDATA` nodes are equal

Copyright © 2002 Jason Hunter, Brett McLaughlin. All Rights Reserved.