XML for Java Compatibility API 2.0.6

com.ibm.xml.parser
Class Child

java.lang.Object
  |
  +--com.ibm.xml.parser.Child
Direct Known Subclasses:
AttDef, Attlist, ElementDecl, Parent, TXCharacterData, TXNotation, TXPI

public abstract class Child
extends java.lang.Object
implements org.w3c.dom.Node, java.lang.Cloneable, java.io.Serializable, Visitee

The Child class implements the Node interface as defined by the Document Object Model (DOM).

Node is the base type of most objects in the Document Object Model. It may have an arbitrary number (including zero) of sequentially ordered Child Nodes. It usually has a parent Node; the exception being that the root Node in a document hierarchy has no parent.

The child node has an added property, userData, that allows the programmer to attach application specific data to any node in the document tree that extends Child.

Version:
Revision: 56 1.6 src/com/ibm/xml/parser/Child.java, parser, xml4j2, xml4j2_0_6
See Also:
Node, TXElement, TXText, TXComment, TXPI, TXCDATASection, TXNotation, TXAttribute, Parent, Serialized Form

Field Summary
static int ATTDEF
           
static int ATTLIST
           
static int ELEMENT_DECL
           
static java.lang.String NAME_ATTDEF
           
static java.lang.String NAME_ATTLIST
           
static java.lang.String NAME_CDATA
           
static java.lang.String NAME_COMMENT
           
static java.lang.String NAME_DOCFRAGMENT
           
static java.lang.String NAME_DOCUMENT
           
static java.lang.String NAME_ELEMENT_DECL
           
static java.lang.String NAME_PSEUDONODE
           
static java.lang.String NAME_TEXT
           
static int PSEUDONODE
           
 
Constructor Summary
Child()
           
 
Method Summary
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          Throws a DOMException because Child Nodes are leaf Nodes.
 void clearDigest()
          Clears the digest value for this Node and any ancestors.
abstract  java.lang.Object clone()
          Clone this object.
 org.w3c.dom.Node cloneNode(boolean deep)
          This method is defined by DOM.
abstract  boolean equals(org.w3c.dom.Node node, boolean deep)
           
 org.w3c.dom.NamedNodeMap getAttributes()
          Returns null.
 org.w3c.dom.NodeList getChildNodes()
          Returns an empty NodeList object because Child Nodes are leaf Nodes.
 byte[] getDigest()
          Returns the digest value for this Node.
 TXDocument getFactory()
          Returns the factory used for creating this Node.
 org.w3c.dom.Node getFirstChild()
          Returns null because Child Nodes are leaf Nodes.
 org.w3c.dom.Node getFirstWithoutReference()
          Return null
 org.w3c.dom.Node getLastChild()
          Returns null because Child Nodes are leaf Nodes.
 org.w3c.dom.Node getLastWithoutReference()
          Return null
 org.w3c.dom.Node getNextSibling()
          Returns the Node immediately following this Node in a breadth-first traversal of the tree.
 org.w3c.dom.Node getNextWithoutReference()
           
 java.lang.String getNodeValue()
          This method is defined by DOM.
 org.w3c.dom.Document getOwnerDocument()
          This method is defined by DOM.
 org.w3c.dom.Node getParentNode()
          Returns the parent of the given Node instance.
 org.w3c.dom.Node getParentWithoutReference()
           
 org.w3c.dom.Node getPreviousSibling()
          Returns the Node immediately preceding this Node in a breadth-first traversal of the tree.
 org.w3c.dom.Node getPreviousWithoutReference()
           
 java.lang.String getText()
          Returns all text associated with this Node without considering entities.
 java.lang.Object getUserData()
          Returns the user data associated to this child node.
 boolean hasChildNodes()
          Returns false because Child Nodes are leaf Nodes.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          Throws a DOMException because Child Nodes are leaf Nodes.
 XPointer makeXPointer()
          Returns an XPointer instance representing this Node.
 void print(java.io.Writer writer)
          Print this Node and any children in XML format, using the default character encoding.
 void print(java.io.Writer writer, java.lang.String encoding)
          Print this Node and any children in XML format, using the specified character encoding.
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          Throws a DOMException because Child Nodes are leaf Nodes.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node oldChild, org.w3c.dom.Node newChild)
          Throws a DOMException because Child Nodes are leaf Nodes.
 TXElement searchAncestors(int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
          Returns the first TXElement match through all ancestors.
 TXElement searchAncestors(java.lang.String qName)
          Returns the first TXElement match through all ancestors.
 void setFactory(TXDocument factory)
          Sets the factory to be used in creating this Node.
 void setNodeValue(java.lang.String arg)
          This method is defined by DOM.
 void setUserData(java.lang.Object data)
          Sets the user data associated to this child node.
 void toXMLString(java.io.Writer writer)
          Returns this Node and any children in XML format using the default character encoding.
 void toXMLString(java.io.Writer writer, java.lang.String encoding)
          Returns this Node and any children in XML format using the specified character encoding.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENT_DECL

public static final int ELEMENT_DECL

ATTLIST

public static final int ATTLIST

ATTDEF

public static final int ATTDEF

PSEUDONODE

public static final int PSEUDONODE

NAME_DOCUMENT

public static final java.lang.String NAME_DOCUMENT

NAME_COMMENT

public static final java.lang.String NAME_COMMENT

NAME_TEXT

public static final java.lang.String NAME_TEXT

NAME_CDATA

public static final java.lang.String NAME_CDATA

NAME_DOCFRAGMENT

public static final java.lang.String NAME_DOCFRAGMENT

NAME_ATTDEF

public static final java.lang.String NAME_ATTDEF

NAME_ATTLIST

public static final java.lang.String NAME_ATTLIST

NAME_ELEMENT_DECL

public static final java.lang.String NAME_ELEMENT_DECL

NAME_PSEUDONODE

public static final java.lang.String NAME_PSEUDONODE
Constructor Detail

Child

public Child()
Method Detail

clone

public abstract java.lang.Object clone()
Clone this object.
Returns:
Copy of this object.
Overrides:
clone in class java.lang.Object

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)

This method is defined by DOM.

Specified by:
cloneNode in interface org.w3c.dom.Node
Parameters:
deep - ignored.

equals

public abstract boolean equals(org.w3c.dom.Node node,
                               boolean deep)

getNodeValue

public java.lang.String getNodeValue()

This method is defined by DOM.

Specified by:
getNodeValue in interface org.w3c.dom.Node

setNodeValue

public void setNodeValue(java.lang.String arg)

This method is defined by DOM.

Specified by:
setNodeValue in interface org.w3c.dom.Node

getParentNode

public org.w3c.dom.Node getParentNode()
Returns the parent of the given Node instance. If this Node is the root of the document object tree, or if the Node has not been added to a document tree, null is returned.

This method is defined by DOM.

Specified by:
getParentNode in interface org.w3c.dom.Node
Returns:
Parent Node associated with this object, or null if no parent.

getParentWithoutReference

public org.w3c.dom.Node getParentWithoutReference()

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
Returns an empty NodeList object because Child Nodes are leaf Nodes. If the Child class is extended by non-leaf Nodes, this method should be overridden.

This method is defined by DOM.

Specified by:
getChildNodes in interface org.w3c.dom.Node
Returns:
Always returns an empty NodeList.
See Also:
Parent.getChildNodes()

hasChildNodes

public boolean hasChildNodes()
Returns false because Child Nodes are leaf Nodes. If the Child class is extended by non-leaf Nodes, this method should be overridden.

This method is defined by DOM.

Specified by:
hasChildNodes in interface org.w3c.dom.Node
Returns:
Always returns false.
See Also:
Parent.hasChildNodes()

getFirstChild

public org.w3c.dom.Node getFirstChild()
Returns null because Child Nodes are leaf Nodes. If the Child class is extended by non-leaf Nodes, this method should be overridden.

This method is defined by DOM.

Specified by:
getFirstChild in interface org.w3c.dom.Node
Returns:
Always returns null.
See Also:
Parent.getFirstChild()

getFirstWithoutReference

public org.w3c.dom.Node getFirstWithoutReference()
Return null
Returns:
Always returns null.
See Also:
Parent.getFirstWithoutReference()

getLastChild

public org.w3c.dom.Node getLastChild()
Returns null because Child Nodes are leaf Nodes. If the Child class is extended by non-leaf Nodes, this method should be overridden.

This method is defined by DOM.

Specified by:
getLastChild in interface org.w3c.dom.Node
Returns:
Always returns null.
See Also:
Parent.getLastChild()

getLastWithoutReference

public org.w3c.dom.Node getLastWithoutReference()
Return null
Returns:
Always returns null.
See Also:
Parent.getLastWithoutReference()

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
Returns the Node immediately preceding this Node in a breadth-first traversal of the tree. If there is no such Node, null is returned.

This method is defined by DOM.

Specified by:
getPreviousSibling in interface org.w3c.dom.Node
Returns:
The Child Node immediately preceding this object in the Parent's Child list, or null if this object is the first sibling.
See Also:
getNextSibling()

getPreviousWithoutReference

public org.w3c.dom.Node getPreviousWithoutReference()

getNextSibling

public org.w3c.dom.Node getNextSibling()
Returns the Node immediately following this Node in a breadth-first traversal of the tree. If there is no such Node, null is returned.

This method is defined by DOM.

Specified by:
getNextSibling in interface org.w3c.dom.Node
Returns:
The Child Node immediately following this object in the parent's Child list, or null if this object is the last sibling.
See Also:
getPreviousSibling()

getNextWithoutReference

public org.w3c.dom.Node getNextWithoutReference()

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
Returns null.

This method is defined by DOM.

Specified by:
getAttributes in interface org.w3c.dom.Node
See Also:
TXElement.getAttributes()

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
Throws a DOMException because Child Nodes are leaf Nodes. If the Child class is extended by non-leaf Nodes, this method should be overridden.

This method is defined by DOM.

Specified by:
insertBefore in interface org.w3c.dom.Node
Parameters:
newChild - Not used.
refChild - Not used.
Returns:
Nothing is ever returned (an exception is thrown).
Throws:
org.w3c.dom.DOMException - Thrown to indicate that no children exist in leaf Nodes.
See Also:
Parent.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node oldChild,
                                     org.w3c.dom.Node newChild)
                              throws org.w3c.dom.DOMException
Throws a DOMException because Child Nodes are leaf Nodes. If the Child class is extended by non-leaf Nodes, this method should be overridden.

This method is defined by DOM.

Specified by:
replaceChild in interface org.w3c.dom.Node
Parameters:
oldChild - Not used.
newChild - Not used.
Returns:
Nothing is ever returned (an exception is thrown).
Throws:
org.w3c.dom.DOMException - Thrown to indicate that no children exist in leaf Nodes.
See Also:
Parent.replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
                             throws org.w3c.dom.DOMException
Throws a DOMException because Child Nodes are leaf Nodes. If the Child class is extended by non-leaf Nodes, this method should be overridden.

This method is defined by DOM.

Specified by:
removeChild in interface org.w3c.dom.Node
Parameters:
oldChild - Not used.
Returns:
Nothing is ever returned (an exception is thrown).
Throws:
org.w3c.dom.DOMException - Thrown to indicate that no children exist in leaf Nodes.
See Also:
Parent.removeChild(org.w3c.dom.Node)

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
                             throws org.w3c.dom.DOMException
Throws a DOMException because Child Nodes are leaf Nodes. If the Child class is extended by non-leaf Nodes, this method should be overridden.

This method is defined by DOM.

Specified by:
appendChild in interface org.w3c.dom.Node
See Also:
Parent.removeChild(org.w3c.dom.Node)

getText

public java.lang.String getText()
Returns all text associated with this Node without considering entities. This method is intended to be overridden by DOM-defined Node types.
Returns:
Always returns "".
See Also:
TXText.getText(), toXMLString(java.io.Writer, java.lang.String)

searchAncestors

public TXElement searchAncestors(java.lang.String qName)
Returns the first TXElement match through all ancestors. Searching is done recursively, not just for the immediate Parent Node. The specified qualified name refers to the Element tag name (see Namespace for details).
Parameters:
qName - Qualified name to match against in all ancestors.
Returns:
The first matching TXElement Node, or null if no matches.
See Also:
Namespace

searchAncestors

public TXElement searchAncestors(int matchType,
                                 java.lang.String uri,
                                 java.lang.String qNameOrLocalName)
Returns the first TXElement match through all ancestors. All specified input parameters must match for an Element to be judged as matched (see Namespace for details). Various namespace matching algorithms are supported: qualified name, local name & URI, or URI. Searching is done recursively, not just for the immediate Parent Node.
Parameters:
matchType - Namespace match type: Match.QNAME, Match.NSLOCAL, Match.NS
uri - When matching a URI, specify the value to match; otherwise, specify null.
qNameOrLocalName - When matching a qualified name or local name, specify the value to match; otherwise, specify null.
Returns:
The first matching TXElement Node, or null if no matches.
See Also:
Namespace

toXMLString

public void toXMLString(java.io.Writer writer,
                        java.lang.String encoding)
                 throws java.io.IOException,
                        LibraryException
Returns this Node and any children in XML format using the specified character encoding.
Parameters:
writer - The character output stream to use.
encoding - Java character encoding in use by writer.
Throws:
java.io.IOException - Thrown if a Node can not be visitted because of an invalid witer.
LibraryException - Thrown if the document object hierarchy is in an unknown state.
See Also:
getText()

toXMLString

public void toXMLString(java.io.Writer writer)
                 throws java.io.IOException,
                        LibraryException
Returns this Node and any children in XML format using the default character encoding.
Parameters:
writer - The character output stream to use.
Throws:
java.io.IOException - Thrown if a Node can not be visitted because of an invalid witer.
LibraryException - Thrown if the document object hierarchy is in an unknown state.
See Also:
getText()

print

public void print(java.io.Writer writer,
                  java.lang.String encoding)
           throws java.io.IOException,
                  LibraryException
Print this Node and any children in XML format, using the specified character encoding.
Parameters:
writer - The character output stream to use.
encoding - Java character encoding in use by writer.
Throws:
java.io.IOException - Thrown if a Node can not be visitted because of an invalid witer.
LibraryException - Thrown if the document object hierarchy is in an unknown state.
See Also:
TXDocument.printWithFormat(java.io.Writer)

print

public void print(java.io.Writer writer)
           throws java.io.IOException,
                  LibraryException
Print this Node and any children in XML format, using the default character encoding.
Parameters:
writer - The character output stream to use.
Throws:
java.io.IOException - Thrown if a Node can not be visitted because of an invalid witer.
LibraryException - Thrown if the document object hierarchy is in an unknown state.
See Also:
TXDocument.printWithFormat(java.io.Writer)

getOwnerDocument

public org.w3c.dom.Document getOwnerDocument()

This method is defined by DOM.

Specified by:
getOwnerDocument in interface org.w3c.dom.Node

getFactory

public TXDocument getFactory()
Returns the factory used for creating this Node.
Returns:
The factory used for creating this Node, or null if no factory.
See Also:
setFactory(com.ibm.xml.parser.TXDocument)

setFactory

public void setFactory(TXDocument factory)
Sets the factory to be used in creating this Node.
Parameters:
factory - The factory to be used in creating this Node.
See Also:
getFactory()

getDigest

public byte[] getDigest()
                 throws LibraryException
Returns the digest value for this Node. If no digest value currently exists, calculate and store it.
Returns:
The array of bytes for the resulting hash value.
Throws:
LibraryException - Thrown if the document object hierarchy is in an unknown state.
See Also:
clearDigest()

clearDigest

public void clearDigest()
Clears the digest value for this Node and any ancestors.
See Also:
getDigest()

makeXPointer

public XPointer makeXPointer()
Returns an XPointer instance representing this Node.
Returns:
XPointer instance, or null if this Node can not be represented by an XPointer.
See Also:
XPointer

setUserData

public void setUserData(java.lang.Object data)
Sets the user data associated to this child node. This method is useful for attaching application specific information to any node in the document tree.
Parameters:
data - The user data to attach to this child node. This value may be null.
See Also:
getUserData()

getUserData

public java.lang.Object getUserData()
Returns the user data associated to this child node. The returned value can be null if no user data is associated.
See Also:
setUserData(java.lang.Object)

XML for Java Compatibility API 2.0.6