Package net.sf.saxon.ma.arrays
Class AbstractArrayItem
- java.lang.Object
-
- net.sf.saxon.ma.arrays.AbstractArrayItem
-
- Direct Known Subclasses:
DelegatingArrayItem,ImmutableArrayItem,SimpleArrayItem
public abstract class AbstractArrayItem extends java.lang.Object implements ArrayItem
An abstract implementation of XDM array items, containing methods that can be implemented generically.
-
-
Field Summary
-
Fields inherited from interface net.sf.saxon.ma.arrays.ArrayItem
SINGLE_ARRAY_TYPE
-
-
Constructor Summary
Constructors Constructor Description AbstractArrayItem()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AtomicSequenceatomize()Atomize the item.GroundedValuecall(XPathContext context, Sequence[] args)Invoke the array in its role as a functionbooleandeepEquals(Function other, XPathContext context, AtomicComparer comparer, int flags)Test whether this array is deep-equal to another array, under the rules of the deep-equal functionbooleaneffectiveBooleanValue()Get the effective boolean value of this sequencevoidexport(ExpressionPresenter out)Output information about this function item to the diagnostic explain() outputAnnotationListgetAnnotations()Get the function annotations (as defined in XQuery).intgetArity()Get the arity of the functionjava.lang.StringgetDescription()Get a description of this function for use in error messages.FunctionItemTypegetFunctionItemType()Get the item type of the function itemStructuredQNamegetFunctionName()Get the name of the function, or null if it is anonymousSequenceTypegetMemberType(TypeHierarchy th)Get the lowest common item type of the members of the arrayOperandRole[]getOperandRoles()Get the roles of the arguments, for the purposes of streamingjava.lang.StringgetStringValue()Get the value of the item as a string.java.lang.CharSequencegetStringValueCS()Get the value of the item as a CharSequence.booleanisArray()Ask whether this function item is an arraybooleanisMap()Ask whether this function item is a mapbooleanisTrustedResultType()Check that result type is of the trusted system functions to return a result of the correct typeXPathContextmakeNewContext(XPathContext callingContext, ContextOriginator originator)Prepare an XPathContext object for evaluating the functionjava.lang.StringtoString()Output a string representation of the array, suitable for diagnostics-
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
arrayLength, concat, get, getGenre, insert, isEmpty, members, put, remove, removeSeveral, subArray, 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
-
-
-
-
Method Detail
-
getOperandRoles
public OperandRole[] getOperandRoles()
Get the roles of the arguments, for the purposes of streaming- Specified by:
getOperandRolesin interfaceFunction- Returns:
- an array of OperandRole objects, one for each argument
-
isArray
public boolean isArray()
Ask whether this function item is an array
-
isMap
public boolean isMap()
Ask whether this function item is a map
-
atomize
public AtomicSequence atomize() throws XPathException
Atomize the item.- Specified by:
atomizein interfaceItem- Returns:
- the result of atomization
- Throws:
XPathException- if atomization is not allowed for this kind of item
-
getAnnotations
public AnnotationList getAnnotations()
Get the function annotations (as defined in XQuery). Returns an empty list if there are no function annotations.- Specified by:
getAnnotationsin interfaceFunction- Returns:
- the function annotations
-
getFunctionItemType
public FunctionItemType getFunctionItemType()
Get the item type of the function item- Specified by:
getFunctionItemTypein interfaceFunction- Returns:
- the function item's type
-
getFunctionName
public StructuredQName getFunctionName()
Get the name of the function, or null if it is anonymous- Specified by:
getFunctionNamein interfaceFunction- Returns:
- the function name, or null for an anonymous function (which this one is)
-
getDescription
public java.lang.String 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".- Specified by:
getDescriptionin interfaceFunction- Returns:
- a description of the function for use in error messages
-
getArity
public int getArity()
Get the arity of the function
-
makeNewContext
public XPathContext makeNewContext(XPathContext callingContext, ContextOriginator originator)
Prepare an XPathContext object for evaluating the function- Specified by:
makeNewContextin interfaceFunction- Parameters:
callingContext- the XPathContext of the function calling expressionoriginator-- Returns:
- a suitable context for evaluating the function (which may or may not be the same as the caller's context)
-
call
public GroundedValue call(XPathContext context, Sequence[] args) throws XPathException
Invoke the array in its role as a function- Specified by:
callin interfaceCallable- Specified by:
callin interfaceFunction- Parameters:
context- the XPath dynamic evaluation contextargs- the actual arguments to be supplied (a single integer, one-based)- Returns:
- the result of invoking the function
- Throws:
XPathException- if the index is out of bounds
-
deepEquals
public boolean deepEquals(Function 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- Specified by:
deepEqualsin interfaceFunction- 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
-
effectiveBooleanValue
public boolean effectiveBooleanValue() throws XPathExceptionGet the effective boolean value of this sequence- Specified by:
effectiveBooleanValuein interfaceGroundedValue- Returns:
- the effective boolean value
- Throws:
XPathException- if the sequence has no effective boolean value (for example a sequence of two integers)
-
getStringValue
public java.lang.String getStringValue()
Get the value of the item as a string. For arrays, there is no string value, so an exception is thrown.- Specified by:
getStringValuein interfaceGroundedValue- Specified by:
getStringValuein interfaceItem- Returns:
- the string value of the item
- Throws:
java.lang.UnsupportedOperationException- 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
- See Also:
getStringValueCS()
-
getStringValueCS
public java.lang.CharSequence getStringValueCS()
Get the value of the item as a CharSequence. For arrays, there is no string value, so an exception is thrown.- Specified by:
getStringValueCSin interfaceGroundedValue- Specified by:
getStringValueCSin interfaceItem- Returns:
- the string value of the item
- Throws:
java.lang.UnsupportedOperationException- 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
- See Also:
getStringValueCS()
-
export
public void export(ExpressionPresenter out) throws XPathException
Output information about this function item to the diagnostic explain() output- Specified by:
exportin interfaceFunction- Throws:
XPathException
-
isTrustedResultType
public boolean isTrustedResultType()
Description copied from interface:FunctionCheck that result type is of the trusted system functions to return a result of the correct type- Specified by:
isTrustedResultTypein interfaceFunction
-
toString
public java.lang.String toString()
Output a string representation of the array, suitable for diagnostics- Overrides:
toStringin classjava.lang.Object
-
getMemberType
public SequenceType getMemberType(TypeHierarchy th)
Get the lowest common item type of the members of the array- Specified by:
getMemberTypein interfaceArrayItem- Returns:
- the most specific type to which all the members belong.
-
-