|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jaxen.DefaultNavigator
org.jaxen.dom.DocumentNavigator
Interface for navigating around the W3C DOM Level 2 object model.
This class is not intended for direct usage, but is used by the Jaxen engine during evaluation.
This class implements the org.jaxen.DefaultNavigator interface for the Jaxen XPath library, version 1.0beta3 (it is not guaranteed to work with subsequent releases). This adapter allows the Jaxen library to be used to execute XPath queries against any object tree that implements the DOM level 2 interfaces.
Note: DOM level 2 does not include a node representing an XML
Namespace declaration. This navigator will return Namespace decls
as instantiations of the custom NamespaceNode
class, and
users will have to check result sets to locate and isolate
these.
XPath
,
NamespaceNode
,
Serialized FormNested Class Summary | |
(package private) class |
DocumentNavigator.AttributeIterator
An iterator over an attribute list. |
(package private) class |
DocumentNavigator.NodeIterator
A generic iterator over DOM nodes. |
Field Summary | |
private static java.util.Iterator |
EMPTY_ITERATOR
Constant: empty iterator. |
private static DocumentNavigator |
SINGLETON
Constant: singleton navigator. |
Constructor Summary | |
DocumentNavigator()
Default Constructor. |
Method Summary | |
java.util.Iterator |
getAttributeAxisIterator(java.lang.Object contextNode)
Get an iterator over all attributes. |
java.lang.String |
getAttributeName(java.lang.Object object)
Get the local name of an attribute. |
java.lang.String |
getAttributeNamespaceUri(java.lang.Object object)
Get the Namespace URI of an attribute. |
java.lang.String |
getAttributeQName(java.lang.Object object)
Get the qualified name of an attribute. |
java.lang.String |
getAttributeStringValue(java.lang.Object object)
Get the string value of an attribute node. |
java.util.Iterator |
getChildAxisIterator(java.lang.Object contextNode)
Get an iterator over all of this node's children. |
java.lang.String |
getCommentStringValue(java.lang.Object object)
Get the string value of a comment node. |
java.lang.Object |
getDocument(java.lang.String uri)
Use JAXP to load a namespace aware document from a given URI |
java.lang.Object |
getDocumentNode(java.lang.Object contextNode)
Get the top-level document node. |
java.lang.Object |
getElementById(java.lang.Object object,
java.lang.String elementId)
Returns the element whose ID is given by elementId. |
java.lang.String |
getElementName(java.lang.Object object)
Get the local name of an element. |
java.lang.String |
getElementNamespaceUri(java.lang.Object object)
Get the Namespace URI of an element. |
java.lang.String |
getElementQName(java.lang.Object object)
Get the qualified name of an element. |
java.lang.String |
getElementStringValue(java.lang.Object object)
Get the string value of an element node. |
java.util.Iterator |
getFollowingAxisIterator(java.lang.Object contextNode)
Get an iterator over all following nodes, depth-first. |
java.util.Iterator |
getFollowingSiblingAxisIterator(java.lang.Object contextNode)
Get an iterator over all following siblings. |
static Navigator |
getInstance()
Get a singleton DocumentNavigator for efficiency. |
java.util.Iterator |
getNamespaceAxisIterator(java.lang.Object contextNode)
Get an iterator over all declared Namespaces. |
java.lang.String |
getNamespacePrefix(java.lang.Object object)
Get the prefix value of a Namespace node. |
java.lang.String |
getNamespaceStringValue(java.lang.Object object)
Get the string value of a Namespace node. |
java.util.Iterator |
getParentAxisIterator(java.lang.Object contextNode)
Get a (single-member) iterator over this node's parent. |
java.util.Iterator |
getPrecedingAxisIterator(java.lang.Object contextNode)
Get an iterator over all preceding nodes, depth-first. |
java.util.Iterator |
getPrecedingSiblingAxisIterator(java.lang.Object contextNode)
Get an iterator over all preceding siblings. |
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. |
private java.lang.StringBuffer |
getStringValue(org.w3c.dom.Node node,
java.lang.StringBuffer buffer)
Construct an element's string value recursively. |
java.lang.String |
getTextStringValue(java.lang.Object object)
Get the string value of text. |
boolean |
isAttribute(java.lang.Object object)
Test if a node is an attribute. |
boolean |
isComment(java.lang.Object object)
Test if a node is a comment. |
boolean |
isDocument(java.lang.Object object)
Test if a node is a top-level document. |
boolean |
isElement(java.lang.Object object)
Test if a node is an element. |
boolean |
isNamespace(java.lang.Object object)
Test if a node is a Namespace. |
boolean |
isProcessingInstruction(java.lang.Object object)
Test if a node is a processing instruction. |
boolean |
isText(java.lang.Object object)
Test if a node is plain text. |
XPath |
parseXPath(java.lang.String xpath)
Returns a parsed form of the given xpath string, which will be suitable for queries on DOM documents. |
java.lang.String |
translateNamespacePrefixToUri(java.lang.String prefix,
java.lang.Object element)
Translate a Namespace prefix to a URI. |
Methods inherited from class org.jaxen.DefaultNavigator |
getAncestorAxisIterator, getAncestorOrSelfAxisIterator, getDescendantAxisIterator, getDescendantOrSelfAxisIterator, getNodeType, getParentNode, getSelfAxisIterator |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.util.Iterator EMPTY_ITERATOR
private static final DocumentNavigator SINGLETON
Constructor Detail |
public DocumentNavigator()
Method Detail |
public static Navigator getInstance()
public java.util.Iterator getChildAxisIterator(java.lang.Object contextNode)
getChildAxisIterator
in interface Navigator
getChildAxisIterator
in class DefaultNavigator
contextNode
- The context node for the child axis.
public java.util.Iterator getParentAxisIterator(java.lang.Object contextNode)
getParentAxisIterator
in interface Navigator
getParentAxisIterator
in class DefaultNavigator
contextNode
- the context node for the parent axis.
public java.util.Iterator getFollowingSiblingAxisIterator(java.lang.Object contextNode)
getFollowingSiblingAxisIterator
in interface Navigator
getFollowingSiblingAxisIterator
in class DefaultNavigator
contextNode
- the context node for the sibling iterator.
public java.util.Iterator getPrecedingSiblingAxisIterator(java.lang.Object contextNode)
getPrecedingSiblingAxisIterator
in interface Navigator
getPrecedingSiblingAxisIterator
in class DefaultNavigator
contextNode
- The context node for the preceding sibling axis.
public java.util.Iterator getFollowingAxisIterator(java.lang.Object contextNode)
getFollowingAxisIterator
in interface Navigator
getFollowingAxisIterator
in class DefaultNavigator
contextNode
- The context node for the following axis.
public java.util.Iterator getPrecedingAxisIterator(java.lang.Object contextNode)
getPrecedingAxisIterator
in interface Navigator
getPrecedingAxisIterator
in class DefaultNavigator
contextNode
- The context node for the preceding axis.
public java.util.Iterator getAttributeAxisIterator(java.lang.Object contextNode)
getAttributeAxisIterator
in interface Navigator
getAttributeAxisIterator
in class DefaultNavigator
contextNode
- The context node for the attribute axis.
public java.util.Iterator getNamespaceAxisIterator(java.lang.Object contextNode)
Note: this iterator is not live: it takes a snapshot and that snapshot remains static during the life of the iterator (i.e. it won't reflect subsequent changes to the DOM).
getNamespaceAxisIterator
in interface Navigator
getNamespaceAxisIterator
in class DefaultNavigator
contextNode
- The context node for the Namespace axis.
public XPath parseXPath(java.lang.String xpath) throws SAXPathException
xpath
- The xpath expression.
SAXPathException
- If an error occurs while parsing the
xpath expression.XPath
public java.lang.Object getDocumentNode(java.lang.Object contextNode)
getDocumentNode
in interface Navigator
getDocumentNode
in class DefaultNavigator
contextNode
- Any node in the document.
public java.lang.String getElementNamespaceUri(java.lang.Object object)
object
- The target node.
public java.lang.String getElementName(java.lang.Object object)
object
- The target node.
public java.lang.String getElementQName(java.lang.Object object)
object
- The target node.
public java.lang.String getAttributeNamespaceUri(java.lang.Object object)
object
- The target node.
public java.lang.String getAttributeName(java.lang.Object object)
object
- The target node.
public java.lang.String getAttributeQName(java.lang.Object object)
object
- The target node.
public boolean isDocument(java.lang.Object object)
object
- The target node.
public boolean isNamespace(java.lang.Object object)
object
- The target node.
public boolean isElement(java.lang.Object object)
object
- The target node.
public boolean isAttribute(java.lang.Object object)
object
- The target node.
public boolean isComment(java.lang.Object object)
object
- The target node.
public boolean isText(java.lang.Object object)
object
- The target node.
public boolean isProcessingInstruction(java.lang.Object object)
object
- The target node.
public java.lang.String getElementStringValue(java.lang.Object object)
object
- The target node.
private java.lang.StringBuffer getStringValue(org.w3c.dom.Node node, java.lang.StringBuffer buffer)
node
- The current node.buffer
- The buffer for building the text.
public java.lang.String getAttributeStringValue(java.lang.Object object)
object
- The target node.
public java.lang.String getTextStringValue(java.lang.Object object)
object
- The target node.
public java.lang.String getCommentStringValue(java.lang.Object object)
object
- The target node.
public java.lang.String getNamespaceStringValue(java.lang.Object object)
object
- The target node.
public java.lang.String getNamespacePrefix(java.lang.Object object)
object
- The target node.
public java.lang.String translateNamespacePrefixToUri(java.lang.String prefix, java.lang.Object element)
translateNamespacePrefixToUri
in interface Navigator
translateNamespacePrefixToUri
in class DefaultNavigator
public java.lang.Object getDocument(java.lang.String uri) throws FunctionCallException
getDocument
in interface Navigator
getDocument
in class DefaultNavigator
uri
- is the URI of the document to load
FunctionCallException
- containing a nested exception
if a problem occurs trying to parse the given documentpublic java.lang.String getProcessingInstructionTarget(java.lang.Object obj)
Navigator
getProcessingInstructionTarget
in interface Navigator
getProcessingInstructionTarget
in class DefaultNavigator
public java.lang.String getProcessingInstructionData(java.lang.Object obj)
Navigator
getProcessingInstructionData
in interface Navigator
getProcessingInstructionData
in class DefaultNavigator
public java.lang.Object getElementById(java.lang.Object object, java.lang.String elementId)
setValidating(true)
on the
DocumentBuilderFactory.
getElementById
in interface Navigator
getElementById
in class DefaultNavigator
elementId
- id to look for
DocumentBuilderFactory
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |