Class SimpleArrayItem

    • Field Detail

      • EMPTY_ARRAY

        public static final SimpleArrayItem EMPTY_ARRAY
        Static constant value representing an empty array
    • Constructor Detail

      • SimpleArrayItem

        public SimpleArrayItem​(java.util.List<GroundedValue> members)
        Construct an array whose members are arbitrary sequences
        Parameters:
        members - the list of values (in general, each value is a sequence) to form the members of the array. The values must be repeatable sequences (not LazySequences); this is not checked.
    • Method Detail

      • makeSimpleArrayItem

        public static SimpleArrayItem makeSimpleArrayItem​(SequenceIterator input)
                                                   throws XPathException
        Construct an array whose members are single items
        Parameters:
        input - an iterator over the items to make up the array
        Returns:
        an array in which each member is a single item, taken from the input sequence
        Throws:
        XPathException - if evaluating the SequenceIterator fails
      • requestNotification

        public void requestNotification​(Pingable informee)
        Register an object to be notified if the SimpleArrayItem is converted to an ImmutableArrayItem. This indicates that it should probably have been created as an ImmutableArrayItem in the first place.
      • notifyConversion

        public void notifyConversion()
        Notify conversion to an ImmutableArrayItem
      • makeGrounded

        public void makeGrounded()
                          throws XPathException
        Ensure that all the members are grounded. The idea is that a member may initially be a reference to a lazily-evaluated sequence, but once computed, the reference will be replaced with the actual value
        Throws:
        XPathException - if an error is detected
      • get

        public GroundedValue get​(int index)
        Get a member of the array
        Specified by:
        get in class ArrayItem
        Parameters:
        index - the position of the member to retrieve (zero-based)
        Returns:
        the value at the given position.
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is out of range
      • put

        public ArrayItem put​(int index,
                             GroundedValue newValue)
        Replace a member of the array
        Specified by:
        put in class ArrayItem
        Parameters:
        index - the position of the member to replace (zero-based)
        newValue - the replacement value
        Returns:
        the value at the given position.
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is out of range
      • arrayLength

        public int arrayLength()
        Get the size of the array
        Specified by:
        arrayLength in class ArrayItem
        Returns:
        the number of members in this array
      • isEmpty

        public boolean isEmpty()
        Ask whether the array is empty
        Overrides:
        isEmpty in class ArrayItem
        Returns:
        true if and only if the size of the array is zero
      • members

        public java.lang.Iterable<GroundedValue> members()
        Get the list of all members of the array
        Specified by:
        members in class ArrayItem
        Returns:
        an iterator over the members of the array
      • removeSeveral

        public ArrayItem removeSeveral​(IntSet positions)
        Remove zero or more members from the array
        Specified by:
        removeSeveral in class ArrayItem
        Parameters:
        positions - the positions of the members to be removed (zero-based). A value that is out of range is ignored.
        Returns:
        a new array in which the requested member has been removed
      • remove

        public ArrayItem remove​(int pos)
        Remove a member from the array
        Specified by:
        remove in class ArrayItem
        Parameters:
        pos - the position of the member to be removed (zero-based). A value that is out of range results in an IndexOutOfBoundsException
        Returns:
        a new array in which the requested member has been removed
      • subArray

        public ArrayItem subArray​(int start,
                                  int end)
        Get a subarray given a start and end position
        Specified by:
        subArray in class ArrayItem
        Parameters:
        start - the start position (zero based)
        end - the end position (the position of the first item not to be returned) (zero based)
        Returns:
        a new array item containing the sub-array
        Throws:
        java.lang.IndexOutOfBoundsException - if start, or start+end, is out of range
      • insert

        public ArrayItem insert​(int position,
                                GroundedValue member)
        Insert a new member into an array
        Specified by:
        insert in class ArrayItem
        Parameters:
        position - the 0-based position that the new item will assume
        member - the new member to be inserted
        Returns:
        a new array item with the new member inserted
        Throws:
        java.lang.IndexOutOfBoundsException - if position is out of range
      • append

        public ArrayItem append​(GroundedValue newMember)
        Add a member to this array
        Specified by:
        append in class ArrayItem
        Parameters:
        newMember - the member to be added
        Returns:
        the new array, comprising the members of this array and then one additional member.
      • concat

        public ArrayItem concat​(ArrayItem other)
        Concatenate this array with another
        Specified by:
        concat in class ArrayItem
        Parameters:
        other - the second array
        Returns:
        the concatenation of the two arrays; that is, an array containing first the members of this array, and then the members of the other array
      • getMembers

        public java.util.List<GroundedValue> getMembers()
        Get a list of the members of the array
        Returns:
        the list of members. Note that this returns the actual contained member array, and this is mutable. Changes to this array are permitted only if the caller knows what they are doing, for example during initial construction of an array that will not be presented to the user until construction has finished.