Package net.sf.saxon.ma.arrays
Class ImmutableArrayItem
- java.lang.Object
-
- net.sf.saxon.ma.arrays.AbstractArrayItem
-
- net.sf.saxon.ma.arrays.ImmutableArrayItem
-
public class ImmutableArrayItem extends AbstractArrayItem
Implementation of ArrayItem backed by a persistent immutable array, so that operations that "update" the array do not have to copy the whole array
-
-
Field Summary
-
Fields inherited from interface net.sf.saxon.ma.arrays.ArrayItem
SINGLE_ARRAY_TYPE
-
-
Constructor Summary
Constructors Constructor Description ImmutableArrayItem(SimpleArrayItem other)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intarrayLength()Get the number of members in the arrayArrayItemconcat(ArrayItem other)Concatenate this array with anotherGroundedValueget(int index)Get a member of the arrayArrayIteminsert(int position, GroundedValue member)Insert a new member into an arraybooleanisEmpty()Ask whether the array is emptyjava.lang.Iterable<GroundedValue>members()Get the list of all members of the arrayArrayItemput(int index, GroundedValue newValue)Replace a member of the arrayArrayItemremove(int index)Remove a member from the arrayArrayItemremoveSeveral(IntSet positions)Remove zero or more members from the arrayArrayItemsubArray(int start, int end)Get a subarray given a start and end position-
Methods inherited from class net.sf.saxon.ma.arrays.AbstractArrayItem
atomize, call, deepEquals, effectiveBooleanValue, export, getAnnotations, getArity, getDescription, getFunctionItemType, getFunctionName, getMemberType, getOperandRoles, getStringValue, getStringValueCS, isArray, isMap, isTrustedResultType, makeNewContext, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.ma.arrays.ArrayItem
getGenre, toShortString
-
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize
-
Methods inherited from interface net.sf.saxon.om.Item
getLength, head, isStreamed, itemAt, iterate, reduce, subsequence
-
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
-
-
-
Constructor Detail
-
ImmutableArrayItem
public ImmutableArrayItem(SimpleArrayItem other)
-
-
Method Detail
-
get
public GroundedValue get(int index)
Get a member of the array- 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- 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
-
insert
public ArrayItem insert(int position, GroundedValue member)
Insert a new member into an array- Parameters:
position- the 0-based position that the new item will assumemember- 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
-
arrayLength
public int arrayLength()
Get the number of members in the arrayNote: the
method always returns 1, because an array is an item- Returns:
- the number of members in this array.
-
isEmpty
public boolean isEmpty()
Ask whether the array is empty- 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- Returns:
- an iterator over the members of the array
-
subArray
public ArrayItem subArray(int start, int end)
Get a subarray given a start and end position- 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
-
concat
public ArrayItem concat(ArrayItem other)
Concatenate this array with another- 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)
Remove a member from the array- Parameters:
index- the position of the member to be removed (zero-based)- Returns:
- a new array in which the requested member has been removed.
- Throws:
java.lang.IndexOutOfBoundsException- if index is out of range
-
-