Package net.sf.saxon.expr
Class UnionConstructorFunction
java.lang.Object
net.sf.saxon.functions.AbstractFunction
net.sf.saxon.expr.UnionConstructorFunction
- All Implemented Interfaces:
Callable
,FunctionItem
,GroundedValue
,Item
,Sequence
- Direct Known Subclasses:
UnionCastableFunction
Function to perform a cast to a union type
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected NamespaceResolver
protected UnionType
-
Constructor Summary
ConstructorsConstructorDescriptionUnionConstructorFunction
(UnionType targetType, NamespaceResolver resolver, boolean allowEmpty) Create a cast expression to a union type -
Method Summary
Modifier and TypeMethodDescriptioncall
(XPathContext context, Sequence[] args) Invoke the functioncast
(AtomicValue value, XPathContext context) Method to perform the cast of an atomic value to a union typestatic AtomicSequence
cast
(AtomicValue value, UnionType targetType, NamespaceResolver nsResolver, ConversionRules rules) Static method to perform the cast of an atomic value to a union typeint
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 namespace resolver that will be used to resolve any namespace-sensitive values (such as QNames) when castingprotected OperandRole
Get the usage (in terms of streamability analysis) of the single operandGet the union type that is the target of this cast operationboolean
Ask whether the value of the operand is allowed to be emptyMethods inherited from class net.sf.saxon.functions.AbstractFunction
atomize, deepEqual40, deepEquals, effectiveBooleanValue, export, getAnnotations, getOperandRoles, getUnicodeStringValue, isArray, isMap, isTrustedResultType, makeNewContext, simplify, toShortString, typeCheck
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.FunctionItem
getGenre, 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
-
Field Details
-
targetType
-
resolver
-
allowEmpty
protected boolean allowEmpty
-
-
Constructor Details
-
UnionConstructorFunction
public UnionConstructorFunction(UnionType targetType, NamespaceResolver resolver, boolean allowEmpty) Create a cast expression to a union type- Parameters:
targetType
- the union type that is the result of the castresolver
- used for resolving namespace prefixes if the type is namespace-sensitiveallowEmpty
- true if an empty sequence may be supplied as input, converting to an empty sequence on output
-
-
Method Details
-
getOperandRole
Get the usage (in terms of streamability analysis) of the single operand- Returns:
- the operand usage
-
isAllowEmpty
public boolean isAllowEmpty()Ask whether the value of the operand is allowed to be empty- Returns:
- true if an empty sequence may be supplied as input, converting to an empty sequence on output
-
getTargetType
Get the union type that is the target of this cast operation- Returns:
- the target type of the cast
-
getNamespaceResolver
Get the namespace resolver that will be used to resolve any namespace-sensitive values (such as QNames) when casting- Returns:
- the namespace resolver, or null if there is none.
-
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 inline function
-
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
-
cast
Method to perform the cast of an atomic value to a union type- Parameters:
value
- the input value to be converted. Must not be null.context
- the evaluation context- Returns:
- the result of the conversion (may be a sequence if the union includes list types in its membership)
- Throws:
XPathException
- if the conversion fails
-
call
Invoke the function- Parameters:
context
- the XPath dynamic evaluation contextargs
- the actual arguments to be supplied- Returns:
- the result of invoking the function
- Throws:
XPathException
- if a dynamic error occurs within the function
-
cast
public static AtomicSequence cast(AtomicValue value, UnionType targetType, NamespaceResolver nsResolver, ConversionRules rules) throws XPathException Static method to perform the cast of an atomic value to a union type- Parameters:
value
- the input value to be converted. Must not be null.targetType
- the union type to which the value is to be convertednsResolver
- the namespace context, required if the type is namespace-sensitiverules
- the conversion rules- Returns:
- the result of the conversion (may be a sequence if the union includes list types in its membership)
- Throws:
XPathException
- if the conversion fails
-