Class XPathResult

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.htmlunit.corejs.javascript.ConstProperties, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable

    public class XPathResult
    extends HtmlUnitScriptable
    A JavaScript object for XPathResult.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ANY_TYPE
      This code does not represent a specific type.
      static int ANY_UNORDERED_NODE_TYPE
      The result is a node set and will be accessed as a single node, which may be null if the node set is empty.
      static int BOOLEAN_TYPE
      The result is a boolean.
      static int FIRST_ORDERED_NODE_TYPE
      The result is a node set and will be accessed as a single node, which may be null if the node set is empty.
      private int iteratorIndex_
      The index of the next result.
      static int NUMBER_TYPE
      The result is a number.
      static int ORDERED_NODE_ITERATOR_TYPE
      The result is a node set that will be accessed iteratively, which will produce document-ordered nodes.
      static int ORDERED_NODE_SNAPSHOT_TYPE
      The result is a node set that will be accessed as a snapshot list of nodes that will be in original document order.
      private java.util.List<?> result_  
      private int resultType_  
      static int STRING_TYPE
      The result is a string.
      static int UNORDERED_NODE_ITERATOR_TYPE
      The result is a node set that will be accessed iteratively, which may not produce nodes in a particular order.
      static int UNORDERED_NODE_SNAPSHOT_TYPE
      The result is a node set that will be accessed as a snapshot list of nodes that may not be in a particular order.
      • Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
      • Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

        NOT_FOUND
    • Constructor Summary

      Constructors 
      Constructor Description
      XPathResult()
      Creates an instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String asString()  
      boolean getBooleanValue()
      Returns the value of this boolean result.
      boolean getInvalidIteratorState()  
      double getNumberValue()
      Returns the value of this number result.
      int getResultType()
      The code representing the type of this result, as defined by the type constants.
      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()
      Returns the value of this string result.
      (package private) void init​(java.util.List<?> result, int type)  
      Node iterateNext()
      Iterates and returns the next node from the node set or null if there are no more nodes.
      void jsConstructor()
      Creates an instance.
      Node snapshotItem​(int index)
      Returns the indexth item in the snapshot collection.
      • Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ANY_TYPE

        public static final int ANY_TYPE
        This code does not represent a specific type. An evaluation of an XPath expression will never produce this type. If this type is requested, then the evaluation returns whatever type naturally results from evaluation of the expression.
        See Also:
        Constant Field Values
      • NUMBER_TYPE

        public static final int NUMBER_TYPE
        The result is a number.
        See Also:
        Constant Field Values
      • STRING_TYPE

        public static final int STRING_TYPE
        The result is a string.
        See Also:
        Constant Field Values
      • BOOLEAN_TYPE

        public static final int BOOLEAN_TYPE
        The result is a boolean.
        See Also:
        Constant Field Values
      • UNORDERED_NODE_ITERATOR_TYPE

        public static final int UNORDERED_NODE_ITERATOR_TYPE
        The result is a node set that will be accessed iteratively, which may not produce nodes in a particular order. This is the default type returned if the result is a node set and ANY_TYPE is requested.
        See Also:
        Constant Field Values
      • ORDERED_NODE_ITERATOR_TYPE

        public static final int ORDERED_NODE_ITERATOR_TYPE
        The result is a node set that will be accessed iteratively, which will produce document-ordered nodes.
        See Also:
        Constant Field Values
      • UNORDERED_NODE_SNAPSHOT_TYPE

        public static final int UNORDERED_NODE_SNAPSHOT_TYPE
        The result is a node set that will be accessed as a snapshot list of nodes that may not be in a particular order.
        See Also:
        Constant Field Values
      • ORDERED_NODE_SNAPSHOT_TYPE

        public static final int ORDERED_NODE_SNAPSHOT_TYPE
        The result is a node set that will be accessed as a snapshot list of nodes that will be in original document order.
        See Also:
        Constant Field Values
      • ANY_UNORDERED_NODE_TYPE

        public static final int ANY_UNORDERED_NODE_TYPE
        The result is a node set and will be accessed as a single node, which may be null if the node set is empty. If there is more than one node in the actual result, the single node returned might not be the first in document order.
        See Also:
        Constant Field Values
      • FIRST_ORDERED_NODE_TYPE

        public static final int FIRST_ORDERED_NODE_TYPE
        The result is a node set and will be accessed as a single node, which may be null if the node set is empty. If there are more than one node in the actual result, the single node returned will be the first in document order.
        See Also:
        Constant Field Values
      • result_

        private java.util.List<?> result_
      • resultType_

        private int resultType_
      • iteratorIndex_

        private int iteratorIndex_
        The index of the next result.
    • Constructor Detail

      • XPathResult

        public XPathResult()
        Creates an instance.
    • Method Detail

      • jsConstructor

        public void jsConstructor()
        Creates an instance.
      • init

        void init​(java.util.List<?> result,
                  int type)
        Parameters:
        result - the evaluation result
        type - If a specific type is specified, then the result will be returned as the corresponding type
      • getResultType

        public int getResultType()
        The code representing the type of this result, as defined by the type constants.
        Returns:
        the code representing the type of this result
      • getSnapshotLength

        public int getSnapshotLength()
        The number of nodes in the result snapshot.
        Returns:
        the number of nodes in the result snapshot
      • getSingleNodeValue

        public Node getSingleNodeValue()
        The value of this single node result, which may be null.
        Returns:
        the value of this single node result, which may be null
      • getInvalidIteratorState

        public boolean getInvalidIteratorState()
        Returns:
        signifies that the iterator has become invalid. It is true if XPathResult.resultType is UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE and the document has been modified since this result was returned.
      • iterateNext

        public Node iterateNext()
        Iterates and returns the next node from the node set or null if there are no more nodes.
        Returns:
        the next node
      • snapshotItem

        public Node snapshotItem​(int index)
        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.
        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
      • getNumberValue

        public double getNumberValue()
        Returns the value of this number result.
        Returns:
        the value of this number result
      • getBooleanValue

        public boolean getBooleanValue()
        Returns the value of this boolean result.
        Returns:
        the value of this boolean result
      • getStringValue

        public java.lang.String getStringValue()
        Returns the value of this string result.
        Returns:
        the value of this string result
      • asString

        private java.lang.String asString()