Interface Item

    • Method Detail

      • getGenre

        Genre getGenre()
        Get the genre of this item (to distinguish the top-level categories of item, such as nodes, atomic values, and functions)
        Returns:
        the genre
      • head

        default Item head()
        Get the first item in the sequence. Differs from the superclass Sequence in that * no exception is thrown.
        Specified by:
        head in interface GroundedValue
        Specified by:
        head in interface Sequence
        Returns:
        the first item in the sequence if there is one, or null if the sequence is empty
      • getUnicodeStringValue

        UnicodeString getUnicodeStringValue()
        Get the value of the item as a Unicode string. For nodes, this is the string value of the node as defined in the XPath 2.0 data model, except that all nodes are treated as being untyped: it is not an error to get the string value of a node with a complex type. For atomic values, the method returns the result of casting the atomic value to a string.
        Specified by:
        getUnicodeStringValue in interface GroundedValue
        Returns:
        the string value of the item
        Throws:
        java.lang.UnsupportedOperationException - if the item is a function item (an unchecked exception is used here to avoid introducing exception handling to a large number of paths where it is not needed)
        Since:
        8.4
      • getStringValue

        default java.lang.String getStringValue()
        Get the value of the item as a Java string. For nodes, this is the string value of the node as defined in the XPath 2.0 data model, except that all nodes are treated as being untyped: it is not an error to get the string value of a node with a complex type. For atomic values, the method returns the result of casting the atomic value to a string.
        Specified by:
        getStringValue in interface GroundedValue
        Returns:
        the string value of the item
        Throws:
        java.lang.UnsupportedOperationException - if the item is a function item (an unchecked exception is used here to avoid introducing exception handling to a large number of paths where it is not needed)
        Since:
        8.4
      • toShortString

        default java.lang.String toShortString()
        Provide a short string showing the contents of the item, suitable for use in error messages
        Specified by:
        toShortString in interface GroundedValue
        Returns:
        a depiction of the item suitable for use in error messages
      • itemAt

        default Item itemAt​(int n)
        Get the n'th item in the value, counting from 0
        Specified by:
        itemAt in interface GroundedValue
        Parameters:
        n - the index of the required item, with 0 representing the first item in the sequence
        Returns:
        the n'th item if it exists, or null otherwise
      • subsequence

        default GroundedValue subsequence​(int start,
                                          int length)
        Get a subsequence of the value
        Specified by:
        subsequence in interface GroundedValue
        Parameters:
        start - the index of the first item to be included in the result, counting from zero. A negative value is taken as zero. If the value is beyond the end of the sequence, an empty sequence is returned
        length - the number of items to be included in the result. Specify Integer.MAX_VALUE to get the subsequence up to the end of the base sequence. If the value is negative, an empty sequence is returned. If the value goes off the end of the sequence, the result returns items up to the end of the sequence
        Returns:
        the required subsequence. If min is
      • getLength

        default int getLength()
        Get the size of the value (the number of items)
        Specified by:
        getLength in interface GroundedValue
        Returns:
        the number of items in the sequence. Note that for a single item, including a map or array, the result is always 1 (one).
      • reduce

        default GroundedValue reduce()
        Reduce the sequence to its simplest form. If the value is an empty sequence, the result will be EmptySequence.getInstance(). If the value is a single atomic value, the result will be an instance of AtomicValue. If the value is a single item of any other kind, the result will be an instance of Item. Otherwise, the result will typically be unchanged.
        Specified by:
        reduce in interface GroundedValue
        Returns:
        the simplified sequence
      • isStreamed

        default boolean isStreamed()
        Ask whether this is a node in a streamed document
        Returns:
        true if the node is in a document being processed using streaming