Package net.sf.saxon.ma.arrays
Class AbstractArrayItem
java.lang.Object
net.sf.saxon.ma.arrays.ArrayItem
net.sf.saxon.ma.arrays.AbstractArrayItem
- All Implemented Interfaces:
Callable
,FunctionItem
,GroundedValue
,Item
,Sequence
- Direct Known Subclasses:
DelegatingArrayItem
,ImmutableArrayItem
,SimpleArrayItem
An abstract implementation of XDM array items, containing methods that can be implemented generically.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionatomize()
Atomize the item.call
(XPathContext context, Sequence[] args) Invoke the array in its role as a functionboolean
deepEqual40
(FunctionItem other, XPathContext context, DeepEqual.DeepEqualOptions options) boolean
deepEquals
(FunctionItem other, XPathContext context, AtomicComparer comparer, int flags) Test whether this array is deep-equal to another array, under the rules of the deep-equal functionboolean
Get the effective boolean value of this sequencevoid
Output information about this function item to the diagnostic explain() outputGet the function annotations (as defined in XQuery).int
getArity()
Get the arity of the functionGet a description of this function for use in error messages.Get the item type of the function itemGet the name of the function, or null if it is anonymousGet the lowest common item type of the members of the arrayGet the roles of the arguments, for the purposes of streamingGet the value of the item as a string.boolean
Ask if the function can be trusted to return a result of the correct typemakeNewContext
(XPathContext callingContext, ContextOriginator originator) Prepare an XPathContext object for evaluating the functiontoString()
Output a string representation of the array, suitable for diagnosticsMethods inherited from class net.sf.saxon.ma.arrays.ArrayItem
append, arrayLength, concat, get, getGenre, insert, isArray, isEmpty, isMap, members, parcels, put, remove, removeSeveral, subArray, toShortString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.FunctionItem
isSequenceVariadic
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize
Methods inherited from interface net.sf.saxon.om.Item
getLength, getStringValue, head, isStreamed, itemAt, iterate, reduce, subsequence
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
AbstractArrayItem
public AbstractArrayItem()
-
-
Method Details
-
getOperandRoles
Get the roles of the arguments, for the purposes of streaming- Returns:
- an array of OperandRole objects, one for each argument
-
atomize
Atomize the item.- Returns:
- the result of atomization
- Throws:
XPathException
- if atomization is not allowed for this kind of item
-
getAnnotations
Get the function annotations (as defined in XQuery). Returns an empty list if there are no function annotations.- Returns:
- the function annotations
-
getFunctionItemType
Get the item type of the function item- Returns:
- the function item's type
-
getFunctionName
Get the name of the function, or null if it is anonymous- Returns:
- the function name, or null for an anonymous function (which this one is)
-
getDescription
Get a description of this function for use in error messages. For named functions, the description is the function name (as a lexical QName). For others, it might be, for example, "inline function", or "partially-applied ends-with function".- Returns:
- a description of the function for use in error messages
-
getArity
public int getArity()Get the arity of the function- Returns:
- the number of arguments in the function signature (in this case, 1 (one))
-
makeNewContext
Prepare an XPathContext object for evaluating the function- Parameters:
callingContext
- the XPathContext of the function calling expressionoriginator
- identifies the location of the caller for diagnostics- Returns:
- a suitable context for evaluating the function (which may or may not be the same as the caller's context)
-
call
Invoke the array in its role as a function- Parameters:
context
- the XPath dynamic evaluation contextargs
- the actual arguments to be supplied (a single integer)- Returns:
- the result of invoking the function
- Throws:
XPathException
- if a dynamic error occurs within the function
-
deepEquals
public boolean deepEquals(FunctionItem other, XPathContext context, AtomicComparer comparer, int flags) throws XPathException Test whether this array is deep-equal to another array, under the rules of the deep-equal function- Parameters:
other
- the other function itemcontext
- the dynamic evaluation contextcomparer
- the object to perform the comparisonflags
- options for how the comparison is performed- Returns:
- true if the two array items are deep-equal; false if they are not deep equal or if the other item is not an array
- Throws:
XPathException
- if the comparison cannot be performed
-
deepEqual40
public boolean deepEqual40(FunctionItem other, XPathContext context, DeepEqual.DeepEqualOptions options) throws XPathException - Throws:
XPathException
-
effectiveBooleanValue
Get the effective boolean value of this sequence- Returns:
- the effective boolean value
- Throws:
XPathException
- if the sequence has no effective boolean value (for example a sequence of two integers)
-
getUnicodeStringValue
Get the value of the item as a string. For arrays, there is no string value, so an exception is thrown.- Returns:
- the string value of the item
- Throws:
UncheckedXPathException
- if the item is an array (an unchecked exception is used here to avoid introducing exception handling to a large number of paths where it is not needed)- Since:
- 8.4
-
export
Output information about this function item to the diagnostic explain() output- Parameters:
out
- the destination for the information- Throws:
XPathException
- if things go wrong
-
isTrustedResultType
public boolean isTrustedResultType()Description copied from interface:FunctionItem
Ask if the function can be trusted to return a result of the correct type- Returns:
- true if the implementation can be trusted
-
toString
Output a string representation of the array, suitable for diagnostics -
getMemberType
Get the lowest common item type of the members of the array- Specified by:
getMemberType
in classArrayItem
- Parameters:
th
- the type hierarchy- Returns:
- the most specific type to which all the members belong.
-