Class LabeledFunctionItem
- All Implemented Interfaces:
LabeledItem,Callable,FunctionItem,GroundedValue,Item,Sequence
LabeledMapItem represents an XDM map together with a label, which is a map:
the map typically contains retained information about how the map was selected within a JSON-like tree.-
Constructor Summary
ConstructorsConstructorDescriptionLabeledFunctionItem(FunctionItem subject, MapItem label) Create a LabeledFunctionItem with a supplied label -
Method Summary
Modifier and TypeMethodDescriptionatomize()Atomize the item.call(XPathContext context, Sequence[] arguments) Call the Callable.booleandeepEqual40(FunctionItem other, XPathContext context, DeepEqual.DeepEqualOptions options) Test whether this FunctionItem is deep-equal to another function item, under the rules of the deep-equal function in XPath 4.0booleandeepEquals(FunctionItem other, XPathContext context, AtomicMatcher comparer, int flags) Test whether this FunctionItem is deep-equal to another function item, under the rules of the deep-equal functionvoidOutput information about this function item to the diagnostic explain() outputGet the function annotations (as defined in XQuery).intgetArity()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 anonymousgetLabel()Get the label of this value, typically, information about the containing maps and arrays in the containing treeGet the roles of the arguments, for the purposes of streamingGet the subject item without its labelGet the value of the item as a Unicode string.booleanisArray()Ask whether this function item is an arraybooleanisMap()Ask whether this function item is a mapbooleanAsk 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 functionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.saxon.om.FunctionItem
getGenre, isSequenceVariadic, toShortStringMethods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, effectiveBooleanValue, 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
-
Constructor Details
-
LabeledFunctionItem
Create a LabeledFunctionItem with a supplied label- Parameters:
subject- the subject function itemlabel- the label
-
-
Method Details
-
getSubject
Get the subject item without its label- Specified by:
getSubjectin interfaceLabeledItem- Returns:
- the subject item
-
getLabel
Get the label of this value, typically, information about the containing maps and arrays in the containing tree- Specified by:
getLabelin interfaceItem- Specified by:
getLabelin interfaceLabeledItem- Returns:
- the associated
Pedigree.
-
call
Call the Callable.- Specified by:
callin interfaceCallable- Parameters:
context- the dynamic evaluation contextarguments- the values of the arguments, supplied as Sequences.Generally it is advisable, if calling iterate() to process a supplied sequence, to call it only once; if the value is required more than once, it should first be converted to a
GroundedValueby calling the utility method SequenceTool.toGroundedValue().If the expected value is a single item, the item should be obtained by calling Sequence.head(): it cannot be assumed that the item will be passed as an instance of
ItemorAtomicValue.It is the caller's responsibility to perform any type conversions required to convert arguments to the type expected by the callee. An exception is where this Callable is explicitly an argument-converting wrapper around the original Callable.
- Returns:
- the result of the evaluation, in the form of a Sequence. It is the responsibility of the callee to ensure that the type of result conforms to the expected result type.
- Throws:
XPathException- if a dynamic error occurs during the evaluation of the expression
-
isMap
public boolean isMap()Ask whether this function item is a map- Specified by:
isMapin interfaceFunctionItem- Returns:
- true if this function item is a map, otherwise false
-
isArray
public boolean isArray()Ask whether this function item is an array- Specified by:
isArrayin interfaceFunctionItem- Returns:
- true if this function item is an array, otherwise false
-
getFunctionItemType
Get the item type of the function item- Specified by:
getFunctionItemTypein interfaceFunctionItem- Returns:
- the function item's type
-
getFunctionName
Get the name of the function, or null if it is anonymous- Specified by:
getFunctionNamein interfaceFunctionItem- Returns:
- the function name, or null for an anonymous inline function
-
getArity
public int getArity()Get the arity of the function- Specified by:
getArityin interfaceFunctionItem- Returns:
- the number of arguments in the function signature
-
getOperandRoles
Get the roles of the arguments, for the purposes of streaming- Specified by:
getOperandRolesin interfaceFunctionItem- Returns:
- an array of OperandRole objects, one for each argument
-
getAnnotations
Get the function annotations (as defined in XQuery). Returns an empty list if there are no function annotations.- Specified by:
getAnnotationsin interfaceFunctionItem- Returns:
- the function annotations
-
makeNewContext
Prepare an XPathContext object for evaluating the function- Specified by:
makeNewContextin interfaceFunctionItem- 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)
-
deepEquals
public boolean deepEquals(FunctionItem other, XPathContext context, AtomicMatcher comparer, int flags) throws XPathException Test whether this FunctionItem is deep-equal to another function item, under the rules of the deep-equal function- Specified by:
deepEqualsin interfaceFunctionItem- 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 function items are deep-equal
- Throws:
XPathException- if the comparison cannot be performed
-
deepEqual40
public boolean deepEqual40(FunctionItem other, XPathContext context, DeepEqual.DeepEqualOptions options) throws XPathException Description copied from interface:FunctionItemTest whether this FunctionItem is deep-equal to another function item, under the rules of the deep-equal function in XPath 4.0- Specified by:
deepEqual40in interfaceFunctionItem- Parameters:
other- the other function itemcontext- the dynamic evaluation contextoptions- the options supplied to the deep-equal function- Returns:
- true if the two function items are deep-equal
- Throws:
XPathException- if the comparison cannot be performed
-
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 interfaceFunctionItem- Returns:
- a description of the function for use in error messages
-
export
Output information about this function item to the diagnostic explain() output- Specified by:
exportin interfaceFunctionItem- Parameters:
out- the destination for the information- Throws:
XPathException- if things go wrong
-
isTrustedResultType
public boolean isTrustedResultType()Ask if the function can be trusted to return a result of the correct type- Specified by:
isTrustedResultTypein interfaceFunctionItem- Returns:
- true if the implementation can be trusted
-
getUnicodeStringValue
Get the value of the item as a Unicode string. For nodes, this is the string value of the node as defined in the XPath 2.0 data model, except that all nodes are treated as being untyped: it is not an error to get the string value of a node with a complex type. For atomic values, the method returns the result of casting the atomic value to a string.- Specified by:
getUnicodeStringValuein interfaceGroundedValue- Specified by:
getUnicodeStringValuein interfaceItem- Returns:
- the string value of the item
- Throws:
UnsupportedOperationException- if the item is a function item (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
-
atomize
Atomize the item.- Specified by:
atomizein interfaceItem- Returns:
- the result of atomization
- Throws:
XPathException- if atomization is not allowed for this kind of item
-