Package org.jaxen.javabean
Class DocumentNavigator
- java.lang.Object
-
- org.jaxen.DefaultNavigator
-
- org.jaxen.javabean.DocumentNavigator
-
- All Implemented Interfaces:
java.io.Serializable,NamedAccessNavigator,Navigator
public class DocumentNavigator extends DefaultNavigator implements NamedAccessNavigator
Interface for navigating around a JavaBean object model.This class is not intended for direct usage, but is used by the Jaxen engine during evaluation.
- Author:
- bob mcwhirter
- See Also:
XPath, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DocumentNavigator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.IteratorgetAttributeAxisIterator(java.lang.Object contextNode)ThrowsUnsupportedAxisException.java.util.IteratorgetAttributeAxisIterator(java.lang.Object contextNode, java.lang.String localName, java.lang.String namespacePrefix, java.lang.String namespaceURI)Retrieves anIteratorover the attribute elements that match the supplied name.java.lang.StringgetAttributeName(java.lang.Object obj)Retrieve the local name of the given attribute node.java.lang.StringgetAttributeNamespaceUri(java.lang.Object obj)Retrieve the namespace URI of the given attribute node.java.lang.StringgetAttributeQName(java.lang.Object obj)Retrieve the qualified name of the given attribute node.java.lang.StringgetAttributeStringValue(java.lang.Object obj)Retrieve the string-value of an attribute node.java.util.IteratorgetChildAxisIterator(java.lang.Object contextNode)ThrowsUnsupportedAxisExceptionjava.util.IteratorgetChildAxisIterator(java.lang.Object contextNode, java.lang.String localName, java.lang.String namespacePrefix, java.lang.String namespaceURI)Retrieves anIteratorover the child elements that match the supplied name.java.lang.StringgetCommentStringValue(java.lang.Object obj)Retrieve the string-value of a comment node.java.lang.ObjectgetDocument(java.lang.String uri)Default implementation that always returns null.java.lang.ObjectgetDocumentNode(java.lang.Object contextNode)Returns the document node that contains the given context node.java.lang.StringgetElementName(java.lang.Object obj)Retrieve the local name of the given element node.java.lang.StringgetElementNamespaceUri(java.lang.Object obj)Retrieve the namespace URI of the given element node.java.lang.StringgetElementQName(java.lang.Object obj)Retrieve the qualified name of the given element node.java.lang.StringgetElementStringValue(java.lang.Object obj)Retrieve the string-value of an element node.static NavigatorgetInstance()Retrieve the singleton instance of thisDocumentNavigator.java.util.IteratorgetNamespaceAxisIterator(java.lang.Object contextNode)ThrowsUnsupportedAxisException.java.lang.StringgetNamespacePrefix(java.lang.Object obj)Retrieve the namespace prefix of a namespace node.java.lang.StringgetNamespaceStringValue(java.lang.Object obj)Retrieve the string-value of a namespace node.shortgetNodeType(java.lang.Object node)Returns a number that identifies the type of node that the given object represents in this navigator.java.util.IteratorgetParentAxisIterator(java.lang.Object contextNode)ThrowsUnsupportedAxisExceptionjava.lang.ObjectgetParentNode(java.lang.Object contextNode)Default inefficient implementation.java.lang.StringgetProcessingInstructionData(java.lang.Object obj)Retrieve the data of a processing-instruction.java.lang.StringgetProcessingInstructionTarget(java.lang.Object obj)Retrieve the target of a processing-instruction.java.lang.StringgetTextStringValue(java.lang.Object obj)Retrieve the string-value of a text node.booleanisAttribute(java.lang.Object obj)Returns whether the given object is an attribute node.booleanisComment(java.lang.Object obj)Returns whether the given object is a comment node.booleanisDocument(java.lang.Object obj)Returns whether the given object is a document node.booleanisElement(java.lang.Object obj)Returns whether the given object is an element node.booleanisNamespace(java.lang.Object obj)Returns whether the given object is a namespace node.booleanisProcessingInstruction(java.lang.Object obj)Returns whether the given object is a processing-instruction node.booleanisText(java.lang.Object obj)Returns whether the given object is a text node.protected java.lang.Stringjavacase(java.lang.String name)XPathparseXPath(java.lang.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.java.lang.StringtranslateNamespacePrefixToUri(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, 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, getPrecedingAxisIterator, getPrecedingSiblingAxisIterator, getSelfAxisIterator
-
-
-
-
Method Detail
-
getInstance
public static Navigator getInstance()
Retrieve the singleton instance of thisDocumentNavigator.
-
isElement
public boolean isElement(java.lang.Object obj)
Description copied from interface:NavigatorReturns whether the given object is an element node.
-
isComment
public boolean isComment(java.lang.Object obj)
Description copied from interface:NavigatorReturns whether the given object is a comment node.
-
isText
public boolean isText(java.lang.Object obj)
Description copied from interface:NavigatorReturns whether the given object is a text node.
-
isAttribute
public boolean isAttribute(java.lang.Object obj)
Description copied from interface:NavigatorReturns whether the given object is an attribute node.- Specified by:
isAttributein interfaceNavigator- Parameters:
obj- the object to test- Returns:
trueif the object is an attribute node, elsefalse
-
isProcessingInstruction
public boolean isProcessingInstruction(java.lang.Object obj)
Description copied from interface:NavigatorReturns whether the given object is a processing-instruction node.- Specified by:
isProcessingInstructionin interfaceNavigator- Parameters:
obj- the object to test- Returns:
trueif the object is a processing-instruction node, elsefalse
-
isDocument
public boolean isDocument(java.lang.Object obj)
Description copied from interface:NavigatorReturns whether the given object is a document node. A document node is the node that is selected by the XPath expression/.- Specified by:
isDocumentin interfaceNavigator- Parameters:
obj- the object to test- Returns:
trueif the object is a document node, elsefalse
-
isNamespace
public boolean isNamespace(java.lang.Object obj)
Description copied from interface:NavigatorReturns whether the given object is a namespace node.- Specified by:
isNamespacein interfaceNavigator- Parameters:
obj- the object to test- Returns:
trueif the object is a namespace node, elsefalse
-
getElementName
public java.lang.String getElementName(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve the local name of the given element node.- Specified by:
getElementNamein interfaceNavigator- Parameters:
obj- the context element node- Returns:
- the local name of the element node
-
getElementNamespaceUri
public java.lang.String getElementNamespaceUri(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve the namespace URI of the given element node.- Specified by:
getElementNamespaceUriin interfaceNavigator- Parameters:
obj- the context element node- Returns:
- the namespace URI of the element node
-
getElementQName
public java.lang.String getElementQName(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve the qualified name of the given element node.- Specified by:
getElementQNamein interfaceNavigator- Parameters:
obj- the context element node- Returns:
- the qualified name of the element node
-
getAttributeName
public java.lang.String getAttributeName(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve the local name of the given attribute node.- Specified by:
getAttributeNamein interfaceNavigator- Parameters:
obj- the context attribute node- Returns:
- the local name of the attribute node
-
getAttributeNamespaceUri
public java.lang.String getAttributeNamespaceUri(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve the namespace URI of the given attribute node.- Specified by:
getAttributeNamespaceUriin interfaceNavigator- Parameters:
obj- the context attribute node- Returns:
- the namespace URI of the attribute node
-
getAttributeQName
public java.lang.String getAttributeQName(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve the qualified name of the given attribute node.- Specified by:
getAttributeQNamein interfaceNavigator- Parameters:
obj- the context attribute node- Returns:
- the qualified name of the attribute node
-
getChildAxisIterator
public java.util.Iterator getChildAxisIterator(java.lang.Object contextNode)
Description copied from class:DefaultNavigatorThrowsUnsupportedAxisException- Specified by:
getChildAxisIteratorin interfaceNavigator- Overrides:
getChildAxisIteratorin classDefaultNavigator- Parameters:
contextNode- the original context node- 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 anIteratorover the child elements that match the supplied name.- Specified by:
getChildAxisIteratorin interfaceNamedAccessNavigator- Parameters:
contextNode- the origin context nodelocalName- the local name of the children to return, always presentnamespacePrefix- the prefix of the namespace of the children to returnnamespaceURI- the namespace URI of the children to return- Returns:
- an Iterator that traverses the named children, or null if none
-
getParentAxisIterator
public java.util.Iterator getParentAxisIterator(java.lang.Object contextNode)
Description copied from class:DefaultNavigatorThrowsUnsupportedAxisException- Specified by:
getParentAxisIteratorin interfaceNavigator- Overrides:
getParentAxisIteratorin classDefaultNavigator- Parameters:
contextNode- the original context node- Returns:
- never returns
-
getAttributeAxisIterator
public java.util.Iterator getAttributeAxisIterator(java.lang.Object contextNode)
Description copied from class:DefaultNavigatorThrowsUnsupportedAxisException. Subclasses that support the attribute axis must override this method.- Specified by:
getAttributeAxisIteratorin interfaceNavigator- Overrides:
getAttributeAxisIteratorin classDefaultNavigator- Parameters:
contextNode- the original context node- 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 anIteratorover the attribute elements that match the supplied name.- Specified by:
getAttributeAxisIteratorin interfaceNamedAccessNavigator- Parameters:
contextNode- the origin context nodelocalName- the local name of the attributes to return, always presentnamespacePrefix- the prefix of the namespace of the attributes to returnnamespaceURI- the namespace URI of the attributes to return- Returns:
- an Iterator that traverses the named attributes, not null
-
getNamespaceAxisIterator
public java.util.Iterator getNamespaceAxisIterator(java.lang.Object contextNode)
Description copied from class:DefaultNavigatorThrowsUnsupportedAxisException. Subclasses that support the namespace axis must override this method.- Specified by:
getNamespaceAxisIteratorin interfaceNavigator- Overrides:
getNamespaceAxisIteratorin classDefaultNavigator- Parameters:
contextNode- the original context node- Returns:
- never returns
-
getDocumentNode
public java.lang.Object getDocumentNode(java.lang.Object contextNode)
Description copied from interface:NavigatorReturns the document node that contains the given context node.- Specified by:
getDocumentNodein interfaceNavigator- Overrides:
getDocumentNodein classDefaultNavigator- Parameters:
contextNode- the context node- Returns:
- the document of the context node
- See Also:
Navigator.isDocument(Object)
-
getParentNode
public java.lang.Object getParentNode(java.lang.Object contextNode)
Description copied from class:DefaultNavigatorDefault inefficient implementation. Subclasses should override this method.- Specified by:
getParentNodein interfaceNavigator- Overrides:
getParentNodein classDefaultNavigator- Parameters:
contextNode- the node whose parent to return- Returns:
- the parent node
- See Also:
Navigator.isDocument(java.lang.Object),Navigator.isElement(java.lang.Object)
-
getTextStringValue
public java.lang.String getTextStringValue(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve 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:
getTextStringValuein interfaceNavigator- Parameters:
obj- the text node- Returns:
- the string-value of the node
-
getElementStringValue
public java.lang.String getElementStringValue(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve 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:
getElementStringValuein interfaceNavigator- Parameters:
obj- the comment node.- Returns:
- the string-value of the node.
-
getAttributeStringValue
public java.lang.String getAttributeStringValue(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve 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:
getAttributeStringValuein interfaceNavigator- Parameters:
obj- the attribute node- Returns:
- the string-value of the node
-
getNamespaceStringValue
public java.lang.String getNamespaceStringValue(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve 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:
getNamespaceStringValuein interfaceNavigator- 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:NavigatorRetrieve the namespace prefix of a namespace node.- Specified by:
getNamespacePrefixin interfaceNavigator- Parameters:
obj- the namespace node- Returns:
- the prefix associated with the node
-
getCommentStringValue
public java.lang.String getCommentStringValue(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve 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:
getCommentStringValuein interfaceNavigator- 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:NavigatorTranslate 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:
translateNamespacePrefixToUriin interfaceNavigator- Overrides:
translateNamespacePrefixToUriin classDefaultNavigator- Parameters:
prefix- the prefix to translatecontext- the element to consider during translation- Returns:
- the namespace URI associated with the prefix
- See Also:
NamespaceContext
-
getNodeType
public short getNodeType(java.lang.Object node)
Description copied from interface:NavigatorReturns a number that identifies the type of node that the given object represents in this navigator.- Specified by:
getNodeTypein interfaceNavigator- Overrides:
getNodeTypein classDefaultNavigator- Parameters:
node- ????- Returns:
- ????
- See Also:
Pattern
-
getDocument
public java.lang.Object getDocument(java.lang.String uri) throws FunctionCallExceptionDescription copied from class:DefaultNavigatorDefault implementation that always returns null. Override in subclass if the subclass can load documents.- Specified by:
getDocumentin interfaceNavigator- Overrides:
getDocumentin classDefaultNavigator- 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 java.lang.String getProcessingInstructionTarget(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve the target of a processing-instruction.- Specified by:
getProcessingInstructionTargetin interfaceNavigator- Overrides:
getProcessingInstructionTargetin classDefaultNavigator- Parameters:
obj- the context processing-instruction node- Returns:
- the target of the processing-instruction node
-
getProcessingInstructionData
public java.lang.String getProcessingInstructionData(java.lang.Object obj)
Description copied from interface:NavigatorRetrieve the data of a processing-instruction.- Specified by:
getProcessingInstructionDatain interfaceNavigator- Overrides:
getProcessingInstructionDatain classDefaultNavigator- Parameters:
obj- the context processing-instruction node- Returns:
- the data of the processing-instruction node
-
parseXPath
public XPath parseXPath(java.lang.String xpath) throws SAXPathException
Description copied from interface:NavigatorReturns a parsed form of the given XPath string, which will be suitable for queries on documents that use the same navigator as this one.- Specified by:
parseXPathin interfaceNavigator- 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
-
javacase
protected java.lang.String javacase(java.lang.String name)
-
-