org.jaxen
Interface Navigator

All Superinterfaces:
Serializable
All Known Implementing Classes:
DefaultNavigator

public interface Navigator
extends Serializable

Interface for navigating around an arbitrary object model, using xpath semantics.

There is a method to obtain a java.util.Iterator, for each axis specified by XPath. If the target object model does not support the semantics of a particular axis, an UnsupportedAxisException is to be thrown.

Author:
bob mcwhirter (bob@werken.com), James Strachan

Method Summary
 Iterator getAncestorAxisIterator(Object contextNode)
          Retrieve an Iterator matching the ancestor xpath axis.
 Iterator getAncestorOrSelfAxisIterator(Object contextNode)
          Retrieve an Iterator matching the ancestor-or-self xpath axis.
 Iterator getAttributeAxisIterator(Object contextNode)
          Retrieve an Iterator matching the attribute xpath axis.
 String getAttributeName(Object attr)
          Retrieve the name of the given attribute node.
 String getAttributeNamespaceUri(Object attr)
          Retrieve the namespace URI of the given attribute node.
 String getAttributeQName(Object attr)
          Retrieve the QName of the given attribute node.
 String getAttributeStringValue(Object attr)
          Retrieve the string-value of an attribute node.
 Iterator getChildAxisIterator(Object contextNode)
          Retrieve an Iterator matching the child xpath axis.
 String getCommentStringValue(Object comment)
          Retrieve the string-value of a comment node.
 Iterator getDescendantAxisIterator(Object contextNode)
          Retrieve an Iterator matching the descendant xpath axis.
 Iterator getDescendantOrSelfAxisIterator(Object contextNode)
          Retrieve an Iterator matching the descendant-or-self xpath axis.
 Object getDocument(String uri)
          Loads a document from the given URI
 Object getDocumentNode(Object contextNode)
          Returns the document node that contains the given context node.
 Object getElementById(Object contextNode, String elementId)
          Returns the element whose ID is given by elementId.
 String getElementName(Object element)
          Retrieve the name of the given element node.
 String getElementNamespaceUri(Object element)
          Retrieve the namespace URI of the given element node.
 String getElementQName(Object element)
          Retrieve the QName of the given element node.
 String getElementStringValue(Object element)
          Retrieve the string-value of an element node.
 Iterator getFollowingAxisIterator(Object contextNode)
          Retrieve an Iterator matching the following xpath axis.
 Iterator getFollowingSiblingAxisIterator(Object contextNode)
          Retrieve an Iterator matching the following-sibling xpath axis.
 Iterator getNamespaceAxisIterator(Object contextNode)
          Retrieve an Iterator matching the namespace xpath axis.
 String getNamespacePrefix(Object ns)
          Retrieve the namespace prefix of a namespace node.
 String getNamespaceStringValue(Object ns)
          Retrieve the string-value of a namespace node.
 short getNodeType(Object node)
          Returns a number that identifies the type of node that the given object represents in this navigator.
 Iterator getParentAxisIterator(Object contextNode)
          Retrieve an Iterator matching the parent xpath axis.
 Object getParentNode(Object contextNode)
          Returns the parent of the given context node.
 Iterator getPrecedingAxisIterator(Object contextNode)
          Retrieve an Iterator matching the preceding xpath axis.
 Iterator getPrecedingSiblingAxisIterator(Object contextNode)
          Retrieve an Iterator matching the preceding-sibling xpath axis.
 String getProcessingInstructionData(Object pi)
          Retrieve the data of a processing-instruction.
 String getProcessingInstructionTarget(Object pi)
          Retrieve the target of a processing-instruction.
 Iterator getSelfAxisIterator(Object contextNode)
          Retrieve an Iterator matching the self xpath axis.
 String getTextStringValue(Object txt)
          Retrieve the string-value of a text node.
 boolean isAttribute(Object object)
          Returns whether the given object is an attribute node.
 boolean isComment(Object object)
          Returns whether the given object is a comment node.
 boolean isDocument(Object object)
          Returns whether the given object is a document node.
 boolean isElement(Object object)
          Returns whether the given object is an element node.
 boolean isNamespace(Object object)
          Returns whether the given object is a namespace node.
 boolean isProcessingInstruction(Object object)
          Returns whether the given object is a processing-instruction node.
 boolean isText(Object object)
          Returns whether the given object is a text node.
 XPath parseXPath(String xpath)
          Returns a parsed form of the given xpath string, which will be suitable for queries on documents that use the same navigator as this one.
 String translateNamespacePrefixToUri(String prefix, Object element)
          Translate a namespace prefix to a namespace URI, possibly considering a particular element node.
 

Method Detail

getChildAxisIterator

public Iterator getChildAxisIterator(Object contextNode)
                              throws UnsupportedAxisException
Retrieve an Iterator matching the child xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getDescendantAxisIterator

public Iterator getDescendantAxisIterator(Object contextNode)
                                   throws UnsupportedAxisException
Retrieve an Iterator matching the descendant xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getParentAxisIterator

public Iterator getParentAxisIterator(Object contextNode)
                               throws UnsupportedAxisException
Retrieve an Iterator matching the parent xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getAncestorAxisIterator

public Iterator getAncestorAxisIterator(Object contextNode)
                                 throws UnsupportedAxisException
Retrieve an Iterator matching the ancestor xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getFollowingSiblingAxisIterator

public Iterator getFollowingSiblingAxisIterator(Object contextNode)
                                         throws UnsupportedAxisException
Retrieve an Iterator matching the following-sibling xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getPrecedingSiblingAxisIterator

public Iterator getPrecedingSiblingAxisIterator(Object contextNode)
                                         throws UnsupportedAxisException
Retrieve an Iterator matching the preceding-sibling xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getFollowingAxisIterator

public Iterator getFollowingAxisIterator(Object contextNode)
                                  throws UnsupportedAxisException
Retrieve an Iterator matching the following xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getPrecedingAxisIterator

public Iterator getPrecedingAxisIterator(Object contextNode)
                                  throws UnsupportedAxisException
Retrieve an Iterator matching the preceding xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getAttributeAxisIterator

public Iterator getAttributeAxisIterator(Object contextNode)
                                  throws UnsupportedAxisException
Retrieve an Iterator matching the attribute xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getNamespaceAxisIterator

public Iterator getNamespaceAxisIterator(Object contextNode)
                                  throws UnsupportedAxisException
Retrieve an Iterator matching the namespace xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getSelfAxisIterator

public Iterator getSelfAxisIterator(Object contextNode)
                             throws UnsupportedAxisException
Retrieve an Iterator matching the self xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getDescendantOrSelfAxisIterator

public Iterator getDescendantOrSelfAxisIterator(Object contextNode)
                                         throws UnsupportedAxisException
Retrieve an Iterator matching the descendant-or-self xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getAncestorOrSelfAxisIterator

public Iterator getAncestorOrSelfAxisIterator(Object contextNode)
                                       throws UnsupportedAxisException
Retrieve an Iterator matching the ancestor-or-self xpath axis.
Parameters:
contextNode - The origin context node.
Returns:
An Iterator capable of traversing the axis.
Throws:
UnsupportedAxisException - is the semantics of this axis are not supported by this object model.

getDocument

public Object getDocument(String uri)
                   throws FunctionCallException
Loads a document from the given URI
Parameters:
uri - is the URI of the document to load
Throws:
FunctionCallException - if the document could not be loaded

getDocumentNode

public Object getDocumentNode(Object contextNode)
Returns the document node that contains the given context node.
Parameters:
object - The context node.
Returns:
The document of the context node.
See Also:
isDocument(Object)

getParentNode

public Object getParentNode(Object contextNode)
                     throws UnsupportedAxisException
Returns the parent of the given context node.

The parent of any node must either be a document node or an element node.

Parameters:
object - The context node.
Returns:
The parent of the context node.
See Also:
isDocument(java.lang.Object), isElement(java.lang.Object)

getElementNamespaceUri

public String getElementNamespaceUri(Object element)
Retrieve the namespace URI of the given element node.
Parameters:
element - The context element node.
Returns:
The namespace URI of the element node.

getElementName

public String getElementName(Object element)
Retrieve the name of the given element node.
Parameters:
element - The context element node.
Returns:
The name of the element node.

getElementQName

public String getElementQName(Object element)
Retrieve the QName of the given element node.
Parameters:
element - The context element node.
Returns:
The QName of the element node.

getAttributeNamespaceUri

public String getAttributeNamespaceUri(Object attr)
Retrieve the namespace URI of the given attribute node.
Parameters:
element - The context attribute node.
Returns:
The namespace URI of the attribute node.

getAttributeName

public String getAttributeName(Object attr)
Retrieve the name of the given attribute node.
Parameters:
element - The context attribute node.
Returns:
The name of the attribute node.

getAttributeQName

public String getAttributeQName(Object attr)
Retrieve the QName of the given attribute node.
Parameters:
element - The context attribute node.
Returns:
The QName of the attribute node.

getProcessingInstructionTarget

public String getProcessingInstructionTarget(Object pi)
Retrieve the target of a processing-instruction.
Parameters:
pi - The context processing-instruction node.
Returns:
The target of the processing-instruction node.

getProcessingInstructionData

public String getProcessingInstructionData(Object pi)
Retrieve the data of a processing-instruction.
Parameters:
pi - The context processing-instruction node.
Returns:
The data of the processing-instruction node.

isDocument

public boolean isDocument(Object object)
Returns whether the given object is a document node. A document node is the node that is selected by the xpath expression /.
Parameters:
object - The object to test.
Returns:
true if the object is a document node, else false

isElement

public boolean isElement(Object object)
Returns whether the given object is an element node.
Parameters:
object - The object to test.
Returns:
true if the object is an element node, else false

isAttribute

public boolean isAttribute(Object object)
Returns whether the given object is an attribute node.
Parameters:
object - The object to test.
Returns:
true if the object is an attribute node, else false

isNamespace

public boolean isNamespace(Object object)
Returns whether the given object is a namespace node.
Parameters:
object - The object to test.
Returns:
true if the object is a namespace node, else false

isComment

public boolean isComment(Object object)
Returns whether the given object is a comment node.
Parameters:
object - The object to test.
Returns:
true if the object is a comment node, else false

isText

public boolean isText(Object object)
Returns whether the given object is a text node.
Parameters:
object - The object to test.
Returns:
true if the object is a text node, else false

isProcessingInstruction

public boolean isProcessingInstruction(Object object)
Returns whether the given object is a processing-instruction node.
Parameters:
object - The object to test.
Returns:
true if the object is a processing-instruction node, else false

getCommentStringValue

public String getCommentStringValue(Object comment)
Retrieve the string-value of a comment node.
Parameters:
comment - The comment node.
Returns:
The string-value of the node.

getElementStringValue

public String getElementStringValue(Object element)
Retrieve the string-value of an element node.
Parameters:
element - The comment node.
Returns:
The string-value of the node.

getAttributeStringValue

public String getAttributeStringValue(Object attr)
Retrieve the string-value of an attribute node.
Parameters:
attr - The attribute node.
Returns:
The string-value of the node.

getNamespaceStringValue

public String getNamespaceStringValue(Object ns)
Retrieve the string-value of a namespace node.
Parameters:
attr - The namespace node.
Returns:
The string-value of the node.

getTextStringValue

public String getTextStringValue(Object txt)
Retrieve the string-value of a text node.
Parameters:
attr - The text node.
Returns:
The string-value of the node.

getNamespacePrefix

public String getNamespacePrefix(Object ns)
Retrieve the namespace prefix of a namespace node.
Parameters:
ns - The namespace node.
Returns:
The prefix associated with the node.

translateNamespacePrefixToUri

public String translateNamespacePrefixToUri(String prefix,
                                            Object element)
Translate a namespace prefix to a namespace URI, possibly considering a particular element node.

Strictly speaking, prefix-to-URI translation should occur irrespective of any element in the document. This method is provided to allow a non-conforming ease-of-use enhancement.

Parameters:
prefix - The prefix to translate.
element - The element to consider during translation.
Returns:
The namespace URI associated with the prefix.
See Also:
NamespaceContext

parseXPath

public XPath parseXPath(String xpath)
                 throws org.saxpath.SAXPathException
Returns a parsed form of the given xpath string, which will be suitable for queries on documents that use the same navigator as this one.
Parameters:
xpath - The xpath expression.
Returns:
A new XPath expression object.
See Also:
XPath

getElementById

public Object getElementById(Object contextNode,
                             String elementId)
Returns the element whose ID is given by elementId. If no such element exists, returns null. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null.
Parameters:
contextNode - a node from the document in which to look for the id
elementId - id to look for
Returns:
element whose ID is given by elementId, or null if no such element exists in the document or if the implementation does not know about attribute types

getNodeType

public short getNodeType(Object node)
Returns a number that identifies the type of node that the given object represents in this navigator.
See Also:
Pattern


Copyright © 2002 bob mcwhirter & James Strachan. All Rights Reserved. Hosted by

SourceForge Logo