XML for Java Compatibility API 2.0.13

com.ibm.xml.parser
Class TXText

java.lang.Object
  |
  +--com.ibm.xml.parser.Child
        |
        +--com.ibm.xml.parser.TXCharacterData
              |
              +--com.ibm.xml.parser.TXText
Direct Known Subclasses:
TreeFactory.TreeText, TXCDATASection

public class TXText
extends TXCharacterData
implements org.w3c.dom.Text

The TXText class implements the Text interface as defined by the Document Object Model (DOM).

The Text object contains the non-markup content of an Element. If there is no markup inside an Element's content, the text will be contained in a single Text object that is the child of the Element. Any markup will parse into Child Elements that are siblings of the Text Nodes on either side of it, and whose content will be represented as Text Node children of the markup Element.

Version:
Revision: 08 1.5 src/com/ibm/xml/parser/TXText.java, parser, xml4j2, xml4j2_0_13
See Also:
Text, TXCDATASection, Serialized Form

Fields inherited from class com.ibm.xml.parser.Child
ATTDEF, ATTLIST, ELEMENT_DECL, NAME_ATTDEF, NAME_ATTLIST, NAME_CDATA, NAME_COMMENT, NAME_DOCFRAGMENT, NAME_DOCUMENT, NAME_ELEMENT_DECL, NAME_PSEUDONODE, NAME_TEXT, PSEUDONODE
 
Constructor Summary
TXText(java.lang.String data)
          Constructor.
 
Method Summary
 void acceptPost(Visitor visitor)
          Implements the accept operation of the visitor design pattern when the end of a TXText Node is recognized when traversing the document object tree.
 void acceptPre(Visitor visitor)
          Implements the accept operation of the visitor design pattern when the start of a TXText Node is recognized when traversing the document object tree.
 java.lang.Object clone()
          Clone this Text Node using the appropriate factory.
 boolean equals(org.w3c.dom.Node arg, boolean deep)
           
 boolean getIsIgnorableWhitespace()
          Returns, at the Text level, whether space is to be preserved.
 java.lang.String getLanguage()
          Returns the XML language ID (the value of the xml:lang attribute) in use for this Text Node.
 java.lang.String getNodeName()
           
 short getNodeType()
          Returns that this object is a Text Node.
 java.lang.String getText()
          Returns all text associated with this Node without considering entities.
static java.lang.String makePrintable(java.lang.String string)
          Translate escape sequences in the specified string into printable characters.
 void setIsIgnorableWhitespace(boolean isIgnorableWhitespace)
          Sets, at the Text level, whether space is to be preserved.
 void splice(org.w3c.dom.Element element, int offset, int count)
          Deprecated. This method will be removed in next release.
 org.w3c.dom.Text splitText(int offset)
          Split this text node into two text nodes at the specified offset, keeping both in the tree as siblings.
static java.lang.String trim(java.lang.String string)
          Trim all leading and trailing whitespace in the specified String.
static java.lang.String trim(java.lang.String string, boolean trimHead, boolean trimTail)
          Conditionally trim all leading and trailing whitespace in the specified String.
 
Methods inherited from class com.ibm.xml.parser.TXCharacterData
appendData, deleteData, getData, getLength, getNodeValue, insertData, replaceData, setData, setNodeValue, substringData
 
Methods inherited from class com.ibm.xml.parser.Child
appendChild, clearDigest, cloneNode, getAttributes, getChildNodes, getDigest, getFactory, getFirstChild, getFirstWithoutReference, getLastChild, getLastWithoutReference, getNextSibling, getNextWithoutReference, getOwnerDocument, getParentNode, getParentWithoutReference, getPreviousSibling, getPreviousWithoutReference, getUserData, hasChildNodes, insertBefore, makeXPointer, print, print, removeChild, replaceChild, searchAncestors, searchAncestors, setFactory, setUserData, toXMLString, toXMLString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TXText

public TXText(java.lang.String data)
Constructor.
Parameters:
data - The actual content of the Text Node.
Method Detail

clone

public java.lang.Object clone()
Clone this Text Node using the appropriate factory.

This method is defined by Child.

Returns:
Cloned Text Node.
Overrides:
clone in class Child
See Also:
Child.clone()

equals

public boolean equals(org.w3c.dom.Node arg,
                      boolean deep)
Parameters:
deep - ignored.
Overrides:
equals in class Child

getNodeType

public short getNodeType()
Returns that this object is a Text Node.

This method is defined by DOM.

Returns:
Text Node indicator.

getNodeName

public java.lang.String getNodeName()

getText

public java.lang.String getText()
Returns all text associated with this Node without considering entities.

This method is defined by Child.

Returns:
Text associated with this object, or "" if no Text.
Overrides:
getText in class Child
See Also:
Child.toXMLString(java.io.Writer, java.lang.String), TXCharacterData.getData()

getIsIgnorableWhitespace

public boolean getIsIgnorableWhitespace()
Returns, at the Text level, whether space is to be preserved. This value is used, for example, to determine if space is to be preserved in Text Nodes during printWithFormat() operations.
Returns:
=true space is to be preserved; =false space is to be ignored.
See Also:
setIsIgnorableWhitespace(boolean), Parser.setPreserveSpace(boolean), TXElement.setPreserveSpace(boolean), TXDocument.printWithFormat(java.io.Writer)

setIsIgnorableWhitespace

public void setIsIgnorableWhitespace(boolean isIgnorableWhitespace)
Sets, at the Text level, whether space is to be preserved. This value is used, for example, to determine if space is to be preserved in Text Nodes during printWithFormat() operations.

By default, this Text Node is not ignorable whitespace. The XML4J parser may, depending on the value if its isPreserveSpace, override this default setting if no significant text is detected for this Text Node.

Parameters:
isIgnorableWhitespace - =true space is to be preserved; =false space is to be ignored.
See Also:
getIsIgnorableWhitespace(), Parser.setPreserveSpace(boolean), TXElement.setPreserveSpace(boolean), TXDocument.printWithFormat(java.io.Writer)

getLanguage

public java.lang.String getLanguage()
Returns the XML language ID (the value of the xml:lang attribute) in use for this Text Node. If this Text Node has no explicitly defined language attribute, Parent Nodes will be recursively checked.
Returns:
The XML language ID, or null if all Parents have no language ID.

splice

public void splice(org.w3c.dom.Element element,
                   int offset,
                   int count)
            throws java.lang.IllegalArgumentException,
                   java.lang.RuntimeException
Deprecated. This method will be removed in next release.
Insert the specified Element as a sibling of this Text Node. The result of this operation may be the creation of up to 2 new Text Nodes: the character data specified by the offset and count will form one Text Node that will become the Child of the inserted Element, and the remainder of the character data (after the offset and count) will form another Text Node, becoming a sibling of this Text Node.
Parameters:
element - The Element to insert in the tree; this instance must be an instance of TXElement.
offset - 0-based offset into existing character data in this Text Node.
count - Number of characters to copy to Child Text Node of Element.
Throws:
java.lang.IllegalArgumentException - Thrown if element is not a TXElement.
java.lang.RuntimeException - Thrown if this Text Node has no Parent.

splitText

public org.w3c.dom.Text splitText(int offset)
                           throws org.w3c.dom.DOMException
Split this text node into two text nodes at the specified offset, keeping both in the tree as siblings.

This method is defined by DOM.

Specified by:
splitText in interface org.w3c.dom.Text

trim

public static java.lang.String trim(java.lang.String string)
Trim all leading and trailing whitespace in the specified String. All strings of white space are replaced by a single space character (#x20).
Parameters:
string - String to be trimmed.
Returns:
The trimmed string.

trim

public static java.lang.String trim(java.lang.String string,
                                    boolean trimHead,
                                    boolean trimTail)
Conditionally trim all leading and trailing whitespace in the specified String. All strings of white space are replaced by a single space character (#x20).
Parameters:
string - String to be trimmed.
trimHead - Trim leading whitespace?
trimTail - Trim trailing whitespace?
Returns:
The trimmed string.

makePrintable

public static java.lang.String makePrintable(java.lang.String string)
Translate escape sequences in the specified string into printable characters. For example, \r is translated into \\r.
Parameters:
string - String to translate.
Returns:
The translated string.

acceptPre

public void acceptPre(Visitor visitor)
               throws java.lang.Exception
Implements the accept operation of the visitor design pattern when the start of a TXText Node is recognized when traversing the document object tree.
Parameters:
visitor - The implemention of the Visitor operation (toXMLString, digest, ...)
Throws:
java.lang.Exception - Thrown if this Node can not be visitted, or traversal modification is requested.
See Also:
Visitor, TreeTraversal, NonRecursivePreorderTreeTraversal, TreeTraversalException

acceptPost

public void acceptPost(Visitor visitor)
                throws java.lang.Exception
Implements the accept operation of the visitor design pattern when the end of a TXText Node is recognized when traversing the document object tree.
Parameters:
visitor - The implemention of the Visitor operation (toXMLString, digest, ...)
Throws:
java.lang.Exception - Thrown if this Node can not be visitted, or traversal modification is requested.
See Also:
Visitor, TreeTraversal, NonRecursivePreorderTreeTraversal, TreeTraversalException

XML for Java Compatibility API 2.0.13