Package net.sf.saxon.s9api
Class XdmArray
java.lang.Object
net.sf.saxon.s9api.XdmValue
net.sf.saxon.s9api.XdmItem
net.sf.saxon.s9api.XdmFunctionItem
net.sf.saxon.s9api.XdmArray
An array in the XDM data model. An array is a list of zero or more members, each of which
is an arbitrary XDM value. The array itself is an XDM item.
An XdmArray is immutable.
- Since:
- 9.8
-
Constructor Summary
ConstructorsConstructorDescriptionXdmArray()
Create an empty XdmArrayCreate an XdmArray supplying the members as a collection of XdmValue objectsCreate an XdmArray that wraps a supplied ArrayItemCreate an XdmArray supplying the members as an array of XdmValue objects -
Method Summary
Modifier and TypeMethodDescriptionAppend a new member to an arrayint
Get the number of members in the arrayasList()
Get the members of the array in the form of a list.Concatenate another arrayget
(int n) Get the n'th member in the array, counting from zero.Get the underlying implementation object representing the value.static XdmArray
makeArray
(boolean[] input) Make an XdmArray whose members are xs:boolean valuesstatic XdmArray
makeArray
(byte[] input) Make an XdmArray whose members are xs:integer valuesstatic XdmArray
makeArray
(int[] input) Make an XdmArray whose members are xs:integer valuesstatic XdmArray
makeArray
(long[] input) Make an XdmArray whose members are xs:long valuesstatic XdmArray
makeArray
(short[] input) Make an XdmArray whose members are xs:integer valuesstatic XdmArray
Make an XDM array from a Java array.Create a new array in which one member is replaced with a new value.Methods inherited from class net.sf.saxon.s9api.XdmFunctionItem
asFunction, asStep, call, getArity, getName, getSystemFunction, isAtomicValue
Methods inherited from class net.sf.saxon.s9api.XdmItem
asMap, getStringValue, getUnicodeStringValue, isNode, matches, size, stream, wrapItem, wrapItem, wrapItem
Methods inherited from class net.sf.saxon.s9api.XdmValue
append, documentOrder, isEmpty, itemAt, iterator, makeSequence, makeValue, matches, select, subsequence, toString, where, wrap, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
XdmArray
public XdmArray()Create an empty XdmArray -
XdmArray
Create an XdmArray that wraps a supplied ArrayItem- Parameters:
array
- the ArrayItem to be encapsulated
-
XdmArray
Create an XdmArray supplying the members as an array of XdmValue objects- Parameters:
members
- an array of XdmValue objects. Note that subsequent changes to the array will have no effect on the XdmValue.
-
XdmArray
Create an XdmArray supplying the members as a collection of XdmValue objects- Parameters:
members
- a sequence of XdmValue objects. Note that if this is supplied as a list or similar collection, subsequent changes to the list/collection will have no effect on the XdmValue. Note that the argument can be a single XdmValue representing a sequence, in which case the constructed array will have one member for each item in the supplied sequence.
-
-
Method Details
-
arrayLength
public int arrayLength()Get the number of members in the array- Returns:
- the number of members in the array. (Note that the
XdmItem.size()
method returns 1 (one), because an XDM array is an item.)
-
get
Get the n'th member in the array, counting from zero.- Parameters:
n
- the member that is required, counting the first member in the array as member zero- Returns:
- the n'th member in the sequence making up the array, counting from zero
- Throws:
IndexOutOfBoundsException
- if n is less than zero or greater than or equal to the number of members in the array
-
put
Create a new array in which one member is replaced with a new value.- Parameters:
n
- the position of the member that is to be replaced, counting the first member in the array as member zerovalue
- the new value for this member- Returns:
- a new array, the same length as the original, with one member replaced by a new value
- Throws:
IndexOutOfBoundsException
- if n is less than zero or greater than or equal to the number of members in the array
-
addMember
Append a new member to an array- Parameters:
value
- the new member- Returns:
- a new array, one item longer than the original
- Since:
- 9.9. (See bug 3968: on first release of 9.9, the method was mistakenly named
append
).
-
concat
Concatenate another array- Parameters:
value
- the other array- Returns:
- a new array, containing the members of this array followed by the members of the other array
- Since:
- 9.9
-
asList
Get the members of the array in the form of a list.- Returns:
- a list of the members of this array.
-
getUnderlyingValue
Get the underlying implementation object representing the value. This method allows access to lower-level Saxon functionality, including classes and methods that offer no guarantee of stability across releases.- Overrides:
getUnderlyingValue
in classXdmItem
- Returns:
- the underlying implementation object representing the value
-
makeArray
Make an XDM array from a Java array. Each member of the supplied array is converted to a single member in the result array using the methodXdmValue.makeValue(Object)
- Parameters:
input
- the Java array- Returns:
- the result of the conversion if successful
- Throws:
IllegalArgumentException
- if conversion is not possible
-
makeArray
Make an XdmArray whose members are xs:boolean values- Parameters:
input
- the input array of booleans- Returns:
- an XdmArray whose members are xs:boolean values corresponding one-to-one with the input
-
makeArray
Make an XdmArray whose members are xs:long values- Parameters:
input
- the input array of integers- Returns:
- an XdmArray whose members are xs:integer values corresponding one-to-one with the input
-
makeArray
Make an XdmArray whose members are xs:integer values- Parameters:
input
- the input array of integers- Returns:
- an XdmArray whose members are xs:integer values corresponding one-to-one with the input
-
makeArray
Make an XdmArray whose members are xs:integer values- Parameters:
input
- the input array of integers- Returns:
- an XdmArray whose members are xs:integer values corresponding one-to-one with the input
-
makeArray
Make an XdmArray whose members are xs:integer values- Parameters:
input
- the input array of integers- Returns:
- an XdmArray whose members are xs:integer values corresponding one-to-one with the input
-