BEA Systems, Inc.

com.beasys.commerce.util.dom
Class NodeImpl

java.lang.Object
  |
  +--com.beasys.commerce.util.dom.DOMBase
        |
        +--com.beasys.commerce.util.dom.NodeImpl
Direct Known Subclasses:
AttrImpl, CharacterDataImpl, DocumentFragmentImpl, DocumentImpl, DocumentTypeImpl, ElementImpl, EntityImpl, EntityReferenceImpl, NotationImpl, ProcessingInstructionImpl

public abstract class NodeImpl
extends DOMBase
implements org.w3c.dom.Node

A base class implementation of the W3C's DOM Node object.

This provides support for child nodes and a parent node. Subclasses need to override the cloneNode(), getNodeType(), getNodeName(); subclasses might choose to override getAllowableChildrenTypes(), getNodeValue(), and setNodeValue(). Elements should override getAttributes() to provide support for attributes.

See Also:
Serialized Form

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
NodeImpl(org.w3c.dom.Document document, org.w3c.dom.Node parent)
          Constructor.
 
Method Summary
 org.w3c.dom.Node appendChild(org.w3c.dom.Node child)
          Append a new child node to the end of children node list.
abstract  org.w3c.dom.Node cloneNode()
          Clone yourself, including attributes, but not children.
 org.w3c.dom.Node cloneNode(boolean deep)
          Clone this node.
 org.w3c.dom.NamedNodeMap getAttributes()
          Return the attributes of this node.
 org.w3c.dom.NodeList getChildNodes()
          Return the children nodes of this node.
 org.w3c.dom.Node getFirstChild()
          Get the first child node.
 org.w3c.dom.Node getLastChild()
          Get the last child node.
 org.w3c.dom.Node getNextSibling()
          Get the next sibling of this node.
abstract  java.lang.String getNodeName()
          Get the node's name.
abstract  short getNodeType()
          Get the node's type.
static java.lang.String getNodeType(short type)
          Get a string version of the node type.
 java.lang.String getNodeValue()
          Get the node's value.
 org.w3c.dom.Node getParentNode()
          Get the parent node.
 org.w3c.dom.Node getPreviousSibling()
          Get the previous sibling of this node.
 boolean hasChildNodes()
          Return if this has children nodes.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          Insert a new child node in front of the given child node in our children node list.
 org.w3c.dom.Node removeChild(org.w3c.dom.Node child)
          Remove the specified child node from children node list.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
          Replace the specified child node with the new child node in our children node list.
 void setNodeValue(java.lang.String value)
          Set the node's value.
 void setParentNode(org.w3c.dom.Node parentNode)
          Set the parent node.
 
Methods inherited from class com.beasys.commerce.util.dom.DOMBase
checkOwnerDocument, getOwnerDocument, isReadOnly, setReadOnly
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeImpl

public NodeImpl(org.w3c.dom.Document document,
                org.w3c.dom.Node parent)
Constructor.
Parameters:
document - the document we're part of.
parent - our parent node.
Method Detail

cloneNode

public abstract org.w3c.dom.Node cloneNode()
Clone yourself, including attributes, but not children.

This is different from cloneNode(boolean); this is always a shallow clone.


appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node child)
                             throws org.w3c.dom.DOMException
Append a new child node to the end of children node list.
Specified by:
appendChild in interface org.w3c.dom.Node
Parameters:
child - the new child node.
Returns:
child.
Throws:
org.w3c.dom.DOMException - thrown if the child cannot be added to this node.

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
Insert a new child node in front of the given child node in our children node list.
Specified by:
insertBefore in interface org.w3c.dom.Node
Parameters:
newChild - the child to add.
refChild - the child to add in front of.
Returns:
newChild.
Throws:
org.w3c.dom.DOMException - thrown if the child cannot be added to this node.

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node child)
                             throws org.w3c.dom.DOMException
Remove the specified child node from children node list.
Specified by:
removeChild in interface org.w3c.dom.Node
Parameters:
child - the child to remove.
Returns:
child.
Throws:
org.w3c.dom.DOMException - thrown if the child cannot be removed from this node.

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node oldChild)
                              throws org.w3c.dom.DOMException
Replace the specified child node with the new child node in our children node list.
Specified by:
replaceChild in interface org.w3c.dom.Node
Parameters:
newChild - the new child replacing the old child.
oldChild - the old child being replaced.
Returns:
oldChild.
Throws:
org.w3c.dom.DOMException - thrown if the child cannot be replaced.

hasChildNodes

public boolean hasChildNodes()
Return if this has children nodes.
Specified by:
hasChildNodes in interface org.w3c.dom.Node

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Clone this node.
Specified by:
cloneNode in interface org.w3c.dom.Node
Parameters:
deep - true to also clone the children of this node.
Returns:
the new node.
See Also:
#clone()

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
Return the attributes of this node.

Element's should override to return a NamedNodeMap.

Specified by:
getAttributes in interface org.w3c.dom.Node
Returns:
null.

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
Return the children nodes of this node.
Specified by:
getChildNodes in interface org.w3c.dom.Node
Returns:
the children node list.

getFirstChild

public org.w3c.dom.Node getFirstChild()
Get the first child node.
Specified by:
getFirstChild in interface org.w3c.dom.Node
Returns:
the first child node, or null if there are no children.

getLastChild

public org.w3c.dom.Node getLastChild()
Get the last child node.
Specified by:
getLastChild in interface org.w3c.dom.Node
Returns:
the first child node, or null if there are no children.

getNextSibling

public org.w3c.dom.Node getNextSibling()
Get the next sibling of this node.
Specified by:
getNextSibling in interface org.w3c.dom.Node

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
Get the previous sibling of this node.
Specified by:
getPreviousSibling in interface org.w3c.dom.Node

getNodeType

public abstract short getNodeType()
Get the node's type.
Specified by:
getNodeType in interface org.w3c.dom.Node

getNodeName

public abstract java.lang.String getNodeName()
Get the node's name.

This value is subclass specific; see the DOM documentation for further details.

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

getNodeValue

public java.lang.String getNodeValue()
Get the node's value.

This value is subclass specific; see the DOM documentation for further details.

The method here returns null. Subclasses that have node values should override this method.

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

setNodeValue

public void setNodeValue(java.lang.String value)
Set the node's value.

The implementation of this is subclass specific; see the DOM documentation for further details.

The method here does nothing. Subclasses that have node values should override this method.

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

getParentNode

public org.w3c.dom.Node getParentNode()
Get the parent node.
Specified by:
getParentNode in interface org.w3c.dom.Node

setParentNode

public void setParentNode(org.w3c.dom.Node parentNode)
Set the parent node.
Parameters:
parentNode - the new parent node (can be null which means no longer in a tree).

getNodeType

public static java.lang.String getNodeType(short type)
Get a string version of the node type.

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved