All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.jdom.Text

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

public class Text
extends Object
implements Serializable, Cloneable

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

Version:
$Revision: 1.11 $, $Date: 2002/03/12 07:11:39 $
Author:
Brett McLaughlin, Bradley S. Huffman

Variable Index

 o parent
This Text node's parent.
 o value
The actual character content

Constructor Index

 o Text()

This is the protected, no-args constructor standard in all JDOM classes.

 o Text(String)

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

Method Index

 o append(String)

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

 o append(Text)

This will append the content of another Text node to this node.

 o clone()

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

 o detach()

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

 o equals(Object)

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

 o getDocument()

This retrieves the owning {

 o getParent()

This will return the parent of this Text node, which is always a JDOM {

 o getText()

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

 o getTextNormalize()

This returns the textual content with all surrounding whitespace removed and internal whitespace normalized to a single space.

 o getTextTrim()

This returns the textual content with all surrounding whitespace removed.

 o hashCode()

This will generate a hash code for this node.

 o normalizeString(String)

This returns a new string with all surrounding whitespace removed and internal whitespace normalized to a single space.

 o setParent(Element)

This will set the parent of the Text node to the supplied {

 o setText(String)

This will set the value of this Text node.

 o toString()

This returns a String representation of the Text node, suitable for debugging.

Variables

 o value
 protected String value
The actual character content

 o parent
 protected Object parent
This Text node's parent.

Constructors

 o Text
 protected Text()

This is the protected, no-args constructor standard in all JDOM classes. It allows subclassers to get a raw instance with no initialization.

 o Text
 public Text(String str)

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

Parameters:
str - the node's character content.

Methods

 o getText
 public String getText()

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

Returns:
String - character content of this node.
 o getTextTrim
 public String getTextTrim()

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

Returns:
trimmed text content or empty string
 o getTextNormalize
 public 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 text content or empty string
 o normalizeString
 public static String normalizeString(String str)

This returns a new string with all surrounding whitespace removed and internal whitespace normalized to a single space. If only whitespace exists, the empty string is returned.

Per XML 1.0 Production 3 whitespace includes: #x20, #x9, #xD, #xA

Parameters:
str - string to be normalized.
Returns:
normalized string or empty string
 o setText
 public Text setText(String str)

This will set the value of this Text node.

Parameters:
str - value for node's content.
 o append
 public void append(String str)

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

Parameters:
str - character content to append.
 o append
 public void append(Text text)

This will append the content of another Text node to this node.

Parameters:
text - Text node to append.
 o getParent
 public Element getParent()

This will return the parent of this Text node, which is always a JDOM {@link Element}.

Returns:
Element - this node's parent.
 o getDocument
 public Document getDocument()

This retrieves the owning {@link Document} for this Text, or null if not a currently a member of a {@link Document}.

Returns:
Document owning this Text, or null.
 o setParent
 protected Text setParent(Element parent)

This will set the parent of the Text node to the supplied {@link Element}. This method is intentionally left as protected so that only JDOM internals use it.

If you need an instance of this Text node with a new parent, you should get a copy of this node with {@link #clone} and set it on the desired (new) parent Element.

Parameters:
parent - parent for this node.
 o detach
 public Text detach()

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

Returns:
Text - this Text modified.
 o toString
 public String toString()

This returns a String representation of the Text node, suitable for debugging. If the XML representation of the Text node is desired, either {@link #getText} or {@link org.jdom.output.XMLOutputter#outputString(Text)} should be used.

Returns:
String - information about this node.
Overrides:
toString in class Object
 o hashCode
 public final int hashCode()

This will generate a hash code for this node.

Returns:
int - hash code for this node.
Overrides:
hashCode in class Object
 o clone
 public Object clone()

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

Returns:
Text - cloned node.
Overrides:
clone in class Object
 o equals
 public final boolean equals(Object ob)

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

Parameters:
ob - Object to compare to
Returns:
whether the Text nodes are equal
Overrides:
equals in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index