Class XPathResultImpl

java.lang.Object
org.loboevolution.html.dom.xpath.XPathResultImpl
All Implemented Interfaces:
XPathResult

public class XPathResultImpl extends Object implements 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 Details

    • ANY_TYPE

      public static final short ANY_TYPE
      The Constant ANY_TYPE.
      See Also:
    • NUMBER_TYPE

      public static final short NUMBER_TYPE
      The Constant NUMBER_TYPE.
      See Also:
    • STRING_TYPE

      public static final short STRING_TYPE
      The Constant STRING_TYPE.
      See Also:
    • BOOLEAN_TYPE

      public static final short BOOLEAN_TYPE
      The Constant BOOLEAN_TYPE.
      See Also:
    • UNORDERED_NODE_ITERATOR_TYPE

      public static final short UNORDERED_NODE_ITERATOR_TYPE
      The Constant UNORDERED_NODE_ITERATOR_TYPE.
      See Also:
    • ORDERED_NODE_ITERATOR_TYPE

      public static final short ORDERED_NODE_ITERATOR_TYPE
      The Constant ORDERED_NODE_ITERATOR_TYPE.
      See Also:
    • UNORDERED_NODE_SNAPSHOT_TYPE

      public static final short UNORDERED_NODE_SNAPSHOT_TYPE
      The Constant UNORDERED_NODE_SNAPSHOT_TYPE.
      See Also:
    • ORDERED_NODE_SNAPSHOT_TYPE

      public static final short ORDERED_NODE_SNAPSHOT_TYPE
      The Constant ORDERED_NODE_SNAPSHOT_TYPE.
      See Also:
    • ANY_UNORDERED_NODE_TYPE

      public static final short ANY_UNORDERED_NODE_TYPE
      The Constant ANY_UNORDERED_NODE_TYPE.
      See Also:
    • FIRST_ORDERED_NODE_TYPE

      public static final short FIRST_ORDERED_NODE_TYPE
      The 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 interface XPathResult
      Returns:
      a short.
    • getNumberValue

      public double getNumberValue() throws XPathException
      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 interface XPathResult
      Returns:
      a double.
      Throws:
      XPathException - TYPE_ERR: raised if resultType is not NUMBER_TYPE.
      XPathException - if any.
    • getStringValue

      public String getStringValue() throws XPathException
      The value of this string result.
      Specified by:
      getStringValue in interface XPathResult
      Returns:
      a String object.
      Throws:
      XPathException - TYPE_ERR: raised if resultType is not STRING_TYPE.
      XPathException - if any.
    • getBooleanValue

      public boolean getBooleanValue() throws XPathException
      The value of this boolean result.
      Specified by:
      getBooleanValue in interface XPathResult
      Returns:
      a boolean.
      Throws:
      XPathException - TYPE_ERR: raised if resultType is not BOOLEAN_TYPE.
      XPathException - if any.
    • getSingleNodeValue

      public Node getSingleNodeValue() throws XPathException
      The value of this single node result, which may be null.
      Specified by:
      getSingleNodeValue in interface XPathResult
      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 interface XPathResult
      Returns:
      a boolean.
    • 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.
      Specified by:
      getSnapshotLength in interface XPathResult
      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

      public Node iterateNext() throws XPathException, DOMException
      Iterates and returns the next node from the node set or nullif there are no more nodes.
      Specified by:
      iterateNext in interface XPathResult
      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

      public Node snapshotItem(int index) throws XPathException
      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 interface XPathResult
      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

      public void handleEvent(Event event)

      Handle event.

      Parameters:
      event - a Event object.
      See Also: