|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xpath.domapi.XPathResultImpl
class XPathResultImpl
The class provides an implementation XPathResult according to the DOM L3 XPath Specification, Working Group Note 26 February 2004.
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
.
XObject
,
org.w3c.dom.xpath.XPathResult
Field Summary | |
---|---|
private org.w3c.dom.Node |
m_contextNode
Only used to attach a mutation event handler when specified type is an iterator type. |
private boolean |
m_isInvalidIteratorState
|
private org.w3c.dom.traversal.NodeIterator |
m_iterator
The iterator, if this is an iterator type. |
private org.w3c.dom.NodeList |
m_list
The list, if this is a snapshot type. |
private XObject |
m_resultObj
The wrapped XObject |
private short |
m_resultType
This the type specified by the user during construction. |
private XPath |
m_xpath
The xpath object that wraps the expression used for this result. |
Constructor Summary | |
---|---|
XPathResultImpl(short type,
XObject result,
org.w3c.dom.Node contextNode,
XPath xpath)
Constructor for XPathResultImpl. |
Method Summary | |
---|---|
private void |
addEventListener()
Add m_contextNode to Event Listner to listen for Mutations Events |
boolean |
getBooleanValue()
|
boolean |
getInvalidIteratorState()
|
double |
getNumberValue()
The value of this number result. |
short |
getResultType()
|
org.w3c.dom.Node |
getSingleNodeValue()
The value of this single node result, which may be null . |
int |
getSnapshotLength()
The number of nodes in the result snapshot. |
java.lang.String |
getStringValue()
The value of this string result. |
private short |
getTypeFromXObject(XObject object)
Given an XObject, determine the corresponding DOM XPath type |
private java.lang.String |
getTypeString(int type)
Given a request type, return the equivalent string. |
void |
handleEvent(org.w3c.dom.events.Event event)
|
private boolean |
isNamespaceNode(org.w3c.dom.Node node)
Given a node, determine if it is a namespace node. |
(package private) static boolean |
isValidType(short type)
Check if the specified type is one of the supported types. |
org.w3c.dom.Node |
iterateNext()
Iterates and returns the next node from the node set or null if there are no more nodes. |
private void |
removeEventListener()
Remove m_contextNode to Event Listner to listen for Mutations Events |
org.w3c.dom.Node |
snapshotItem(int index)
Returns the index th item in the snapshot collection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final XObject m_resultObj
private final XPath m_xpath
private final short m_resultType
private boolean m_isInvalidIteratorState
private final org.w3c.dom.Node m_contextNode
private org.w3c.dom.traversal.NodeIterator m_iterator
private org.w3c.dom.NodeList m_list
Constructor Detail |
---|
XPathResultImpl(short type, XObject result, org.w3c.dom.Node contextNode, XPath xpath)
Method Detail |
---|
public short getResultType()
org.w3c.dom.xpath.XPathResult#getResultType()
public double getNumberValue() throws XPathException
XPathException
- TYPE_ERR: raised if resultType
is not
NUMBER_TYPE
.org.w3c.dom.xpath.XPathResult#getNumberValue()
public java.lang.String getStringValue() throws XPathException
XPathException
- TYPE_ERR: raised if resultType
is not
STRING_TYPE
.org.w3c.dom.xpath.XPathResult#getStringValue()
public boolean getBooleanValue() throws XPathException
XPathException
org.w3c.dom.xpath.XPathResult#getBooleanValue()
public org.w3c.dom.Node getSingleNodeValue() throws XPathException
null
.
XPathException
- TYPE_ERR: raised if resultType
is not
ANY_UNORDERED_NODE_TYPE
or
FIRST_ORDERED_NODE_TYPE
.org.w3c.dom.xpath.XPathResult#getSingleNodeValue()
public boolean getInvalidIteratorState()
org.w3c.dom.xpath.XPathResult#getInvalidIteratorState()
public int getSnapshotLength() throws XPathException
0
to
snapshotLength-1
inclusive.
XPathException
- TYPE_ERR: raised if resultType
is not
UNORDERED_NODE_SNAPSHOT_TYPE
or
ORDERED_NODE_SNAPSHOT_TYPE
.org.w3c.dom.xpath.XPathResult#getSnapshotLength()
public org.w3c.dom.Node iterateNext() throws XPathException, org.w3c.dom.DOMException
null
if there are no more nodes.
XPathException
- TYPE_ERR: raised if resultType
is not
UNORDERED_NODE_ITERATOR_TYPE
or
ORDERED_NODE_ITERATOR_TYPE
.
org.w3c.dom.DOMException
- INVALID_STATE_ERR: The document has been mutated since the result was
returned.org.w3c.dom.xpath.XPathResult#iterateNext()
public org.w3c.dom.Node snapshotItem(int index) throws XPathException
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.
index
- Index into the snapshot collection.
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
.org.w3c.dom.xpath.XPathResult#snapshotItem(int)
static boolean isValidType(short type)
type
- The specified type
public void handleEvent(org.w3c.dom.events.Event event)
handleEvent
in interface org.w3c.dom.events.EventListener
EventListener.handleEvent(Event)
private java.lang.String getTypeString(int type)
private short getTypeFromXObject(XObject object)
private boolean isNamespaceNode(org.w3c.dom.Node node)
node
-
private void addEventListener()
private void removeEventListener()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |