Class ZenoSequence

  • All Implemented Interfaces:
    GroundedValue, Sequence

    public class ZenoSequence
    extends java.lang.Object
    implements GroundedValue
    An immutable XDM sequence implemented as a ZenoChain.

    This sequence implementation

    • Constructor Detail

      • ZenoSequence

        public ZenoSequence()
        Construct an empty ZenoSequence
      • ZenoSequence

        public ZenoSequence​(ZenoChain<Item> chain)
        Constructor to create a ZenoSequence that wraps a supplied ZenoChain
        Parameters:
        chain - the supplied ZenoChain
    • Method Detail

      • fromList

        public static ZenoSequence fromList​(java.util.List<Item> items)
        Construct a ZenoSequence from a list of items
        Parameters:
        items - the items to be included
        Returns:
        the new ZenoSequence
      • itemAt

        public Item itemAt​(int n)
        Get the item at a given position in the sequence
        Specified by:
        itemAt in interface GroundedValue
        Parameters:
        n - the index of the required item, with zero (0) representing the first item in the sequence
        Returns:
        the item at the given position, or null if the position is out of range
      • head

        public Item head()
        Get the first item in the sequence
        Specified by:
        head in interface GroundedValue
        Specified by:
        head in interface Sequence
        Returns:
        the first item in the sequence, or null if the sequence is empty
      • subsequence

        public 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 length goes off the end of the sequence, the result returns items up to the end of the sequence
        Returns:
        the required subsequence.
      • getLength

        public int getLength()
        Get the length of the sequence
        Specified by:
        getLength in interface GroundedValue
        Returns:
        the number of items in the sequence
      • getUnicodeStringValue

        public UnicodeString getUnicodeStringValue()
                                            throws XPathException
        Get a string representation of the sequence, consisting of the space-separated concatenation of the string representation of the items in the sequence
        Specified by:
        getUnicodeStringValue in interface GroundedValue
        Returns:
        a Unicode string containing the result of getting the string value of each item in the sequence, space-separated
        Throws:
        XPathException - if there is an item in the sequence with no string value, for example a map
      • getStringValue

        public java.lang.String getStringValue()
                                        throws XPathException
        Get a string representation of the sequence, consisting of the space-separated concatenation of the string representation of the items in the sequence
        Specified by:
        getStringValue in interface GroundedValue
        Returns:
        a Unicode string containing the result of getting the string value of each item in the sequence, space-separated
        Throws:
        XPathException - if there is an item in the sequence with no string value, for example a map
      • append

        public ZenoSequence append​(Item item)
        Append a single item to the end of the sequence
        Parameters:
        item - the item to be appended
        Returns:
        a new sequence containing the additional item. The original sequence is unchanged.
      • appendSequence

        public ZenoSequence appendSequence​(GroundedValue items)
        Append a sequence of item to the end of the sequence
        Parameters:
        items - the items to be appended
        Returns:
        a new sequence containing the additional items. The original sequence is unchanged.
      • join

        public static ZenoSequence join​(java.util.List<GroundedValue> segments)
        Create a ZenoSequence by concatenating a number of sequences
        Parameters:
        segments - the sequences to be concatenated
        Returns:
        the result of the concatenation