Package org.loboevolution.html.dom.xpath
Class XPathResultImpl
java.lang.Object
org.loboevolution.html.dom.xpath.XPathResultImpl
- All Implemented Interfaces:
XPathResult
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.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final short
The Constant ANY_TYPE.static final short
The Constant ANY_UNORDERED_NODE_TYPE.static final short
The Constant BOOLEAN_TYPE.static final short
The Constant FIRST_ORDERED_NODE_TYPE.static final short
The Constant NUMBER_TYPE.static final short
The Constant ORDERED_NODE_ITERATOR_TYPE.static final short
The Constant ORDERED_NODE_SNAPSHOT_TYPE.static final short
The Constant STRING_TYPE.static final short
The Constant UNORDERED_NODE_ITERATOR_TYPE.static final short
The Constant UNORDERED_NODE_SNAPSHOT_TYPE. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
The value of this boolean result.boolean
Signifies that the iterator has become invalid.double
The value of this number result.short
A code representing the type of this result, as defined by the type constants.The value of this single node result, which may be null.int
The number of nodes in the result snapshot.The value of this string result.void
handleEvent
(Event event) static boolean
isValidType
(short type) Check if the specified type is one of the supported types.Iterates and returns the next node from the node set or nullif there are no more nodes.snapshotItem
(int index) Returns the indexth item in the snapshot collection.
-
Field Details
-
ANY_TYPE
public static final short ANY_TYPEThe Constant ANY_TYPE.- See Also:
-
NUMBER_TYPE
public static final short NUMBER_TYPEThe Constant NUMBER_TYPE.- See Also:
-
STRING_TYPE
public static final short STRING_TYPEThe Constant STRING_TYPE.- See Also:
-
BOOLEAN_TYPE
public static final short BOOLEAN_TYPEThe Constant BOOLEAN_TYPE.- See Also:
-
UNORDERED_NODE_ITERATOR_TYPE
public static final short UNORDERED_NODE_ITERATOR_TYPEThe Constant UNORDERED_NODE_ITERATOR_TYPE.- See Also:
-
ORDERED_NODE_ITERATOR_TYPE
public static final short ORDERED_NODE_ITERATOR_TYPEThe Constant ORDERED_NODE_ITERATOR_TYPE.- See Also:
-
UNORDERED_NODE_SNAPSHOT_TYPE
public static final short UNORDERED_NODE_SNAPSHOT_TYPEThe Constant UNORDERED_NODE_SNAPSHOT_TYPE.- See Also:
-
ORDERED_NODE_SNAPSHOT_TYPE
public static final short ORDERED_NODE_SNAPSHOT_TYPEThe Constant ORDERED_NODE_SNAPSHOT_TYPE.- See Also:
-
ANY_UNORDERED_NODE_TYPE
public static final short ANY_UNORDERED_NODE_TYPEThe Constant ANY_UNORDERED_NODE_TYPE.- See Also:
-
FIRST_ORDERED_NODE_TYPE
public static final short FIRST_ORDERED_NODE_TYPEThe Constant FIRST_ORDERED_NODE_TYPE.- See Also:
-
-
Constructor Details
-
XPathResultImpl
public XPathResultImpl()Instantiates a new x path result impl.
-
-
Method Details
-
isValidType
public static boolean isValidType(short type) Check if the specified type is one of the supported types.- Parameters:
type
- The specified type- Returns:
- true If the specified type is supported; otherwise, returns false.
-
getResultType
public short getResultType()A code representing the type of this result, as defined by the type constants.- Specified by:
getResultType
in interfaceXPathResult
- Returns:
- a short.
-
getNumberValue
The value of this number result. If the native double type of the DOM binding does not directly support the exact IEEE 754 result of the XPath expression, then it is up to the definition of the binding binding to specify how the XPath number is converted to the native binding number.- Specified by:
getNumberValue
in interfaceXPathResult
- Returns:
- a double.
- Throws:
XPathException
- TYPE_ERR: raised if resultType is not NUMBER_TYPE.XPathException
- if any.
-
getStringValue
The value of this string result.- Specified by:
getStringValue
in interfaceXPathResult
- Returns:
- a
String
object. - Throws:
XPathException
- TYPE_ERR: raised if resultType is not STRING_TYPE.XPathException
- if any.
-
getBooleanValue
The value of this boolean result.- Specified by:
getBooleanValue
in interfaceXPathResult
- Returns:
- a boolean.
- Throws:
XPathException
- TYPE_ERR: raised if resultType is not BOOLEAN_TYPE.XPathException
- if any.
-
getSingleNodeValue
The value of this single node result, which may be null.- Specified by:
getSingleNodeValue
in interfaceXPathResult
- Returns:
- a
Node
object. - Throws:
XPathException
- TYPE_ERR: raised if resultType is not ANY_UNORDERED_NODE_TYPE or FIRST_ORDERED_NODE_TYPE.XPathException
- if any.
-
getInvalidIteratorState
public boolean getInvalidIteratorState()Signifies that the iterator has become invalid. True if resultType is UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE and the document has been modified since this result was returned.- Specified by:
getInvalidIteratorState
in interfaceXPathResult
- Returns:
- a boolean.
-
getSnapshotLength
The number of nodes in the result snapshot. Valid values for snapshotItem indices are 0 to snapshotLength-1 inclusive.- Specified by:
getSnapshotLength
in interfaceXPathResult
- Returns:
- a
Integer
object. - Throws:
XPathException
- TYPE_ERR: raised if resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE.XPathException
- if any.
-
iterateNext
Iterates and returns the next node from the node set or nullif there are no more nodes.- Specified by:
iterateNext
in interfaceXPathResult
- Returns:
- Returns the next node.
- Throws:
XPathException
- TYPE_ERR: raised if resultType is not UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE.XPathException
- if any.DOMException
- INVALID_STATE_ERR: The document has been mutated since the result was returned.DOMException
- if any.
-
snapshotItem
Returns the indexth 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.- Specified by:
snapshotItem
in interfaceXPathResult
- Parameters:
index
- Index into the snapshot collection.- Returns:
- The node at the indexth position in the NodeList, or null if that is not a valid index.
- Throws:
XPathException
- TYPE_ERR: raised if resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE.XPathException
- if any.
-
handleEvent
Handle event.
- Parameters:
event
- aEvent
object.- See Also:
-