com.caucho.xml
Class QNode

java.lang.Object
  |
  +--com.caucho.xml.QAbstractNode
        |
        +--com.caucho.xml.QNode
All Implemented Interfaces:
CauchoNode, Node, NodeList
Direct Known Subclasses:
QAttr, com.caucho.xml.QAttributedNode, com.caucho.xml.QDocumentFragment, QDocumentType

public abstract class QNode
extends QAbstractNode
implements NodeList

QNode represents any node that can have children.


Fields inherited from class com.caucho.xml.QAbstractNode
L
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
QNode()
           
 
Method Summary
 Node appendChild(Node newNode)
          Adds the node newChild to the end of the list of children of this node.
 boolean checkValid()
          For testing...
 boolean equals(Node arg, boolean deep)
           
 boolean equals(java.lang.Object arg)
           
 NamedNodeMap getAttributes()
          A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
 NodeList getChildNodes()
          Returns a node list of the children.
 Node getFirstChild()
          The first child of this node.
 Node getLastChild()
          The last child of this node.
 int getLength()
          Returns the number of children.
 QAbstractNode getNextPreorder()
           
 Node getNextSibling()
          The node immediately following this node.
 java.lang.String getNodeValue()
          The value of this node, depending on its type; see the table above.
 Node getPreviousSibling()
          The node immediately preceding this node.
 boolean hasChildNodes()
          Returns whether this node has any children.
 Node insertBefore(Node newChild, Node refChild)
          Inserts the node newChild before the existing child node refChild.
 Node item(int index)
          Returns the child with the given index.
 void normalize()
          Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
 Node removeChild(Node oldChild)
          Removes the child node indicated by oldChild from the list of children, and returns it.
 Node replaceChild(Node newChild, Node refChild)
          Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
 void setNodeValue(java.lang.String value)
          The value of this node, depending on its type; see the table above.
 
Methods inherited from class com.caucho.xml.QAbstractNode
cloneNode, getCanonicalName, getColumn, getFilename, getLine, getLocalName, getNamespaceURI, getNextContent, getOwnerDocument, getParentNode, getPrefix, getPreviousContent, getTextValue, hasAttributes, hasContent, isSupported, print, printHtml, printPretty, setLocation, setPrefix, supports
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
getNodeName, getNodeType
 

Constructor Detail

QNode

public QNode()
Method Detail

getNodeValue

public java.lang.String getNodeValue()
Description copied from interface: Node
The value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect.
Overrides:
getNodeValue in class QAbstractNode
Following copied from interface: org.w3c.dom.Node
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
DOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.

setNodeValue

public void setNodeValue(java.lang.String value)
Description copied from interface: Node
The value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect.
Overrides:
setNodeValue in class QAbstractNode
Following copied from interface: org.w3c.dom.Node
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
DOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.

getChildNodes

public NodeList getChildNodes()
Returns a node list of the children.
Overrides:
getChildNodes in class QAbstractNode

getFirstChild

public Node getFirstChild()
Description copied from interface: Node
The first child of this node. If there is no such node, this returns null.
Overrides:
getFirstChild in class QAbstractNode

getLastChild

public Node getLastChild()
Description copied from interface: Node
The last child of this node. If there is no such node, this returns null.
Overrides:
getLastChild in class QAbstractNode

getPreviousSibling

public Node getPreviousSibling()
Description copied from interface: Node
The node immediately preceding this node. If there is no such node, this returns null.
Overrides:
getPreviousSibling in class QAbstractNode

getNextSibling

public Node getNextSibling()
Description copied from interface: Node
The node immediately following this node. If there is no such node, this returns null.
Overrides:
getNextSibling in class QAbstractNode

getAttributes

public NamedNodeMap getAttributes()
Description copied from interface: Node
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
Overrides:
getAttributes in class QAbstractNode

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
Description copied from interface: Node
Inserts the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end of the list of children.
If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed.
Overrides:
insertBefore in class QAbstractNode
Following copied from interface: org.w3c.dom.Node
Parameters:
newChild - The node to insert.
refChild - The reference node, i.e., the node before which the new node must be inserted.
Returns:
The node being inserted.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to insert is one of this node's ancestors or this node itself.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly.
NOT_FOUND_ERR: Raised if refChild is not a child of this node.

replaceChild

public Node replaceChild(Node newChild,
                         Node refChild)
                  throws DOMException
Description copied from interface: Node
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed.
Overrides:
replaceChild in class QAbstractNode
Following copied from interface: org.w3c.dom.Node
Parameters:
newChild - The new node to put in the child list.
oldChild - The node being replaced in the list.
Returns:
The node replaced.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to put in is one of this node's ancestors or this node itself.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of this node.

removeChild

public Node removeChild(Node oldChild)
                 throws DOMException
Description copied from interface: Node
Removes the child node indicated by oldChild from the list of children, and returns it.
Overrides:
removeChild in class QAbstractNode
Following copied from interface: org.w3c.dom.Node
Parameters:
oldChild - The node being removed.
Returns:
The node removed.
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of this node.

appendChild

public Node appendChild(Node newNode)
                 throws DOMException
Description copied from interface: Node
Adds the node newChild to the end of the list of children of this node. If the newChild is already in the tree, it is first removed.
Overrides:
appendChild in class QAbstractNode
Following copied from interface: org.w3c.dom.Node
Parameters:
newChild - The node to add.If it is a DocumentFragment object, the entire contents of the document fragment are moved into the child list of this node
Returns:
The node added.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to append is one of this node's ancestors or this node itself.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the previous parent of the node being inserted is readonly.

hasChildNodes

public boolean hasChildNodes()
Description copied from interface: Node
Returns whether this node has any children.
Overrides:
hasChildNodes in class QAbstractNode
Following copied from interface: org.w3c.dom.Node
Returns:
true if this node has any children, false otherwise.

normalize

public void normalize()
Description copied from interface: Node
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.In cases where the document contains CDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate between Text nodes and CDATASection nodes.
Overrides:
normalize in class QAbstractNode

checkValid

public boolean checkValid()
                   throws java.lang.Exception
Description copied from interface: CauchoNode
For testing...
Overrides:
checkValid in class QAbstractNode

getNextPreorder

public QAbstractNode getNextPreorder()
Overrides:
getNextPreorder in class QAbstractNode

equals

public boolean equals(java.lang.Object arg)
Overrides:
equals in class java.lang.Object

equals

public boolean equals(Node arg,
                      boolean deep)
Overrides:
equals in class QAbstractNode

item

public Node item(int index)
Returns the child with the given index.
Specified by:
item in interface NodeList
Following copied from interface: org.w3c.dom.NodeList
Parameters:
index - Index into the collection.
Returns:
The node at the indexth position in the NodeList, or null if that is not a valid index.

getLength

public int getLength()
Returns the number of children.
Specified by:
getLength in interface NodeList