org.jaxen.jdom
Class DocumentNavigator

java.lang.Object
  extended byorg.jaxen.DefaultNavigator
      extended byorg.jaxen.jdom.DocumentNavigator
All Implemented Interfaces:
NamedAccessNavigator, Navigator, java.io.Serializable

public class DocumentNavigator
extends DefaultNavigator
implements NamedAccessNavigator

Interface for navigating around the JDOM object model.

This class is not intended for direct usage, but is used by the Jaxen engine during evaluation.

Author:
bob mcwhirter, Stephen Colebourne
See Also:
XPath, Serialized Form

Constructor Summary
DocumentNavigator()
           
 
Method Summary
 java.util.Iterator getAttributeAxisIterator(java.lang.Object contextNode)
          Retrieve an Iterator matching the attribute XPath axis.
 java.util.Iterator getAttributeAxisIterator(java.lang.Object contextNode, java.lang.String localName, java.lang.String namespacePrefix, java.lang.String namespaceURI)
          Retrieves an Iterator over the attribute elements that match the supplied name.
 java.lang.String getAttributeName(java.lang.Object obj)
          Retrieve the name of the given attribute node.
 java.lang.String getAttributeNamespaceUri(java.lang.Object obj)
          Retrieve the namespace URI of the given attribute node.
 java.lang.String getAttributeQName(java.lang.Object obj)
          Retrieve the QName of the given attribute node.
 java.lang.String getAttributeStringValue(java.lang.Object obj)
          Retrieve the string-value of an attribute node.
 java.util.Iterator getChildAxisIterator(java.lang.Object contextNode)
          Retrieve an Iterator matching the child XPath axis.
 java.util.Iterator getChildAxisIterator(java.lang.Object contextNode, java.lang.String localName, java.lang.String namespacePrefix, java.lang.String namespaceURI)
          Retrieves an Iterator over the child elements that match the supplied name.
 java.lang.String getCommentStringValue(java.lang.Object obj)
          Retrieve the string-value of a comment node.
 java.lang.Object getDocument(java.lang.String url)
          Loads a document from the given URI
 java.lang.Object getDocumentNode(java.lang.Object contextNode)
          Returns the document node that contains the given context node.
 java.lang.String getElementName(java.lang.Object obj)
          Retrieve the name of the given element node.
 java.lang.String getElementNamespaceUri(java.lang.Object obj)
          Retrieve the namespace URI of the given element node.
 java.lang.String getElementQName(java.lang.Object obj)
          Retrieve the QName of the given element node.
 java.lang.String getElementStringValue(java.lang.Object obj)
          Retrieve the string-value of an element node.
static Navigator getInstance()
           
 java.util.Iterator getNamespaceAxisIterator(java.lang.Object contextNode)
          Retrieve an Iterator matching the namespace XPath axis.
 java.lang.String getNamespacePrefix(java.lang.Object obj)
          Retrieve the namespace prefix of a namespace node.
 java.lang.String getNamespaceStringValue(java.lang.Object obj)
          Retrieve the string-value of a namespace node.
 java.util.Iterator getParentAxisIterator(java.lang.Object contextNode)
          Retrieve an Iterator matching the parent XPath axis.
 java.lang.String getProcessingInstructionData(java.lang.Object obj)
          Retrieve the data of a processing-instruction.
 java.lang.String getProcessingInstructionTarget(java.lang.Object obj)
          Retrieve the target of a processing-instruction.
 java.lang.String getTextStringValue(java.lang.Object obj)
          Retrieve the string-value of a text node.
 boolean isAttribute(java.lang.Object obj)
          Returns whether the given object is an attribute node.
 boolean isComment(java.lang.Object obj)
          Returns whether the given object is a comment node.
 boolean isDocument(java.lang.Object obj)
          Returns whether the given object is a document node.
 boolean isElement(java.lang.Object obj)
          Returns whether the given object is an element node.
 boolean isNamespace(java.lang.Object obj)
          Returns whether the given object is a namespace node.
 boolean isProcessingInstruction(java.lang.Object obj)
          Returns whether the given object is a processing-instruction node.
 boolean isText(java.lang.Object obj)
          Returns whether the given object is a text node.
 XPath parseXPath(java.lang.String xpath)
          Returns a parsed form of the given XPath string, which will be suitable for queries on JDOM documents.
 java.lang.String translateNamespacePrefixToUri(java.lang.String prefix, java.lang.Object context)
          Translate a namespace prefix to a namespace URI, possibly considering a particular element node.
 
Methods inherited from class org.jaxen.DefaultNavigator
getAncestorAxisIterator, getAncestorOrSelfAxisIterator, getDescendantAxisIterator, getDescendantOrSelfAxisIterator, getElementById, getFollowingAxisIterator, getFollowingSiblingAxisIterator, getNodeType, getParentNode, getPrecedingAxisIterator, getPrecedingSiblingAxisIterator, getSelfAxisIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jaxen.Navigator
getAncestorAxisIterator, getAncestorOrSelfAxisIterator, getDescendantAxisIterator, getDescendantOrSelfAxisIterator, getElementById, getFollowingAxisIterator, getFollowingSiblingAxisIterator, getNodeType, getParentNode, getPrecedingAxisIterator, getPrecedingSiblingAxisIterator, getSelfAxisIterator
 

Constructor Detail

DocumentNavigator

public DocumentNavigator()
Method Detail

getInstance

public static Navigator getInstance()

isElement

public boolean isElement(java.lang.Object obj)
Description copied from interface: Navigator
Returns whether the given object is an element node.

Specified by:
isElement in interface Navigator
Parameters:
obj - the object to test
Returns:
true if the object is an element node, else false

isComment

public boolean isComment(java.lang.Object obj)
Description copied from interface: Navigator
Returns whether the given object is a comment node.

Specified by:
isComment in interface Navigator
Parameters:
obj - the object to test
Returns:
true if the object is a comment node, else false

isText

public boolean isText(java.lang.Object obj)
Description copied from interface: Navigator
Returns whether the given object is a text node.

Specified by:
isText in interface Navigator
Parameters:
obj - the object to test
Returns:
true if the object is a text node, else false

isAttribute

public boolean isAttribute(java.lang.Object obj)
Description copied from interface: Navigator
Returns whether the given object is an attribute node.

Specified by:
isAttribute in interface Navigator
Parameters:
obj - the object to test
Returns:
true if the object is an attribute node, else false

isProcessingInstruction

public boolean isProcessingInstruction(java.lang.Object obj)
Description copied from interface: Navigator
Returns whether the given object is a processing-instruction node.

Specified by:
isProcessingInstruction in interface Navigator
Parameters:
obj - the object to test
Returns:
true if the object is a processing-instruction node, else false

isDocument

public boolean isDocument(java.lang.Object obj)
Description copied from interface: Navigator
Returns whether the given object is a document node. A document node is the node that is selected by the xpath expression /.

Specified by:
isDocument in interface Navigator
Parameters:
obj - the object to test
Returns:
true if the object is a document node, else false

isNamespace

public boolean isNamespace(java.lang.Object obj)
Description copied from interface: Navigator
Returns whether the given object is a namespace node.

Specified by:
isNamespace in interface Navigator
Parameters:
obj - the object to test
Returns:
true if the object is a namespace node, else false

getElementName

public java.lang.String getElementName(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the name of the given element node.

Specified by:
getElementName in interface Navigator
Parameters:
obj - the context element node
Returns:
the name of the element node

getElementNamespaceUri

public java.lang.String getElementNamespaceUri(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the namespace URI of the given element node.

Specified by:
getElementNamespaceUri in interface Navigator
Parameters:
obj - the context element node
Returns:
the namespace URI of the element node

getAttributeName

public java.lang.String getAttributeName(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the name of the given attribute node.

Specified by:
getAttributeName in interface Navigator
Parameters:
obj - the context attribute node
Returns:
the name of the attribute node

getAttributeNamespaceUri

public java.lang.String getAttributeNamespaceUri(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the namespace URI of the given attribute node.

Specified by:
getAttributeNamespaceUri in interface Navigator
Parameters:
obj - the context attribute node
Returns:
the namespace URI of the attribute node

getChildAxisIterator

public java.util.Iterator getChildAxisIterator(java.lang.Object contextNode)
Description copied from interface: Navigator
Retrieve an Iterator matching the child XPath axis.

Specified by:
getChildAxisIterator in interface Navigator
Overrides:
getChildAxisIterator in class DefaultNavigator
Parameters:
contextNode -
Returns:
never returns

getChildAxisIterator

public java.util.Iterator getChildAxisIterator(java.lang.Object contextNode,
                                               java.lang.String localName,
                                               java.lang.String namespacePrefix,
                                               java.lang.String namespaceURI)
Retrieves an Iterator over the child elements that match the supplied name.

Specified by:
getChildAxisIterator in interface NamedAccessNavigator
Parameters:
contextNode - the origin context node
localName - the local name of the children to return, always present
namespacePrefix - the prefix of the namespace of the children to return
namespaceURI - the uri of the namespace of the children to return
Returns:
an Iterator that traverses the named children, or null if none

getNamespaceAxisIterator

public java.util.Iterator getNamespaceAxisIterator(java.lang.Object contextNode)
Description copied from interface: Navigator
Retrieve an Iterator matching the namespace XPath axis.

Specified by:
getNamespaceAxisIterator in interface Navigator
Overrides:
getNamespaceAxisIterator in class DefaultNavigator
Parameters:
contextNode -
Returns:
never returns

getParentAxisIterator

public java.util.Iterator getParentAxisIterator(java.lang.Object contextNode)
Description copied from interface: Navigator
Retrieve an Iterator matching the parent XPath axis.

Specified by:
getParentAxisIterator in interface Navigator
Overrides:
getParentAxisIterator in class DefaultNavigator
Parameters:
contextNode -
Returns:
never returns

getAttributeAxisIterator

public java.util.Iterator getAttributeAxisIterator(java.lang.Object contextNode)
Description copied from interface: Navigator
Retrieve an Iterator matching the attribute XPath axis.

Specified by:
getAttributeAxisIterator in interface Navigator
Overrides:
getAttributeAxisIterator in class DefaultNavigator
Parameters:
contextNode -
Returns:
never returns

getAttributeAxisIterator

public java.util.Iterator getAttributeAxisIterator(java.lang.Object contextNode,
                                                   java.lang.String localName,
                                                   java.lang.String namespacePrefix,
                                                   java.lang.String namespaceURI)
Retrieves an Iterator over the attribute elements that match the supplied name.

Specified by:
getAttributeAxisIterator in interface NamedAccessNavigator
Parameters:
contextNode - the origin context node
localName - the local name of the attributes to return, always present
namespacePrefix - the prefix of the namespace of the attributes to return
namespaceURI - the URI of the namespace of the attributes to return
Returns:
an Iterator that traverses the named attributes, not null

parseXPath

public XPath parseXPath(java.lang.String xpath)
                 throws SAXPathException
Returns a parsed form of the given XPath string, which will be suitable for queries on JDOM documents.

Specified by:
parseXPath in interface Navigator
Parameters:
xpath - the XPath expression
Returns:
a new XPath expression object
Throws:
SAXPathException - if the string is not a syntactically correct XPath expression
See Also:
XPath

getDocumentNode

public java.lang.Object getDocumentNode(java.lang.Object contextNode)
Description copied from interface: Navigator
Returns the document node that contains the given context node.

Specified by:
getDocumentNode in interface Navigator
Overrides:
getDocumentNode in class DefaultNavigator

getElementQName

public java.lang.String getElementQName(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the QName of the given element node.

Specified by:
getElementQName in interface Navigator
Parameters:
obj - the context element node
Returns:
the QName of the element node

getAttributeQName

public java.lang.String getAttributeQName(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the QName of the given attribute node.

Specified by:
getAttributeQName in interface Navigator
Parameters:
obj - the context attribute node
Returns:
the qualified name of the attribute node

getNamespaceStringValue

public java.lang.String getNamespaceStringValue(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the string-value of a namespace node. This is generally the namespace URI. This may be the empty string but must not be null.

Specified by:
getNamespaceStringValue in interface Navigator
Parameters:
obj - the namespace node
Returns:
the string-value of the node

getNamespacePrefix

public java.lang.String getNamespacePrefix(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the namespace prefix of a namespace node.

Specified by:
getNamespacePrefix in interface Navigator
Parameters:
obj - the namespace node
Returns:
the prefix associated with the node

getTextStringValue

public java.lang.String getTextStringValue(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the string-value of a text node. This must not be null and should not be the empty string. The XPath data model does not allow empty text nodes.

Specified by:
getTextStringValue in interface Navigator
Parameters:
obj - the text node
Returns:
the string-value of the node

getAttributeStringValue

public java.lang.String getAttributeStringValue(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the string-value of an attribute node. This should be the XML 1.0 normalized attribute value. This may be the empty string but must not be null.

Specified by:
getAttributeStringValue in interface Navigator
Parameters:
obj - the attribute node
Returns:
the string-value of the node

getElementStringValue

public java.lang.String getElementStringValue(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the string-value of an element node. This may be the empty string if the element is empty, but must not be null.

Specified by:
getElementStringValue in interface Navigator
Parameters:
obj - the comment node.
Returns:
the string-value of the node.

getProcessingInstructionTarget

public java.lang.String getProcessingInstructionTarget(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the target of a processing-instruction.

Specified by:
getProcessingInstructionTarget in interface Navigator
Overrides:
getProcessingInstructionTarget in class DefaultNavigator

getProcessingInstructionData

public java.lang.String getProcessingInstructionData(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the data of a processing-instruction.

Specified by:
getProcessingInstructionData in interface Navigator
Overrides:
getProcessingInstructionData in class DefaultNavigator

getCommentStringValue

public java.lang.String getCommentStringValue(java.lang.Object obj)
Description copied from interface: Navigator
Retrieve the string-value of a comment node. This may be the empty string if the comment is empty, but must not be null.

Specified by:
getCommentStringValue in interface Navigator
Parameters:
obj - the comment node
Returns:
the string-value of the node

translateNamespacePrefixToUri

public java.lang.String translateNamespacePrefixToUri(java.lang.String prefix,
                                                      java.lang.Object context)
Description copied from interface: Navigator
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.

Specified by:
translateNamespacePrefixToUri in interface Navigator
Overrides:
translateNamespacePrefixToUri in class DefaultNavigator

getDocument

public java.lang.Object getDocument(java.lang.String url)
                             throws FunctionCallException
Description copied from interface: Navigator
Loads a document from the given URI

Specified by:
getDocument in interface Navigator
Overrides:
getDocument in class DefaultNavigator
Parameters:
url - the URL of the document to load
Returns:
null
Throws:
FunctionCallException - if an error occurs while loading the URL; e.g. an I/O error or the document is malformed


Copyright © 2001-2005 Codehaus. All Rights Reserved.