Package net.sf.saxon.type
Class SpecificFunctionType
java.lang.Object
net.sf.saxon.type.AnyFunctionType
net.sf.saxon.type.SpecificFunctionType
- All Implemented Interfaces:
FunctionItemType,ItemType
An instance of this class represents a specific function item type, for example
function(xs:int) as xs:boolean
-
Field Summary
FieldsFields inherited from class net.sf.saxon.type.AnyFunctionType
INSTANCE -
Constructor Summary
ConstructorsConstructorDescriptionSpecificFunctionType(SequenceType... types) Convenience variadic constructorSpecificFunctionType(SequenceType[] argTypes, SequenceType resultType) Construct a specific function typeSpecificFunctionType(SequenceType[] argTypes, SequenceType resultType, AnnotationList annotations) Construct a specific function type including function annotations -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsReducedArityFunction(ItemType supplied) Ask whether a function of a supplied type is acceptable, despite not being an exact match, without needing to be wrapped in aCoercedFunctionbooleanTest whether this function type equals another function typeexplainMismatch(Item item, TypeHierarchy th) Get extra diagnostic information about why a supplied item does not conform to this item type, if available.Get the list of annotation assertions defined on this function item type.Get the argument typesintgetArity()Get the arity (number of arguments) of this function typegetCoercionPlan(int version) Get the coercion plan for use when this type is the required type for (say) coercion of arguments in a function calldoubleGet the default priority when this ItemType is used as an XSLT patternGet the result typeinthashCode()Returns a hash code value for the object.booleanbooleanAsk whether values of this type are atomizablemakeFunctionSequenceCoercer(Expression exp, Supplier<RoleDiagnostic> role, boolean allow40) Create an expression whose effect is to apply function coercion to coerce a function from this type to another typebooleanTest whether a given item conforms to this typerelationship(FunctionItemType other) Determine the relationship of one function item type to another.Return a string representation of this ItemType suitable for use in stylesheet export files.toString()Produce a representation of this type name for use in error messages.Indicate that this function type describes a callback function, and that the caller of this callback is prepared to accept a reduced-arity version of the function directly, without needing it to be wrapped in aCoercedFunctionthat accepts and swallows the superfluous arguments.Methods inherited from class net.sf.saxon.type.AnyFunctionType
getAtomizedItemType, getBasicAlphaCode, getPrimitiveItemType, getPrimitiveType, getUType, isArrayType, isAtomicType, isMapType, isPlainTypeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.type.FunctionItemType
getGenreMethods inherited from interface net.sf.saxon.type.ItemType
asChoiceItemType, getNormalizedDefaultPriority, normalizeItemType
-
Field Details
-
COMPONENT_FUNCTION_TYPE
-
-
Constructor Details
-
SpecificFunctionType
Construct a specific function type- Parameters:
argTypes- the types of the arguments to the functionresultType- the type of the function result
-
SpecificFunctionType
public SpecificFunctionType(SequenceType[] argTypes, SequenceType resultType, AnnotationList annotations) Construct a specific function type including function annotations- Parameters:
argTypes- the types of the arguments to the functionresultType- the type of the function resultannotations- the function annotations
-
SpecificFunctionType
Convenience variadic constructor- Parameters:
types- the argument types, followed by the result type
-
-
Method Details
-
getArity
public int getArity()Get the arity (number of arguments) of this function type- Returns:
- the number of argument types in the function signature
-
withAcceptReducedArity
Indicate that this function type describes a callback function, and that the caller of this callback is prepared to accept a reduced-arity version of the function directly, without needing it to be wrapped in aCoercedFunctionthat accepts and swallows the superfluous arguments. This is useful where it means that the caller does not need to compute additional argument values just for them to be ignored.- Returns:
- this, after setting the
acceptReducedArityflag.
-
isAcceptReducedArity
public boolean isAcceptReducedArity() -
acceptsReducedArityFunction
Ask whether a function of a supplied type is acceptable, despite not being an exact match, without needing to be wrapped in aCoercedFunction- Parameters:
supplied- the item type of a supplied function- Returns:
- true if the caller is able to call the supplied function without further wrapping
-
getArgumentTypes
Get the argument types- Specified by:
getArgumentTypesin interfaceFunctionItemType- Overrides:
getArgumentTypesin classAnyFunctionType- Returns:
- the list of argument types
-
getResultType
Get the result type- Specified by:
getResultTypein interfaceFunctionItemType- Overrides:
getResultTypein classAnyFunctionType- Returns:
- the result type
-
getAnnotationAssertions
Get the list of annotation assertions defined on this function item type.- Specified by:
getAnnotationAssertionsin interfaceFunctionItemType- Overrides:
getAnnotationAssertionsin classAnyFunctionType- Returns:
- the list of annotation assertions, or an empty list if there are none
-
isAtomizable
Ask whether values of this type are atomizable- Specified by:
isAtomizablein interfaceItemType- Overrides:
isAtomizablein classAnyFunctionType- Parameters:
th- The type hierarchy cache- Returns:
- true if some or all instances of this type can be successfully atomized; false * if no instances of this type can be atomized
-
toString
Produce a representation of this type name for use in error messages.- Overrides:
toStringin classAnyFunctionType- Returns:
- a string representation of the type, in notation resembling but not necessarily identical to XPath syntax
-
toExportString
Description copied from interface:ItemTypeReturn a string representation of this ItemType suitable for use in stylesheet export files. This differs from the result of toString() in that it will not contain any references to anonymous types. Note that it may also use the Saxon extended syntax for union types and tuple types. The default implementation returns the result of callingtoString().- Returns:
- the string representation as an instance of the XPath SequenceType construct
-
equals
Test whether this function type equals another function type -
hashCode
public int hashCode()Returns a hash code value for the object. -
relationship
Determine the relationship of one function item type to another. This method is only concerned with the type signatures of the two function item types, and not with their annotation assertions.- Specified by:
relationshipin interfaceFunctionItemType- Overrides:
relationshipin classAnyFunctionType- Parameters:
other- the other function item type- Returns:
- for example
Affinity.SUBSUMES,Affinity.SAME_TYPE
-
getDefaultPriority
public double getDefaultPriority()Get the default priority when this ItemType is used as an XSLT pattern- Specified by:
getDefaultPriorityin interfaceItemType- Overrides:
getDefaultPriorityin classAnyFunctionType- Returns:
- the default priority
-
matches
Test whether a given item conforms to this type- Specified by:
matchesin interfaceItemType- Overrides:
matchesin classAnyFunctionType- Parameters:
item- The item to be tested- Returns:
- true if the item is an instance of this type; false otherwise
-
explainMismatch
Get extra diagnostic information about why a supplied item does not conform to this item type, if available. If extra information is returned, it should be in the form of a complete sentence, minus the closing full stop. No information should be returned for obvious cases.- Specified by:
explainMismatchin interfaceItemType- Overrides:
explainMismatchin classAnyFunctionType- Parameters:
item- the item that doesn't match this typeth- the type hierarchy cache- Returns:
- optionally, a message explaining why the item does not match the type
-
makeFunctionSequenceCoercer
public Expression makeFunctionSequenceCoercer(Expression exp, Supplier<RoleDiagnostic> role, boolean allow40) Description copied from class:AnyFunctionTypeCreate an expression whose effect is to apply function coercion to coerce a function from this type to another type- Specified by:
makeFunctionSequenceCoercerin interfaceFunctionItemType- Overrides:
makeFunctionSequenceCoercerin classAnyFunctionType- Parameters:
exp- the expression that delivers the supplied sequence of function items (the ones in need of coercion)role- information for use in diagnosticsallow40-- Returns:
- the sequence of coerced functions, each on a function that calls the corresponding original function after checking the parameters
-
getCoercionPlan
Get the coercion plan for use when this type is the required type for (say) coercion of arguments in a function call- Specified by:
getCoercionPlanin interfaceItemType- Overrides:
getCoercionPlanin classAnyFunctionType- Parameters:
version- the XPath language version (40 or 31)
-