org.apache.xpath.domapi
Class XPathResultImpl
java.lang.Object
org.apache.xpath.domapi.XPathResultImpl
- EventListener, XPathResult
public class XPathResultImpl
extends java.lang.Object
The class provides an implementation XPathResult according
to the DOM L3 XPath Specification, Working Draft 28, March 2002.
See also the
Document Object Model (DOM) Level 3 XPath Specification.
The
XPathResult
interface represents the result of the
evaluation of an XPath expression within the context of a particular
node. Since evaluation of an XPath expression can result in various
result types, this object makes it possible to discover and manipulate
the type and value of the result.
This implementation wraps an
XObject
.
getSnapshotLength
public int getSnapshotLength()
throws XPathException
The number of nodes in the result snapshot. Valid values for
snapshotItem indices are 0
to
snapshotLength-1
inclusive.
- getSnapshotLength in interface XPathResult
XPathException
- TYPE_ERR: raised if resultType
is not
UNORDERED_NODE_SNAPSHOT_TYPE
or
ORDERED_NODE_SNAPSHOT_TYPE
.
getTypeString
public String getTypeString(int type)
Given a request type, return the equivalent string.
For diagnostic purposes.
isValidType
public static boolean isValidType(short type)
Check if the specified type is one of the supported types.
type
- The specified type
- true If the specified type is supported; otherwise, returns false.
iterateNext
public Node iterateNext()
throws XPathException,
DOMException
Iterates and returns the next node from the node set or
null
if there are no more nodes.
- iterateNext in interface XPathResult
XPathException
- TYPE_ERR: raised if resultType
is not
UNORDERED_NODE_ITERATOR_TYPE
or
ORDERED_NODE_ITERATOR_TYPE
.DOMException
- INVALID_STATE_ERR: The document has been mutated since the result was
returned.
snapshotItem
public Node snapshotItem(int index)
throws XPathException
Returns the index
th item in the snapshot collection. If
index
is greater than or equal to the number of nodes in
the list, this method returns null
. Unlike the iterator
result, the snapshot does not become invalid, but may not correspond
to the current document if it is mutated.
- snapshotItem in interface XPathResult
index
- Index into the snapshot collection.
- The node at the
index
th position in the
NodeList
, or null
if that is not a valid
index.
XPathException
- TYPE_ERR: raised if resultType
is not
UNORDERED_NODE_SNAPSHOT_TYPE
or
ORDERED_NODE_SNAPSHOT_TYPE
.
Copyright B) 2004 Apache XML Project. All Rights Reserved.