Class com.ibm.xml.parser.Child
java.lang.Object
|
+----com.ibm.xml.parser.Child
- Subclasses:
- AttDef, Attlist, ElementDecl, Entity, Parent, PseudoNode, TXAttribute, TXComment, TXNotation, TXPI, TXText
- public abstract class Child
- extends java.lang.Object
- implements 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.
- Version:
- Revision: 88 1.5 src/com/ibm/xml/parser/Child.java, xml4jsrc, xml4j-jtcsv, xml4j_1_0_4
- See Also:
- Node, TXElement, TXText, TXComment, TXPI, TXCDATASection, TXNotation, TXAttribute, Parent
Constructor Summary
|
Child()
|
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DOCUMENTTYPE
public static final int DOCUMENTTYPE
ELEMENTDEFINITION
public static final int ELEMENTDEFINITION
ATTLIST
public static final int ATTLIST
ATTDEF
public static final int ATTDEF
ENTITY
public static final int ENTITY
NOTATION
public static final int NOTATION
GENERALREFERENCE
public static final int GENERALREFERENCE
PSEUDONODE
public static final int PSEUDONODE
Child
public Child()
clone
public abstract java.lang.Object clone()
- Clone this object.
- Returns:
- Copy of this object.
- Overrides:
- clone in class java.lang.Object
getParentNode
public 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.
- Implements:
- getParentNode in interface Node
- Returns:
- Parent Node associated with this object, or null if no parent.
getChildNodes
public NodeIterator getChildNodes()
- Returns an empty NodeIterator 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.
- Implements:
- getChildNodes in interface Node
- Returns:
- Always returns an empty Node iterator.
- See Also:
- 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.
- Implements:
- hasChildNodes in interface Node
- Returns:
- Always returns false.
- See Also:
- hasChildNodes
getFirstChild
public 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.
- Implements:
- getFirstChild in interface Node
- Returns:
- Always returns null.
- See Also:
- getFirstChild
getPreviousSibling
public 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.
- Implements:
- getPreviousSibling in interface 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
getNextSibling
public 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.
- Implements:
- getNextSibling in interface 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
insertBefore
public Node insertBefore(Node newChild,
Node refChild) throws NotMyChildException
- Throws a NotMyChildException 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.
- Implements:
- insertBefore in interface Node
- Parameters:
newChild
- Not used.
refChild
- Not used.
- Returns:
- Nothing is ever returned (an exception is thrown).
- Throws:
- NotMyChildException - Thrown to indicate that no children exist in leaf Nodes.
- See Also:
- insertBefore
replaceChild
public Node replaceChild(Node oldChild,
Node newChild) throws NotMyChildException
- Throws a NotMyChildException 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.
- Implements:
- replaceChild in interface Node
- Parameters:
oldChild
- Not used.
newChild
- Not used.
- Returns:
- Nothing is ever returned (an exception is thrown).
- Throws:
- NotMyChildException - Thrown to indicate that no children exist in leaf Nodes.
- See Also:
- replaceChild
removeChild
public Node removeChild(Node oldChild) throws NotMyChildException
- Throws a NotMyChildException 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.
- Implements:
- removeChild in interface Node
- Parameters:
oldChild
- Not used.
- Returns:
- Nothing is ever returned (an exception is thrown).
- Throws:
- NotMyChildException - Thrown to indicate that no children exist in leaf Nodes.
- See Also:
- removeChild
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:
- getText, toXMLString
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:
- printWithFormat
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:
- printWithFormat
getFactory
public ElementFactory 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
setFactory
public void setFactory(ElementFactory 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