Class DocumentNavigator

java.lang.Object
org.jaxen.DefaultNavigator
org.jaxen.dom4j.DocumentNavigator
All Implemented Interfaces:
Serializable, NamedAccessNavigator, Navigator

public class DocumentNavigator extends DefaultNavigator implements NamedAccessNavigator
Interface for navigating around the DOM4J 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:
  • Constructor Details

    • DocumentNavigator

      public DocumentNavigator()
  • Method Details

    • getInstance

      public static Navigator getInstance()
      Retrieve the singleton instance of this DocumentNavigator.
    • isElement

      public boolean isElement(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(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(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(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(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(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(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 String getElementName(Object obj)
      Description copied from interface: Navigator
      Retrieve the local name of the given element node.
      Specified by:
      getElementName in interface Navigator
      Parameters:
      obj - the context element node
      Returns:
      the local name of the element node
    • getElementNamespaceUri

      public String getElementNamespaceUri(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
    • getElementQName

      public String getElementQName(Object obj)
      Description copied from interface: Navigator
      Retrieve the qualified name of the given element node.
      Specified by:
      getElementQName in interface Navigator
      Parameters:
      obj - the context element node
      Returns:
      the qualified name of the element node
    • getAttributeName

      public String getAttributeName(Object obj)
      Description copied from interface: Navigator
      Retrieve the local name of the given attribute node.
      Specified by:
      getAttributeName in interface Navigator
      Parameters:
      obj - the context attribute node
      Returns:
      the local name of the attribute node
    • getAttributeNamespaceUri

      public String getAttributeNamespaceUri(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
    • getAttributeQName

      public String getAttributeQName(Object obj)
      Description copied from interface: Navigator
      Retrieve the qualified name 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
    • getChildAxisIterator

      public Iterator getChildAxisIterator(Object contextNode)
      Description copied from class: DefaultNavigator
      Throws UnsupportedAxisException. Subclasses should override this method.
      Specified by:
      getChildAxisIterator in interface Navigator
      Overrides:
      getChildAxisIterator in class DefaultNavigator
      Parameters:
      contextNode - the node to start from
      Returns:
      never returns
    • getChildAxisIterator

      public Iterator getChildAxisIterator(Object contextNode, String localName, String namespacePrefix, 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
    • getParentAxisIterator

      public Iterator getParentAxisIterator(Object contextNode)
      Description copied from class: DefaultNavigator
      Throws UnsupportedAxisException. Subclasses should override this method.
      Specified by:
      getParentAxisIterator in interface Navigator
      Overrides:
      getParentAxisIterator in class DefaultNavigator
      Parameters:
      contextNode - the node to start from
      Returns:
      never returns
    • getAttributeAxisIterator

      public Iterator getAttributeAxisIterator(Object contextNode)
      Description copied from class: DefaultNavigator
      Retrieve an Iterator matching the attribute XPath axis.
      Specified by:
      getAttributeAxisIterator in interface Navigator
      Overrides:
      getAttributeAxisIterator in class DefaultNavigator
      Parameters:
      contextNode - the original context node
      Returns:
      an Iterator capable of traversing the axis, not null
    • getAttributeAxisIterator

      public Iterator getAttributeAxisIterator(Object contextNode, String localName, String namespacePrefix, 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
    • getNamespaceAxisIterator

      public Iterator getNamespaceAxisIterator(Object contextNode)
      Description copied from class: DefaultNavigator
      Throws UnsupportedAxisException. Subclasses that support the namespace axis must override this method.
      Specified by:
      getNamespaceAxisIterator in interface Navigator
      Overrides:
      getNamespaceAxisIterator in class DefaultNavigator
      Parameters:
      contextNode - the node to start from
      Returns:
      never returns
    • getDocumentNode

      public Object getDocumentNode(Object contextNode)
      Description copied from class: DefaultNavigator
      Returns null.
      Specified by:
      getDocumentNode in interface Navigator
      Overrides:
      getDocumentNode in class DefaultNavigator
      Parameters:
      contextNode - the node to start from
      Returns:
      null
      See Also:
    • parseXPath

      public XPath parseXPath(String xpath) throws SAXPathException
      Returns a parsed form of the given XPath string, which will be suitable for queries on DOM4J 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:
    • getParentNode

      public Object getParentNode(Object contextNode)
      Description copied from class: DefaultNavigator
      Default inefficient implementation. Subclasses should override this method.
      Specified by:
      getParentNode in interface Navigator
      Overrides:
      getParentNode in class DefaultNavigator
      Parameters:
      contextNode - the node whose parent to return
      Returns:
      the parent node
      See Also:
    • getTextStringValue

      public String getTextStringValue(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
    • getElementStringValue

      public String getElementStringValue(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.
    • getAttributeStringValue

      public String getAttributeStringValue(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
    • getNamespaceStringValue

      public String getNamespaceStringValue(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 String getNamespacePrefix(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
    • getCommentStringValue

      public String getCommentStringValue(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 String translateNamespacePrefixToUri(String prefix, Object context)
      Description copied from class: DefaultNavigator
      Returns null.
      Specified by:
      translateNamespacePrefixToUri in interface Navigator
      Overrides:
      translateNamespacePrefixToUri in class DefaultNavigator
      Parameters:
      prefix - the prefix to translate
      context - the node to start from
      Returns:
      null
      See Also:
    • getNodeType

      public short getNodeType(Object node)
      Description copied from class: DefaultNavigator
      Returns a number that identifies the type of node that the given object represents in this navigator.
      Specified by:
      getNodeType in interface Navigator
      Overrides:
      getNodeType in class DefaultNavigator
      Parameters:
      node - ????
      Returns:
      ????
      See Also:
    • getDocument

      public Object getDocument(String uri) throws FunctionCallException
      Description copied from class: DefaultNavigator
      Default implementation that always returns null. Override in subclass if the subclass can load documents.
      Specified by:
      getDocument in interface Navigator
      Overrides:
      getDocument in class DefaultNavigator
      Parameters:
      uri - 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
    • getProcessingInstructionTarget

      public String getProcessingInstructionTarget(Object obj)
      Description copied from class: DefaultNavigator
      Returns null.
      Specified by:
      getProcessingInstructionTarget in interface Navigator
      Overrides:
      getProcessingInstructionTarget in class DefaultNavigator
      Parameters:
      obj - the node to start from
      Returns:
      null
    • getProcessingInstructionData

      public String getProcessingInstructionData(Object obj)
      Description copied from class: DefaultNavigator
      Returns null.
      Specified by:
      getProcessingInstructionData in interface Navigator
      Overrides:
      getProcessingInstructionData in class DefaultNavigator
      Parameters:
      obj - the node to start from
      Returns:
      null
    • getSAXReader

      public org.dom4j.io.SAXReader getSAXReader()
    • setSAXReader

      public void setSAXReader(org.dom4j.io.SAXReader reader)