Package net.sf.saxon.ma.arrays
Interface ArrayItem
-
- All Superinterfaces:
Callable
,Function
,GroundedValue
,Item
,Sequence
- All Known Implementing Classes:
AbstractArrayItem
,DelegatingArrayItem
,ImmutableArrayItem
,PedigreeArrayItem
,SimpleArrayItem
public interface ArrayItem extends Function
Interface supported by different implementations of an XDM array item
-
-
Field Summary
Fields Modifier and Type Field Description static SequenceType
SINGLE_ARRAY_TYPE
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description int
arrayLength()
Get the number of members in the arrayArrayItem
concat(ArrayItem other)
Concatenate this array with anotherGroundedValue
get(int index)
Get a member of the arraydefault Genre
getGenre()
Get the genre of this itemSequenceType
getMemberType(TypeHierarchy th)
Get the lowest common item type of the members of the arrayArrayItem
insert(int position, GroundedValue member)
Insert a new member into an arrayboolean
isEmpty()
Ask whether the array is emptyjava.lang.Iterable<GroundedValue>
members()
Get the list of all members of the arrayArrayItem
put(int index, GroundedValue newValue)
Replace a member of the arrayArrayItem
remove(int index)
Remove a member from the arrayArrayItem
removeSeveral(IntSet positions)
Remove zero or more members from the arrayArrayItem
subArray(int start, int end)
Get a sub-array given a start and end positiondefault java.lang.String
toShortString()
Provide a short string showing the contents of the item, suitable for use in error messages-
Methods inherited from interface net.sf.saxon.om.Function
call, deepEquals, export, getAnnotations, getArity, getDescription, getFunctionItemType, getFunctionName, getOperandRoles, isArray, isMap, isTrustedResultType, makeNewContext
-
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, effectiveBooleanValue, materialize
-
Methods inherited from interface net.sf.saxon.om.Item
atomize, getLength, getStringValue, getStringValueCS, head, isStreamed, itemAt, iterate, reduce, subsequence
-
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
-
-
-
Field Detail
-
SINGLE_ARRAY_TYPE
static final SequenceType SINGLE_ARRAY_TYPE
-
-
Method Detail
-
get
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
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
-
arrayLength
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
boolean isEmpty()
Ask whether the array is empty- Returns:
- true if and only if the size of the array is zero
-
members
java.lang.Iterable<GroundedValue> members()
Get the list of all members of the array- Returns:
- an iterator over the members of the array
-
concat
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
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
-
removeSeveral
ArrayItem removeSeveral(IntSet positions)
Remove zero or more members from the array- 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
- Throws:
java.lang.IndexOutOfBoundsException
- if any of the positions is out of range
-
subArray
ArrayItem subArray(int start, int end)
Get a sub-array 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
-
insert
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
-
getMemberType
SequenceType getMemberType(TypeHierarchy th)
Get the lowest common item type of the members of the array- Returns:
- the most specific type to which all the members belong.
-
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 interfaceFunction
- Specified by:
toShortString
in interfaceGroundedValue
- Specified by:
toShortString
in interfaceItem
- Returns:
- a depiction of the item suitable for use in error messages
-
-