com.novell.xml.dom
Class NodeDecorator

java.lang.Object
  extended bycom.novell.xml.dom.NodeDecorator
All Implemented Interfaces:
Node
Direct Known Subclasses:
XPathAttributeNode, XPathNamespaceNode

public abstract class NodeDecorator
extends Object
implements Node

An abstract class for DOM node decorators. This class implements the org.w3c.dom.Node interface and simply delegates all method calls to another node. The intent is that NodeDecorator subclasses will override one or more methods to modify the DOM-defined behavior. This allows the behavior of existing DOM nodes to be modified without subclassing those nodes. See the Decorator pattern described in Design Paterns, Gamma, et. al.


Field Summary
protected  Node node
          The node being decorated.
 
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
NodeDecorator(Node node)
          Constructs a new node decorator that decorates the specified node.
 
Method Summary
 Node appendChild(Node newChild)
          DOM-defined method that adds the specified node to the end of the list of children of this node.
 Node cloneNode(boolean deep)
          DOM-defined method that returns a duplicate of this node.
 NamedNodeMap getAttributes()
          DOM-defined method that returns a NamedNameMap containing the attributes of this node (if it is an Element) or null otherwise.
 NodeList getChildNodes()
          DOM-defined method that returns a NodeList containing all children of this node.
 Node getFirstChild()
          DOM-defined method that returns the first child of this node.
 Node getLastChild()
          DOM-defined method that returns the last child of this node.
 String getLocalName()
          Returns the local part of the qualified name of this node.
 String getNamespaceURI()
          The namespace URI of this node, or null if it is unspecified.
 Node getNextSibling()
          DOM-defined method that returns the node immediately following this node.
 String getNodeName()
          DOM-defined method that returns the name of this node, depending on its type.
 short getNodeType()
          DOM-defined method that returns a code representing the type of the underlying object.
 String getNodeValue()
          DOM-defined method that returns the value of this node, depending on its type.
 Document getOwnerDocument()
          DOM-defined method that returns the Document object associated with this node.
 Node getParentNode()
          DOM-defined method that returns the parent of this node.
 String getPrefix()
          The namespace prefix of this node, or null if it is unspecified.
 Node getPreviousSibling()
          DOM-defined method that returns the node immediately preceding this node.
 boolean hasAttributes()
          Returns whether this node (if it is an element) has any attributes.
 boolean hasChildNodes()
          DOM-defined convenience method that returns whether this node has any children.
 Node insertBefore(Node newChild, Node refChild)
          DOM-defined method that inserts the node newChild before the existing child node refChild.
 boolean isSupported(String feature, String version)
          Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
 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)
          DOM-defined method that removes the child node indicated by oldChild from the list of children, and returns it.
 Node replaceChild(Node newChild, Node oldChild)
          DOM-defined method that replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
 void setNodeValue(String nodeValue)
          DOM-defined method that sets the value of this node, depending on its type.
 void setPrefix(String prefix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

protected Node node
The node being decorated.

Constructor Detail

NodeDecorator

public NodeDecorator(Node node)
Constructs a new node decorator that decorates the specified node.

Parameters:
node - the node to decorate
Method Detail

appendChild

public Node appendChild(Node newChild)
                 throws DOMException
DOM-defined method that adds the specified node to the end of the list of children of this node.

Specified by:
appendChild in interface Node
Throws:
DOMException

cloneNode

public Node cloneNode(boolean deep)
DOM-defined method that returns a duplicate of this node.

Specified by:
cloneNode in interface Node

getAttributes

public NamedNodeMap getAttributes()
DOM-defined method that returns a NamedNameMap containing the attributes of this node (if it is an Element) or null otherwise.

Specified by:
getAttributes in interface Node

getChildNodes

public NodeList getChildNodes()
DOM-defined method that returns a NodeList containing all children of this node.

Specified by:
getChildNodes in interface Node

getFirstChild

public Node getFirstChild()
DOM-defined method that returns the first child of this node.

Specified by:
getFirstChild in interface Node

getLastChild

public Node getLastChild()
DOM-defined method that returns the last child of this node.

Specified by:
getLastChild in interface Node

getNextSibling

public Node getNextSibling()
DOM-defined method that returns the node immediately following this node.

Specified by:
getNextSibling in interface Node

getNodeName

public String getNodeName()
DOM-defined method that returns the name of this node, depending on its type.

Specified by:
getNodeName in interface Node

getNodeType

public short getNodeType()
DOM-defined method that returns a code representing the type of the underlying object.

Specified by:
getNodeType in interface Node

getNodeValue

public String getNodeValue()
                    throws DOMException
DOM-defined method that returns the value of this node, depending on its type. Note that this is the DOM-defined node value which is different than the XSL-defined node value.

Specified by:
getNodeValue in interface Node
Throws:
DOMException

getOwnerDocument

public Document getOwnerDocument()
DOM-defined method that returns the Document object associated with this node. This is also the Document object used to create new nodes. When this node is a Document, this is null.

Specified by:
getOwnerDocument in interface Node

getParentNode

public Node getParentNode()
DOM-defined method that returns the parent of this node. All nodes, except Document, DocumentFragment, and Attr may have a parent.

Specified by:
getParentNode in interface Node

getPreviousSibling

public Node getPreviousSibling()
DOM-defined method that returns the node immediately preceding this node.

Specified by:
getPreviousSibling in interface Node

hasChildNodes

public boolean hasChildNodes()
DOM-defined convenience method that returns whether this node has any children.

Specified by:
hasChildNodes in interface Node

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
DOM-defined method that inserts the node newChild before the existing child node refChild.

Specified by:
insertBefore in interface Node
Throws:
DOMException

removeChild

public Node removeChild(Node oldChild)
                 throws DOMException
DOM-defined method that removes the child node indicated by oldChild from the list of children, and returns it.

Specified by:
removeChild in interface Node
Throws:
DOMException

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
                  throws DOMException
DOM-defined method that replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.

Specified by:
replaceChild in interface Node
Throws:
DOMException

setNodeValue

public void setNodeValue(String nodeValue)
                  throws DOMException
DOM-defined method that sets the value of this node, depending on its type. Note that this is the DOM-defined node value which is different than the XSL-defined node value.

Specified by:
setNodeValue in interface Node
Throws:
DOMException

normalize

public 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. 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.

Specified by:
normalize in interface Node

isSupported

public boolean isSupported(String feature,
                           String version)
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.

Specified by:
isSupported in interface Node
Parameters:
feature - The name of the feature to test. This is the same name which can be passed to the method hasFeature on DOMImplementation.
version - This is the version number of the feature to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return true.
Returns:
Returns true if the specified feature is supported on this node, false otherwise.
Since:
DOM Level 2

getNamespaceURI

public String getNamespaceURI()
The namespace URI of this node, or null if it is unspecified.
This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.Per the Namespaces in XML Specification an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.

Specified by:
getNamespaceURI in interface Node
Since:
DOM Level 2

getPrefix

public String getPrefix()
The namespace prefix of this node, or null if it is unspecified.
Note that setting this attribute, when permitted, changes the nodeName attribute, which holds the qualified name, as well as the tagName and name attributes of the Element and Attr interfaces, when applicable.
Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the namespaceURI and localName do not change.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.

Specified by:
getPrefix in interface Node
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the specified prefix is malformed, if the namespaceURI of this node is null, if the specified prefix is "xml" and the namespaceURI of this node is different from " http://www.w3.org/XML/1998/namespace", if this node is an attribute and the specified prefix is "xmlns" and the namespaceURI of this node is different from " http://www.w3.org/2000/xmlns/", or if this node is an attribute and the qualifiedName of this node is "xmlns" .
Since:
DOM Level 2

setPrefix

public void setPrefix(String prefix)
               throws DOMException
Specified by:
setPrefix in interface Node
Throws:
DOMException

getLocalName

public String getLocalName()
Returns the local part of the qualified name of this node.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.

Specified by:
getLocalName in interface Node
Since:
DOM Level 2

hasAttributes

public boolean hasAttributes()
Returns whether this node (if it is an element) has any attributes.

Specified by:
hasAttributes in interface Node
Returns:
true if this node has any attributes, false otherwise.
Since:
DOM Level 2