com.novell.xml.xpath
Class XPathAttributeNode

java.lang.Object
  extended bycom.novell.xml.dom.NodeDecorator
      extended bycom.novell.xml.xpath.XPathAttributeNode
All Implemented Interfaces:
Comparable, Node

public class XPathAttributeNode
extends NodeDecorator
implements Comparable

A node decorator that modifies the behavior of DOM Attr nodes to make them more suitable for XPath.

The XPath evaulations use this decorator to override the getParentNode method of attribute nodes in the source tree, and to determine the document order of an element's attributes. The XPath evaluators ensure that expressions use this decorator to represent source attributes.


Field Summary
 
Fields inherited from class com.novell.xml.dom.NodeDecorator
node
 
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
XPathAttributeNode(Node attribute, Node ownerElement)
          Constructs a new decorator that decorates the specified attribute node and is an attribute of the specified element node.
 
Method Summary
 int compareTo(Object obj)
          Compares this attribute node to another attribute node for document order.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 Node getParentNode()
          DOM-defined method that returns the parent of this attribute node.
 
Methods inherited from class com.novell.xml.dom.NodeDecorator
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPathAttributeNode

public XPathAttributeNode(Node attribute,
                          Node ownerElement)
Constructs a new decorator that decorates the specified attribute node and is an attribute of the specified element node.

Parameters:
attribute - the attribute node to decorate
ownerElement - the element node that this node is an attribute of
Method Detail

getParentNode

public final Node getParentNode()
DOM-defined method that returns the parent of this attribute node. In DOM Level 1, this is always null. To better match the XPath data model, this implementation overrides the DOM definition and returns the Element node that this node is an attribute of. Note that this causes this node to no longer be DOM Level 1 compliant.

Specified by:
getParentNode in interface Node
Overrides:
getParentNode in class NodeDecorator
Returns:
the Element node that this node is an attribute of

compareTo

public int compareTo(Object obj)
Compares this attribute node to another attribute node for document order. The attributes are assumed to belong to the same element. The 16-Dec-98 draft does not define document order for attributes, so for now we assume lexicographic order of the attribute names.

Specified by:
compareTo in interface Comparable
Parameters:
obj - the other XPathAttributeNode to compare with; it is declared as an Object to conform with the Comparable interface
Returns:
a negative integer, zero, or a positive integer depending on whether this attribute node precedes, is the same as, or follows the other node
Throws:
ClassCastException - if the specified object is not an XPathAttributeNode

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one. This implementation returns true if and only if the other object is an XPathAttributeNode and the underlying DOM attribute nodes are the SAME object

Parameters:
obj - the object to compare against
Returns:
true if this object is "equal to" obj, false if not