Package org.apache.axiom.om.xpath
Class DocumentNavigator
- java.lang.Object
-
- org.jaxen.DefaultNavigator
-
- org.apache.axiom.om.xpath.DocumentNavigator
-
- All Implemented Interfaces:
Serializable
,org.jaxen.Navigator
public class DocumentNavigator extends org.jaxen.DefaultNavigator
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DocumentNavigator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<?>
getAncestorAxisIterator(Object contextNode)
Retrieves anIterator
matching theancestor
XPath axis.Iterator<?>
getAncestorOrSelfAxisIterator(Object contextNode)
Retrieves anIterator
matching theancestor-or-self
XPath axis.Iterator<?>
getAttributeAxisIterator(Object contextNode)
Retrieves anIterator
matching theattribute
XPath axis.String
getAttributeName(Object object)
Retrieves the name of the given attribute node.String
getAttributeNamespaceUri(Object object)
Retrieves the namespace URI of the given attribute node.String
getAttributeQName(Object object)
Retrieves the QName of the given attribute node.String
getAttributeStringValue(Object object)
Retrieves the string-value of an attribute node.Iterator<?>
getChildAxisIterator(Object contextNode)
Retrieves anIterator
matching thechild
XPath axis.String
getCommentStringValue(Object object)
Retrieves the string-value of a comment node.Iterator<?>
getDescendantAxisIterator(Object object)
Iterator<?>
getDescendantOrSelfAxisIterator(Object contextNode)
Retrieves anIterator
matching thedescendant-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 object)
Retrieves the name of the given element node.String
getElementNamespaceUri(Object object)
Retrieves the namespace URI of the given element node.String
getElementQName(Object object)
Retrieves the QName of the given element node.String
getElementStringValue(Object object)
Retrieves the string-value of an element node.Iterator<?>
getFollowingAxisIterator(Object contextNode)
Retrieves anIterator
matching thefollowing
XPath axis.Iterator<?>
getFollowingSiblingAxisIterator(Object contextNode)
Retrieves anIterator
matching thefollowing-sibling
XPath axis.Iterator<?>
getNamespaceAxisIterator(Object contextNode)
Retrieves anIterator
matching thenamespace
XPath axis.String
getNamespacePrefix(Object object)
Retrieves the namespace prefix of a namespace node.String
getNamespaceStringValue(Object object)
Retrieves 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)
Retrieves anIterator
matching theparent
XPath axis.Object
getParentNode(Object contextNode)
Returns the parent of the given context node.Iterator<?>
getPrecedingAxisIterator(Object contextNode)
Retrieves anIterator
matching thepreceding
XPath axis.Iterator<?>
getPrecedingSiblingAxisIterator(Object contextNode)
Retrieves anIterator
matching thepreceding-sibling
XPath axis.String
getProcessingInstructionData(Object object)
Retrieves the data of a processing-instruction.String
getProcessingInstructionTarget(Object object)
Retrieves the target of a processing-instruction.Iterator<?>
getSelfAxisIterator(Object contextNode)
Retrieves anIterator
matching theself
xpath axis.String
getTextStringValue(Object object)
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.org.jaxen.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)
Translates a namespace prefix to a namespace URI, possibly considering a particular element node.
-
-
-
Method Detail
-
parseXPath
public org.jaxen.XPath parseXPath(String xpath) throws org.jaxen.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:
- Returns a new XPath expression object.
- Throws:
org.jaxen.saxpath.SAXPathException
- if the string is not a syntactically correct XPath expression- See Also:
XPath
-
getElementNamespaceUri
public String getElementNamespaceUri(Object object)
Retrieves the namespace URI of the given element node.- Parameters:
object
- the context element node- Returns:
- Returns the namespace URI of the element node.
-
getElementName
public String getElementName(Object object)
Retrieves the name of the given element node.- Parameters:
object
- the context element node- Returns:
- Returns the name of the element node.
-
getElementQName
public String getElementQName(Object object)
Retrieves the QName of the given element node.- Parameters:
object
- the context element node- Returns:
- Returns the QName of the element node.
-
getAttributeNamespaceUri
public String getAttributeNamespaceUri(Object object)
Retrieves the namespace URI of the given attribute node.- Parameters:
object
- the context attribute node- Returns:
- Returns the namespace URI of the attribute node.
-
getAttributeName
public String getAttributeName(Object object)
Retrieves the name of the given attribute node.- Parameters:
object
- the context attribute node- Returns:
- Returns the name of the attribute node.
-
getAttributeQName
public String getAttributeQName(Object object)
Retrieves the QName of the given attribute node.- Parameters:
object
- the context attribute node- Returns:
- Returns the qualified name of the attribute 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:
- Returns
true
if the object is a document node, elsefalse
.
-
isElement
public boolean isElement(Object object)
Returns whether the given object is an element node.- Parameters:
object
- the object to test- Returns:
- Returns
true
if the object is an element node, elsefalse
.
-
isAttribute
public boolean isAttribute(Object object)
Returns whether the given object is an attribute node.- Parameters:
object
- the object to test- Returns:
- Returns
true
if the object is an attribute node, elsefalse
.
-
isNamespace
public boolean isNamespace(Object object)
Returns whether the given object is a namespace node.- Parameters:
object
- the object to test- Returns:
- Returns
true
if the object is a namespace node, elsefalse
.
-
isComment
public boolean isComment(Object object)
Returns whether the given object is a comment node.- Parameters:
object
- the object to test- Returns:
- Returns
true
if the object is a comment node, elsefalse
.
-
isText
public boolean isText(Object object)
Returns whether the given object is a text node.- Parameters:
object
- the object to test- Returns:
- Returns
true
if the object is a text node, elsefalse
.
-
isProcessingInstruction
public boolean isProcessingInstruction(Object object)
Returns whether the given object is a processing-instruction node.- Parameters:
object
- the object to test- Returns:
- Returns
true
if the object is a processing-instruction node, elsefalse
.
-
getCommentStringValue
public String getCommentStringValue(Object object)
Retrieves the string-value of a comment node. This may be the empty string if the comment is empty, but must not be null.- Parameters:
object
- the comment node- Returns:
- Returns the string-value of the node.
-
getElementStringValue
public String getElementStringValue(Object object)
Retrieves the string-value of an element node. This may be the empty string if the element is empty, but must not be null.- Parameters:
object
- the comment node.- Returns:
- Returns the string-value of the node.
-
getAttributeStringValue
public String getAttributeStringValue(Object object)
Retrieves 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.- Parameters:
object
- the attribute node- Returns:
- Returns the string-value of the node.
-
getNamespaceStringValue
public String getNamespaceStringValue(Object object)
Retrieves the string-value of a namespace node. This is generally the namespace URI. This may be the empty string but must not be null.- Parameters:
object
- the namespace node- Returns:
- Returns the string-value of the node.
-
getTextStringValue
public String getTextStringValue(Object object)
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.- Parameters:
object
- the text node- Returns:
- Returns the string-value of the node.
-
getNamespacePrefix
public String getNamespacePrefix(Object object)
Retrieves the namespace prefix of a namespace node.- Parameters:
object
- the namespace node- Returns:
- Returns the prefix associated with the node.
-
getChildAxisIterator
public Iterator<?> getChildAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching thechild
XPath axis.- Specified by:
getChildAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getChildAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the child axis are not supported by this object model
-
getDescendantAxisIterator
public Iterator<?> getDescendantAxisIterator(Object object) throws org.jaxen.UnsupportedAxisException
- Specified by:
getDescendantAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getDescendantAxisIterator
in classorg.jaxen.DefaultNavigator
- Throws:
org.jaxen.UnsupportedAxisException
-
getAttributeAxisIterator
public Iterator<?> getAttributeAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching theattribute
XPath axis.- Specified by:
getAttributeAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getAttributeAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the attribute axis are not supported by this object model
-
getNamespaceAxisIterator
public Iterator<?> getNamespaceAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching thenamespace
XPath axis.- Specified by:
getNamespaceAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getNamespaceAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the namespace axis are not supported by this object model
-
getSelfAxisIterator
public Iterator<?> getSelfAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching theself
xpath axis.- Specified by:
getSelfAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getSelfAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the self axis are not supported by this object model
-
getDescendantOrSelfAxisIterator
public Iterator<?> getDescendantOrSelfAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching thedescendant-or-self
XPath axis.- Specified by:
getDescendantOrSelfAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getDescendantOrSelfAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the descendant-or-self axis are not supported by this object model
-
getAncestorOrSelfAxisIterator
public Iterator<?> getAncestorOrSelfAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching theancestor-or-self
XPath axis.- Specified by:
getAncestorOrSelfAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getAncestorOrSelfAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the ancestor-or-self axis are not supported by this object model
-
getParentAxisIterator
public Iterator<?> getParentAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching theparent
XPath axis.- Specified by:
getParentAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getParentAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the parent axis are not supported by this object model
-
getAncestorAxisIterator
public Iterator<?> getAncestorAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching theancestor
XPath axis.- Specified by:
getAncestorAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getAncestorAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the ancestor axis are not supported by this object model
-
getFollowingSiblingAxisIterator
public Iterator<?> getFollowingSiblingAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching thefollowing-sibling
XPath axis.- Specified by:
getFollowingSiblingAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getFollowingSiblingAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the following-sibling axis are not supported by this object model
-
getPrecedingSiblingAxisIterator
public Iterator<?> getPrecedingSiblingAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching thepreceding-sibling
XPath axis.- Specified by:
getPrecedingSiblingAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getPrecedingSiblingAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the preceding-sibling axis are not supported by this object model
-
getFollowingAxisIterator
public Iterator<?> getFollowingAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching thefollowing
XPath axis.- Specified by:
getFollowingAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getFollowingAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the following axis are not supported by this object model
-
getPrecedingAxisIterator
public Iterator<?> getPrecedingAxisIterator(Object contextNode) throws org.jaxen.UnsupportedAxisException
Retrieves anIterator
matching thepreceding
XPath axis.- Specified by:
getPrecedingAxisIterator
in interfaceorg.jaxen.Navigator
- Overrides:
getPrecedingAxisIterator
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the original context node- Returns:
- Returns an Iterator capable of traversing the axis, not null.
- Throws:
org.jaxen.UnsupportedAxisException
- if the semantics of the preceding axis are not supported by this object model
-
getDocument
public Object getDocument(String uri) throws org.jaxen.FunctionCallException
Loads a document from the given URI.- Specified by:
getDocument
in interfaceorg.jaxen.Navigator
- Overrides:
getDocument
in classorg.jaxen.DefaultNavigator
- Parameters:
uri
- the URI of the document to load- Returns:
- Returns the document.
- Throws:
org.jaxen.FunctionCallException
- if the document could not be loaded
-
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.- Specified by:
getElementById
in interfaceorg.jaxen.Navigator
- Overrides:
getElementById
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- a node from the document in which to look for the idelementId
- id to look for- Returns:
- 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.
-
getDocumentNode
public Object getDocumentNode(Object contextNode)
Returns the document node that contains the given context node.- Specified by:
getDocumentNode
in interfaceorg.jaxen.Navigator
- Overrides:
getDocumentNode
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the context node- Returns:
- Returns the document of the context node.
- See Also:
isDocument(Object)
-
translateNamespacePrefixToUri
public String translateNamespacePrefixToUri(String prefix, Object element)
Translates 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 interfaceorg.jaxen.Navigator
- Overrides:
translateNamespacePrefixToUri
in classorg.jaxen.DefaultNavigator
- Parameters:
prefix
- the prefix to translateelement
- the element to consider during translation- Returns:
- Returns the namespace URI associated with the prefix.
-
getProcessingInstructionTarget
public String getProcessingInstructionTarget(Object object)
Retrieves the target of a processing-instruction.- Specified by:
getProcessingInstructionTarget
in interfaceorg.jaxen.Navigator
- Overrides:
getProcessingInstructionTarget
in classorg.jaxen.DefaultNavigator
- Parameters:
object
- the context processing-instruction node- Returns:
- Returns the target of the processing-instruction node.
-
getProcessingInstructionData
public String getProcessingInstructionData(Object object)
Retrieves the data of a processing-instruction.- Specified by:
getProcessingInstructionData
in interfaceorg.jaxen.Navigator
- Overrides:
getProcessingInstructionData
in classorg.jaxen.DefaultNavigator
- Parameters:
object
- the context processing-instruction node- Returns:
- Returns the data of the processing-instruction node.
-
getNodeType
public short getNodeType(Object node)
Returns a number that identifies the type of node that the given object represents in this navigator. See org.jaxen.pattern.Pattern- Specified by:
getNodeType
in interfaceorg.jaxen.Navigator
- Overrides:
getNodeType
in classorg.jaxen.DefaultNavigator
- Parameters:
node
- ????- Returns:
- Returns short.
-
getParentNode
public Object getParentNode(Object contextNode) throws org.jaxen.UnsupportedAxisException
Returns the parent of the given context node.The parent of any node must either be a document node or an element node.
- Specified by:
getParentNode
in interfaceorg.jaxen.Navigator
- Overrides:
getParentNode
in classorg.jaxen.DefaultNavigator
- Parameters:
contextNode
- the context node- Returns:
- Returns the parent of the context node, or null if this is a document node.
- Throws:
org.jaxen.UnsupportedAxisException
- if the parent axis is not supported by the model- See Also:
isDocument(java.lang.Object)
,isElement(java.lang.Object)
-
-