com.novell.xml.xpath
Class Axis

java.lang.Object
  extended bycom.novell.xml.xpath.Axis
All Implemented Interfaces:
ContextNodeList
Direct Known Subclasses:
AxisAttribute, AxisElement, AxisNamespace

public abstract class Axis
extends Object
implements ContextNodeList

This class represents a generic XPath axis. Derived classes must override first() and next() to provide navigation among the nodes specified by the particular axis.

See Also:
Basis

Nested Class Summary
protected  class Axis.AxisMark
           
 
Field Summary
protected  WhitespaceStripper stripper
           
 
Fields inherited from interface com.novell.xml.xpath.ContextNodeList
DOCUMENT_ORDER, REVERSE_DOCUMENT_ORDER, UNKNOWN_ORDER
 
Constructor Summary
protected Axis()
           
 
Method Summary
 int count()
          Return the number of nodes in the axis.
 void done()
          stop referencing resources that are no longer needed
protected  Node getContextNode()
          Access to context node setup by init()
protected  Node incPosition(Node node)
          Increment the "last node" position.
protected  void init()
          Initialization of common code.
 int order()
          Return order in which nodes are returned from first()-next() NOTE: derived classes that are in reverse document order MUST override this
 int position()
          Return the position in the axis of the last node returned by first() or next().
abstract  int principalNodeType()
          Return the principal node type for the axis.
 void setup(Node contextNode, WhitespaceStripper stripper)
          Initialize an axis instance for a context node
protected  boolean stripNode(Node node)
          Return whether an arbitrary node should be stripped
abstract  String toString()
          Provide a readable description of the axis for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.novell.xml.xpath.ContextNodeList
first, getMark, next, returnToMark
 

Field Detail

stripper

protected WhitespaceStripper stripper
Constructor Detail

Axis

protected Axis()
Method Detail

setup

public void setup(Node contextNode,
                  WhitespaceStripper stripper)
Initialize an axis instance for a context node

Parameters:
contextNode - the context node
stripper - The WhitespaceStripper implementation for stripping whitespace nodes

done

public void done()
stop referencing resources that are no longer needed


principalNodeType

public abstract int principalNodeType()
Return the principal node type for the axis. For the attribute axis, this is org.w3c.dom.Node.ATTRIBUTE_NODE For the namespace axis, this is com.novell.xml.xpath.XPathAttributeNode.NAMESPACE_NODE For all other axes, this is org.w3c.dom.Node.ELEMENT_NODE

Returns:
node type for axis

toString

public abstract String toString()
Provide a readable description of the axis for debugging.

Returns:
String representation of the axis (the axis name)

count

public int count()
          throws XPathEvaluationException
Return the number of nodes in the axis. This is implemented in terms of the derived class's first() and next() functions and caches the resulting number. NOTE: first() must have been called previous for meaningful results

Specified by:
count in interface ContextNodeList
Returns:
the number of nodes in the axis
Throws:
XPathEvaluationException

position

public int position()
Return the position in the axis of the last node returned by first() or next(). Note: this will continue to return the position of the last node returned even if next() is called again.

Specified by:
position in interface ContextNodeList
Returns:
The 1-based position of the node in the axis

order

public int order()
Return order in which nodes are returned from first()-next() NOTE: derived classes that are in reverse document order MUST override this

Specified by:
order in interface ContextNodeList
Returns:
ContextNodeList.DOCUMENT_ORDER

init

protected void init()
Initialization of common code. Derived classes must call this at beginning of their first() implementations


incPosition

protected Node incPosition(Node node)
Increment the "last node" position. Derived classes must call this before returning the result of first() and next()

Parameters:
node - Node to be returned from first() or next() (may be null)
Returns:
The passed node (so derived class can write "return incPosition(node)"

getContextNode

protected Node getContextNode()
Access to context node setup by init()

Returns:
The context node

stripNode

protected boolean stripNode(Node node)
Return whether an arbitrary node should be stripped

Parameters:
node - The node to test
Returns:
True if the node is a text or cdata section node and the WhitespaceStripper object passed to setup() returns true.