XML for Java Compatibility API 2.0.6

com.ibm.xml.parser
Class Parent

java.lang.Object
  |
  +--com.ibm.xml.parser.Child
        |
        +--com.ibm.xml.parser.Parent
Direct Known Subclasses:
DTD, EntityDecl, GeneralReference, TXAttribute, TXDocument, TXDocumentFragment, TXElement

public abstract class Parent
extends Child

The Parent class extends Child and provides services in support of non-leaf Nodes.

Version:
Revision: 82 1.5 src/com/ibm/xml/parser/Parent.java, parser, xml4j2, xml4j2_0_6
See Also:
TXElement, TXDocument, DTD, Child, Node, 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
Parent()
           
 
Method Summary
 void addElement(Child newChild)
          Deprecated. Use appendChild()
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          Inserts the specified Node as the last Child in this Node's list of children.
protected abstract  void checkChildType(org.w3c.dom.Node child)
          Check whether child is allowed to be insered in this node or not.
 java.util.Enumeration elements()
          Return an Enumeration instance of all children of this Node.
 void expandEntityReferences()
           
 org.w3c.dom.NodeList getChildNodes()
          Returns a NodeList object that will enumerate all children of this Node.
 Child[] getChildrenArray()
          Make an array of Child Nodes for all children of this Node.
 org.w3c.dom.Node getFirstChild()
          Returns the first Child of this Node.
 org.w3c.dom.Node getFirstWithoutReference()
           
 org.w3c.dom.Node getLastChild()
          Returns the last Child of this Node.
 org.w3c.dom.Node getLastWithoutReference()
           
 java.lang.String getText()
          Return all text associated with this Node and its children without considering entities.
 boolean hasChildNodes()
          Returns true if this Node has any children, or false if this Node has no children at all.
 void insert(org.w3c.dom.Node child, int index)
          Insert a Child Node into the specified position in this Node's list of children.
 org.w3c.dom.Node insertAfter(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          Inserts a Child Node (newChild) after the existing Child Node (refChild).
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          Inserts a Child Node (newChild) before the existing Child Node (refChild).
 org.w3c.dom.Node insertFirst(org.w3c.dom.Node newChild)
          Inserts the specified Node as the first Child in this Node's list of children.
 org.w3c.dom.Node insertLast(org.w3c.dom.Node newChild)
          Inserts the specified Node as the last Child in this Node's list of children.
protected  void processAfterRemove(org.w3c.dom.Node oldChild)
           
protected  void realInsert(org.w3c.dom.Node child, int index)
          Insert a Child Node into the specified position in this Node's list of children.
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          Removes the Child Node indicated by oldChild from this Nodes list of children, and returns it.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
          Replaces the Child Node oldChild with newChild in this Node's list of children, and return the oldChild Node.
 
Methods inherited from class com.ibm.xml.parser.Child
clearDigest, clone, cloneNode, equals, getAttributes, getDigest, getFactory, getNextSibling, getNextWithoutReference, getNodeValue, getOwnerDocument, getParentNode, getParentWithoutReference, getPreviousSibling, getPreviousWithoutReference, getUserData, makeXPointer, print, print, searchAncestors, searchAncestors, setFactory, setNodeValue, setUserData, toXMLString, toXMLString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parent

public Parent()
Method Detail

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
Returns a NodeList object that will enumerate all children of this Node. If there are no children, an empty NodeList is returned. The content of the returned NodeList is "live" in the sense that changes to the children of the Node object that it was created from will be immediately reflected in the Nodes returned by the NodeList; it is not a static snapshot of the content of the Node. Similarly, changes made to the Nodes returned by the NodeList will be immediately reflected in the tree, including the set of children of the Node that the NodeList was created from.

This method is defined by DOM.

Returns:
A NodeList of all children of this Parent Node.
Overrides:
getChildNodes in class Child
See Also:
hasChildNodes(), elements(), getFirstChild(), getLastChild(), getChildrenArray()

hasChildNodes

public boolean hasChildNodes()
Returns true if this Node has any children, or false if this Node has no children at all. This method exists both for convenience as well as to allow implementations to be able to bypass object allocation, which may be required for implementing getChildNodes().

This method is defined by DOM.

Returns:
True if any children exist; otherwise, returns false.
Overrides:
hasChildNodes in class Child
See Also:
getChildNodes(), elements(), getFirstChild(), getLastChild(), getChildrenArray()

elements

public java.util.Enumeration elements()
Return an Enumeration instance of all children of this Node.
Returns:
An enumeration of all children of this Parent Node, or null if no children.
See Also:
hasChildNodes(), getChildNodes(), getFirstChild(), getLastChild(), getChildrenArray()

getChildrenArray

public Child[] getChildrenArray()
Make an array of Child Nodes for all children of this Node.
Returns:
An array of all children of this Parent Node, or null if no children.
See Also:
hasChildNodes(), getChildNodes(), getFirstChild(), elements()

getFirstChild

public org.w3c.dom.Node getFirstChild()
Returns the first Child of this Node. If there are no children, null is returned.

This method is defined by DOM.

Returns:
The first Child of this Parent Node, or null if no children.
Overrides:
getFirstChild in class Child
See Also:
getLastChild(), hasChildNodes(), getChildNodes(), elements()

getFirstWithoutReference

public org.w3c.dom.Node getFirstWithoutReference()
Overrides:
getFirstWithoutReference in class Child
See Also:
getFirstChild(), getLastWithoutReference()

getLastChild

public org.w3c.dom.Node getLastChild()
Returns the last Child of this Node. If there are no children, null is returned.

This method is defined by DOM.

Returns:
The last Child of this Parent Node, or null if no children.
Overrides:
getLastChild in class Child
See Also:
getFirstChild(), hasChildNodes(), getChildNodes(), elements()

getLastWithoutReference

public org.w3c.dom.Node getLastWithoutReference()
Overrides:
getLastWithoutReference in class Child
See Also:
getLastChild(), getFirstWithoutReference()

checkChildType

protected abstract void checkChildType(org.w3c.dom.Node child)
                                throws org.w3c.dom.DOMException
Check whether child is allowed to be insered in this node or not. When not allowed, a DOMException with HIERARCHY_REQUEST_ERR is thrown.

realInsert

protected void realInsert(org.w3c.dom.Node child,
                          int index)
                   throws org.w3c.dom.DOMException
Insert a Child Node into the specified position in this Node's list of children.
Parameters:
child - The Node being inserted. Must not DocumentFragment.
index - 0-based index into the list of children.
Throws:
org.w3c.dom.DOMException - Thrown if index is not valid.
See Also:
insertBefore(org.w3c.dom.Node, org.w3c.dom.Node), insertAfter(org.w3c.dom.Node, org.w3c.dom.Node), insertFirst(org.w3c.dom.Node), insertLast(org.w3c.dom.Node)

insert

public void insert(org.w3c.dom.Node child,
                   int index)
            throws org.w3c.dom.DOMException
Insert a Child Node into the specified position in this Node's list of children.
Parameters:
child - The Node being inserted.
index - 0-based index into the list of children.
Throws:
org.w3c.dom.DOMException - Thrown if index is not valid.
See Also:
insertBefore(org.w3c.dom.Node, org.w3c.dom.Node), insertAfter(org.w3c.dom.Node, org.w3c.dom.Node), insertFirst(org.w3c.dom.Node), insertLast(org.w3c.dom.Node)

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
Inserts a Child Node (newChild) before the existing Child Node (refChild). If refChild is null, insert newChild at the end of the list of children. If refChild is not a Child of this Node, a DOMException is thrown.

This method is defined by DOM.

Parameters:
newChild - The Child Node being inserted.
refChild - The Child Node to insert newChild before, or null if newChild is to be inserted at the end of the Child list.
Returns:
The Child Node being inserted.
Throws:
org.w3c.dom.DOMException - Thrown if refChild is not a Child of this object.
Overrides:
insertBefore in class Child
See Also:
insert(org.w3c.dom.Node, int), insertAfter(org.w3c.dom.Node, org.w3c.dom.Node), insertFirst(org.w3c.dom.Node), insertLast(org.w3c.dom.Node)

insertAfter

public org.w3c.dom.Node insertAfter(org.w3c.dom.Node newChild,
                                    org.w3c.dom.Node refChild)
                             throws org.w3c.dom.DOMException
Inserts a Child Node (newChild) after the existing Child Node (refChild). If refChild is null, insert newChild at the beginning of the list of children. If refChild is not a Child of this Node, a DOMException is thrown.
Parameters:
newChild - The Child Node being inserted.
refChild - The Child Node to insert newChild after, or null if newChild is to be inserted at the beginning of the Child list.
Returns:
The Child Node being inserted.
Throws:
org.w3c.dom.DOMException - Thrown if refChild is not a Child of this object.
See Also:
insertBefore(org.w3c.dom.Node, org.w3c.dom.Node), insert(org.w3c.dom.Node, int), insertFirst(org.w3c.dom.Node), insertLast(org.w3c.dom.Node)

insertFirst

public org.w3c.dom.Node insertFirst(org.w3c.dom.Node newChild)
Inserts the specified Node as the first Child in this Node's list of children.
Parameters:
newChild - The Child Node being inserted.
Returns:
The Child Node being inserted.
See Also:
insertBefore(org.w3c.dom.Node, org.w3c.dom.Node), insertAfter(org.w3c.dom.Node, org.w3c.dom.Node), insert(org.w3c.dom.Node, int), insertLast(org.w3c.dom.Node)

insertLast

public org.w3c.dom.Node insertLast(org.w3c.dom.Node newChild)
Inserts the specified Node as the last Child in this Node's list of children.
Parameters:
newChild - The Child Node being inserted.
Returns:
The Child Node being inserted.
See Also:
insertBefore(org.w3c.dom.Node, org.w3c.dom.Node), insertAfter(org.w3c.dom.Node, org.w3c.dom.Node), insertFirst(org.w3c.dom.Node), insert(org.w3c.dom.Node, int), appendChild(org.w3c.dom.Node)

addElement

public void addElement(Child newChild)
Deprecated. Use appendChild()
Inserts the specified Node as the last Child in this Node's list of children.
Parameters:
newChild - The Child Node being inserted.
Returns:
The Child Node being inserted.

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
Inserts the specified Node as the last Child in this Node's list of children.
Parameters:
newChild - The Child Node being inserted.
Returns:
The Child Node being inserted.
Overrides:
appendChild in class Child
See Also:
insertBefore(org.w3c.dom.Node, org.w3c.dom.Node), insertAfter(org.w3c.dom.Node, org.w3c.dom.Node), insertFirst(org.w3c.dom.Node), insert(org.w3c.dom.Node, int), insertLast(org.w3c.dom.Node)

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node oldChild)
                              throws org.w3c.dom.DOMException
Replaces the Child Node oldChild with newChild in this Node's list of children, and return the oldChild Node. If oldChild was not already a Child of this Node, a DOMException is thrown.

This method is defined by DOM.

Note: The parameters are not intuitively positioned. The first parameter is the new child node which replaces the child node specified in the second parameter. This definition departs from the conventional "replace a by b" representation.

Parameters:
newChild - The Child Node to replace with.
oldChild - The Child Node being replaced.
Returns:
The Child Node being replaced.
Throws:
org.w3c.dom.DOMException - Thrown if oldChild is not a Child of this object.
Overrides:
replaceChild in class Child
See Also:
removeChild(org.w3c.dom.Node)

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
                             throws org.w3c.dom.DOMException
Removes the Child Node indicated by oldChild from this Nodes list of children, and returns it. If oldChild was not a Child of this Node, a DOMException is thrown.

This method is defined by DOM.

Parameters:
oldChild - The Child Node being removed.
Returns:
The Child Node being removed.
Throws:
org.w3c.dom.DOMException - Thrown if oldChild is not a Child of this object.
Overrides:
removeChild in class Child
See Also:
replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)

processAfterRemove

protected void processAfterRemove(org.w3c.dom.Node oldChild)
See Also:
TXElement.collectNamespaceAttributes(), GeneralReference.collectNamespaceAttributes()

expandEntityReferences

public void expandEntityReferences()

getText

public java.lang.String getText()
Return all text associated with this Node and its children without considering entities.

This method is defined by Child.

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

XML for Java Compatibility API 2.0.6