org.exolab.adaptx.xpath
Class XPathNode

java.lang.Object
  extended by org.exolab.adaptx.xpath.XPathNode
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Attribute, Comment, DocumentWrapperXPathNode, Element, Namespace, ProcessingInstruction, Root, Text

public abstract class XPathNode
extends java.lang.Object
implements java.io.Serializable

Abstract class representing a node in a document tree, on which XPath expressions can be evaluated. This abstract class provides all the services required by XPath, and enables multiple implementations to exist. It does not make use of iterators or traversals, but assumes double-linked lists are used to maintain node lists.

Version:
$Revision: 3633 $
Author:
Keith Visco, Assaf Arkin
See Also:
Serialized Form

Field Summary
static int ATTRIBUTE
          Node is an attribute.
static int COMMENT
          Node is a comment.
static int ELEMENT
          Node is an element.
static int NAMESPACE
          Node is a namespace node.
static int PI
          Node is a processing instruction.
static int ROOT
          Node is a root node.
static int TEXT
          Node is a text node.
 
Constructor Summary
XPathNode()
           
 
Method Summary
abstract  java.lang.String getAttribute(java.lang.String uri, java.lang.String local)
          Returns the value of the named attribute, or null if the node has no such attribute.
abstract  XPathNode getFirstAttribute()
          Returns the first in a list of attribute nodes, or null if the node has no attributes.
abstract  XPathNode getFirstChild()
          Returns the first child node of this node, or null if the node has no children.
abstract  XPathNode getFirstNamespace()
          Returns the first in a list of namespace nodes, or null if the node has no namespaces.
abstract  java.lang.String getLocalName()
          Returns the local name of the node.
abstract  java.lang.String getNamespacePrefix(java.lang.String uri)
          Returns the namespace prefix associated with this namespace URI, as defined in the context of this node.
abstract  java.lang.String getNamespaceURI()
          Returns the namespace URI the node.
abstract  java.lang.String getNamespaceURI(java.lang.String prefix)
          Returns the namespace URI associated with this namespace prefix, as defined in the context of this node.
abstract  XPathNode getNext()
          Returns the next sibling node in document order, or null if this node is the last node.
abstract  int getNodeType()
          Returns the type of this node.
abstract  XPathNode getParentNode()
          Returns the parent node, or null if the node has no parent.
abstract  XPathNode getPrevious()
          Returns the previous sibling node in document order, or null if this node is the first node.
abstract  XPathNode getRootNode()
          Returns the root node.
abstract  java.lang.String getStringValue()
          Returns the string value of the node.
abstract  boolean hasChildNodes()
          Returns true if this node has any child nodes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENT

public static final int ELEMENT
Node is an element.

See Also:
Constant Field Values

ATTRIBUTE

public static final int ATTRIBUTE
Node is an attribute.

See Also:
Constant Field Values

TEXT

public static final int TEXT
Node is a text node.

See Also:
Constant Field Values

PI

public static final int PI
Node is a processing instruction.

See Also:
Constant Field Values

COMMENT

public static final int COMMENT
Node is a comment.

See Also:
Constant Field Values

ROOT

public static final int ROOT
Node is a root node.

See Also:
Constant Field Values

NAMESPACE

public static final int NAMESPACE
Node is a namespace node.

See Also:
Constant Field Values
Constructor Detail

XPathNode

public XPathNode()
Method Detail

getFirstChild

public abstract XPathNode getFirstChild()
Returns the first child node of this node, or null if the node has no children. Child nodes are only returned for an element or root node.

Returns:
The first child node of this node, or null

hasChildNodes

public abstract boolean hasChildNodes()
Returns true if this node has any child nodes.

Returns:
True if this node has any child nodes.

getNext

public abstract XPathNode getNext()
Returns the next sibling node in document order, or null if this node is the last node. This method is value for any node except the root node.

Returns:
The next sibling node in document order, or null

getPrevious

public abstract XPathNode getPrevious()
Returns the previous sibling node in document order, or null if this node is the first node. This method can is valid for any node except the root node.

Returns:
The previous sibling node in document order, or null

getNodeType

public abstract int getNodeType()
Returns the type of this node.

Returns:
The type of this node

getFirstAttribute

public abstract XPathNode getFirstAttribute()
Returns the first in a list of attribute nodes, or null if the node has no attributes. This method is valid only for the element node.

Returns:
The first in a list of attribute nodes, or null

getAttribute

public abstract java.lang.String getAttribute(java.lang.String uri,
                                              java.lang.String local)
Returns the value of the named attribute, or null if the node has no such attribute. If the argument uri is null, the node's namespace URI will be used. This method is valid only for the element node.

Parameters:
uri - The attribute's namespace URI, or null
local - The attribute's local name
Returns:
The attribute's value, or null if no such attribute exists

getFirstNamespace

public abstract XPathNode getFirstNamespace()
Returns the first in a list of namespace nodes, or null if the node has no namespaces. This method is valid only for the element node.

Returns:
The first in a list of namespace nodes, or null

getLocalName

public abstract java.lang.String getLocalName()
Returns the local name of the node. Returns the local name of an element or attribute, the prefix of a namespace node, the target of a processing instruction, or null for all other node types.

Returns:
The local name of the node, or null if the node has no name

getNamespaceURI

public abstract java.lang.String getNamespaceURI()
Returns the namespace URI the node. Returns the namespace URI of an element, attribute or namespace node, or null for all other node types.

Returns:
The namespace URI of the node, or null if the node has no namespace URI

getParentNode

public abstract XPathNode getParentNode()
Returns the parent node, or null if the node has no parent. This method is valid on all node types except the root node. Attribute and namespace nodes have the element as their parent node.

Returns:
The parent node, or null

getRootNode

public abstract XPathNode getRootNode()
Returns the root node. Note to implementors: This should NOT return null.

Returns:
The root node

getStringValue

public abstract java.lang.String getStringValue()
Returns the string value of the node. The string value of a text node or an attribute node is it's text value. The string value of an element or a root node is the concatenation of the string value of all its child nodes. The string value of a namespace node is its namespace URI. The string value of a processing instruction is the instruction, and the string value of a comment is the comment text.

Returns:
The string value of the node

getNamespaceURI

public abstract java.lang.String getNamespaceURI(java.lang.String prefix)
Returns the namespace URI associated with this namespace prefix, as defined in the context of this node. Returns null if the prefix is undefined. Returns empty if the prefix is defined and associated with no namespace. This method is valid only for element nodes.

Parameters:
prefix - The namespace prefix
Returns:
The namespace URI, or null

getNamespacePrefix

public abstract java.lang.String getNamespacePrefix(java.lang.String uri)
Returns the namespace prefix associated with this namespace URI, as defined in the context of this node. Returns null if no prefix is defined for this namespace URI. Returns an empty string if the default prefix is associated with this namespace URI. This method is valid only for element nodes.

Parameters:
uri - The namespace URI
Returns:
The namespace prefix, or null