Package net.sf.saxon.ma.arrays
Class SimpleArrayItem
java.lang.Object
net.sf.saxon.ma.arrays.ArrayItem
net.sf.saxon.ma.arrays.AbstractArrayItem
net.sf.saxon.ma.arrays.SimpleArrayItem
- All Implemented Interfaces:
Callable,FunctionItem,GroundedValue,Item,Sequence
A simple implementation of XDM array items, in which the array is backed by a Java List.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SimpleArrayItemStatic constant value representing an empty array -
Constructor Summary
ConstructorsConstructorDescriptionSimpleArrayItem(List<GroundedValue> members) Construct an array whose members are arbitrary sequences -
Method Summary
Modifier and TypeMethodDescriptionappend(GroundedValue newMember) Add a member to this arrayintGet the size of the arrayConcatenate this array with anotherget(int index) Get a member of the arrayGet the function annotations (as defined in XQuery).Get a list of the members of the arrayGet the roles of the arguments, for the purposes of streaminginsert(int position, GroundedValue member) Insert a new member into an arraybooleanisEmpty()Ask whether the array is emptyvoidEnsure that all the members are grounded.static SimpleArrayItemConstruct an array whose members are single itemsmembers()Get the list of all members of the arrayvoidNotify conversion to an ImmutableArrayItemparcels()Get an iterator over the members of the array, each represented as aParcelput(int index, GroundedValue newValue) Replace a member of the arrayremove(int pos) Remove a member from the arrayremoveSeveral(IntSet positions) Remove zero or more members from the arrayvoidrequestNotification(Pingable informee) Register an object to be notified if the SimpleArrayItem is converted to an ImmutableArrayItem.subArray(int start, int end) Get a subarray given a start and end positionProvide a short string showing the contents of the item, suitable for use in error messagesMethods inherited from class net.sf.saxon.ma.arrays.AbstractArrayItem
atomize, call, deepEqual40, deepEquals, effectiveBooleanValue, export, getArity, getDescription, getFunctionItemType, getFunctionName, getMemberType, getUnicodeStringValue, isTrustedResultType, makeNewContext, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.om.FunctionItem
isSequenceVariadicMethods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materializeMethods inherited from interface net.sf.saxon.om.Item
getLength, getStringValue, head, isStreamed, itemAt, iterate, reduce, subsequenceMethods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Field Details
-
EMPTY_ARRAY
Static constant value representing an empty array
-
-
Constructor Details
-
SimpleArrayItem
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 Details
-
makeSimpleArrayItem
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
-
getOperandRoles
Get the roles of the arguments, for the purposes of streaming- Specified by:
getOperandRolesin interfaceFunctionItem- Overrides:
getOperandRolesin classAbstractArrayItem- Returns:
- an array of OperandRole objects, one for each argument
-
requestNotification
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
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
-
getAnnotations
Get the function annotations (as defined in XQuery). Returns an empty list if there are no function annotations.- Specified by:
getAnnotationsin interfaceFunctionItem- Overrides:
getAnnotationsin classAbstractArrayItem- Returns:
- the function annotations
-
get
Get a member of the array- Specified by:
getin classArrayItem- Parameters:
index- the position of the member to retrieve (zero-based)- Returns:
- the value at the given position.
- Throws:
IndexOutOfBoundsException- if the index is out of range
-
put
Replace a member of the array- Specified by:
putin classArrayItem- Parameters:
index- the position of the member to replace (zero-based)newValue- the replacement value- Returns:
- the value at the given position.
- Throws:
IndexOutOfBoundsException- if the index is out of range
-
arrayLength
public int arrayLength()Get the size of the array- Specified by:
arrayLengthin classArrayItem- Returns:
- the number of members in this array
-
isEmpty
public boolean isEmpty()Ask whether the array is empty -
members
Get the list of all members of the array -
parcels
Get an iterator over the members of the array, each represented as aParcel- Overrides:
parcelsin classArrayItem- Returns:
- an
SequenceIteratorover the members of the array, represented as parcels
-
removeSeveral
Remove zero or more members from the array- Specified by:
removeSeveralin classArrayItem- 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
Remove a member from the array -
subArray
Get a subarray given a start and end position- Specified by:
subArrayin classArrayItem- 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:
IndexOutOfBoundsException- if start, or start+end, is out of range
-
insert
Insert a new member into an array- Specified by:
insertin classArrayItem- 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:
IndexOutOfBoundsException- if position is out of range
-
append
Add a member to this array -
concat
Concatenate this array with another -
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.
-
toShortString
Provide a short string showing the contents of the item, suitable for use in error messages- Specified by:
toShortStringin interfaceFunctionItem- Specified by:
toShortStringin interfaceGroundedValue- Specified by:
toShortStringin interfaceItem- Overrides:
toShortStringin classArrayItem- Returns:
- a depiction of the item suitable for use in error messages
-