Class DelegatingArrayItem

All Implemented Interfaces:
Callable, FunctionItem, GroundedValue, Item, Sequence
Direct Known Subclasses:
PedigreeArrayItem

public abstract class DelegatingArrayItem extends AbstractArrayItem
A DelegatingArrayItem is an abstract class representing an array that is implemented by delegating all array-related functionality to a base class. Unless any methods are overridden, the functionality is identical to that of the wrapped array item.

Note that methods such as put(int, net.sf.saxon.om.GroundedValue) that create a new array will (unless overridden) simply delegate to the base array, and the new array will therefore not be a delegating array.

  • Constructor Details

    • DelegatingArrayItem

      public DelegatingArrayItem(ArrayItem base)
  • Method Details

    • get

      public GroundedValue get(int index)
      Description copied from class: ArrayItem
      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.
    • put

      public ArrayItem put(int index, GroundedValue newValue)
      Description copied from class: ArrayItem
      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.
    • arrayLength

      public int arrayLength()
      Description copied from class: ArrayItem
      Get the number of members in the array

      Note: the method always returns 1, because an array is an item

      Specified by:
      arrayLength in class ArrayItem
      Returns:
      the number of members in this array.
    • isEmpty

      public boolean isEmpty()
      Description copied from class: ArrayItem
      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 Iterable<GroundedValue> members()
      Description copied from class: ArrayItem
      Get the list of all members of the array
      Specified by:
      members in class ArrayItem
      Returns:
      an iterator over the members of the array
    • append

      public ArrayItem append(GroundedValue newMember)
      Description copied from class: ArrayItem
      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)
      Description copied from class: ArrayItem
      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
    • remove

      public ArrayItem remove(int index)
      Description copied from class: ArrayItem
      Remove a member from the array
      Specified by:
      remove in class ArrayItem
      Parameters:
      index - the position of the member to be removed (zero-based)
      Returns:
      a new array in which the requested member has been removed.
    • removeSeveral

      public ArrayItem removeSeveral(IntSet positions)
      Description copied from class: ArrayItem
      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
    • subArray

      public ArrayItem subArray(int start, int end)
      Description copied from class: ArrayItem
      Get a sub-array 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
    • insert

      public ArrayItem insert(int position, GroundedValue member)
      Description copied from class: ArrayItem
      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
    • getBaseItem

      public ArrayItem getBaseItem()