public abstract class SystemFunction extends AbstractFunction
Constructor and Description |
---|
SystemFunction() |
Modifier and Type | Method and Description |
---|---|
boolean |
dependsOnContextItem()
Ask whether the result of the function depends on the context item
|
static Sequence<?> |
dynamicCall(Function f,
XPathContext context,
Sequence[] args)
Make a dynamic call to a supplied argument function (convenience method for use by implementations)
|
boolean |
equals(java.lang.Object o)
Determine whether two functions are equivalent
|
void |
export(ExpressionPresenter out)
Diagnostic print of expression structure.
|
void |
exportAdditionalArguments(SystemFunctionCall call,
ExpressionPresenter out)
Export any implicit arguments held in optimized form within the SystemFunction call
|
void |
exportAttributes(ExpressionPresenter out)
Export any context attributes held within the SystemFunction object.
|
Expression |
fixArguments(Expression... arguments)
Optimize for constant argument values
|
int |
getArity()
Get the arity of the function (the number of arguments).
|
int |
getCardinality(Expression[] args)
Get the cardinality, given knowledge of the actual arguments
|
java.lang.String |
getCompilerName()
Get the (local) name of a class that can be used to generate bytecode for this
system function
|
protected NodeInfo |
getContextNode(XPathContext context)
Helper method for subclasses: get the context item if it is a node, throwing appropriate errors
if not
|
java.lang.String |
getDescription()
Get a description of this function for use in error messages.
|
BuiltInFunctionSet.Entry |
getDetails()
Get the details of the function signature
|
java.lang.String |
getErrorCodeForTypeErrors()
Return the error code to be used for type errors.
|
FunctionItemType |
getFunctionItemType()
Get the item type of the function item
|
StructuredQName |
getFunctionName()
Get the qualified name of the function being called
|
IntegerValue[] |
getIntegerBounds()
For a function that returns an integer or a sequence of integers, get
a lower and upper bound on the values of the integers that may be returned, from
static analysis.
|
int |
getNetCost()
Get an estimate of the net cost of evaluating the function, excluding the cost of evaluating
its arguments.
|
OperandRole[] |
getOperandRoles()
Get the roles of the arguments, for the purposes of streaming
|
SequenceType |
getRequiredType(int arg)
Get the required type of the nth argument
|
ItemType |
getResultItemType()
Determine the item type of the value returned by the function
|
ItemType |
getResultItemType(Expression[] args)
Get the return type, given knowledge of the actual arguments
|
RetainedStaticContext |
getRetainedStaticContext()
Get the static context in which the function operates, for use with functions whose result
depends on the static context
|
int |
getSpecialProperties(Expression[] arguments)
Determine the special properties of this function.
|
java.lang.String |
getStaticBaseUriString() |
java.lang.String |
getStreamerName()
Get a name that identifies the class that can be used to evaluate this function
in streaming mode, that is, supplying one item or event at a time as it is
delivered by the parser.
|
void |
importAttributes(java.util.Properties attributes)
Import any attributes found in the export file, that is, any attributes output using
the exportAttributes method
|
boolean |
isTrustedResultType()
Check that result type is SystemFunction or AtomicConstructorFunction
|
static Expression |
makeCall(java.lang.String name,
RetainedStaticContext rsc,
Expression... arguments)
Make a system function call (one in the standard function namespace).
|
static SystemFunction |
makeFunction(java.lang.String name,
RetainedStaticContext rsc,
int arity)
Make a system function item (one in the standard function namespace).
|
Expression |
makeFunctionCall(Expression... arguments)
Make an expression that either calls this function, or that is equivalent to a call
on this function
|
Expression |
makeOptimizedFunctionCall(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo,
Expression... arguments)
Allow the function to create an optimized call based on the values of the actual arguments
|
protected Sequence<?> |
resultIfEmpty(int arg)
Ask if the function always returns a known result when one of the arguments is an empty sequence
|
void |
setArity(int arity)
Set the arity of the function
|
void |
setDetails(BuiltInFunctionSet.Entry entry)
Set the details of this type of function
|
void |
setRetainedStaticContext(RetainedStaticContext retainedStaticContext)
Set the static context in which the function operates, for use with functions whose result
depends on the static context
|
void |
supplyTypeInformation(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType,
Expression[] arguments)
Method called during static type checking.
|
java.lang.String |
toShortString()
Provide a short string showing the contents of the item, suitable
for use in error messages
|
java.lang.String |
toString() |
Expression |
typeCheckCaller(FunctionCall caller,
ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Typecheck a call on this function
|
atomize, deepEquals, effectiveBooleanValue, getAnnotations, getStringValue, getStringValueCS, isArray, isMap, makeNewContext, simplify, typeCheck
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
argumentArray, call, getGenre
getLength, head, isStreamed, itemAt, iterate, iterator, reduce, subsequence, toGroundedValue
asIterable, materialize
makeRepeatable
public static Expression makeCall(java.lang.String name, RetainedStaticContext rsc, Expression... arguments)
name
- The local name of the function.rsc
- Necessary information about the static contextarguments
- the arguments to the function callpublic static SystemFunction makeFunction(java.lang.String name, RetainedStaticContext rsc, int arity)
name
- The local name of the function.rsc
- Necessary information about the static contextarity
- the arity of the functionpublic Expression makeFunctionCall(Expression... arguments)
arguments
- the supplied arguments to the function callpublic void setArity(int arity)
arity
- the number of argumentspublic int getNetCost()
public Expression makeOptimizedFunctionCall(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo, Expression... arguments) throws XPathException
visitor
- the expression visitorcontextInfo
- information about the context itemarguments
- the supplied arguments to the function call. Note: modifying the contents
of this array should not be attempted, it is likely to have no effect.XPathException
- if an error is detectedpublic Expression fixArguments(Expression... arguments) throws XPathException
XPathException
protected Sequence<?> resultIfEmpty(int arg)
arg
- the argument whose value is an empty sequence (counting from zero)public RetainedStaticContext getRetainedStaticContext()
public void setRetainedStaticContext(RetainedStaticContext retainedStaticContext)
retainedStaticContext
- the retained static contextpublic boolean dependsOnContextItem()
public void setDetails(BuiltInFunctionSet.Entry entry)
entry
- information giving details of the function signature and other function propertiespublic BuiltInFunctionSet.Entry getDetails()
public StructuredQName getFunctionName()
public java.lang.String getDescription()
public int getArity()
public OperandRole[] getOperandRoles()
getOperandRoles
in interface Function
getOperandRoles
in class AbstractFunction
public IntegerValue[] getIntegerBounds()
public void supplyTypeInformation(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType, Expression[] arguments) throws XPathException
visitor
- an expression visitor, providing access to the static context and configurationcontextItemType
- information about whether the context item is set, and what its type isarguments
- the expressions appearing as arguments in the function callXPathException
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String getErrorCodeForTypeErrors()
public SequenceType getRequiredType(int arg)
arg
- the number of the argument whose type is requested, zero-basedpublic ItemType getResultItemType()
public FunctionItemType getFunctionItemType()
public ItemType getResultItemType(Expression[] args)
args
- the actual arguments suppliedpublic int getCardinality(Expression[] args)
args
- the actual arguments suppliedpublic int getSpecialProperties(Expression[] arguments)
arguments
- the actual arguments supplied in a call to the functionprotected NodeInfo getContextNode(XPathContext context) throws XPathException
context
- the XPath dynamic contextXPathException
- if there is no context item or if the context item is not a nodepublic static Sequence<?> dynamicCall(Function f, XPathContext context, Sequence[] args) throws XPathException
context
- the XPath dynamic evaluation contextargs
- the actual arguments to be suppliedXPathException
- if a dynamic error occurs within the functionpublic void export(ExpressionPresenter out) throws XPathException
export
in interface Function
export
in class AbstractFunction
XPathException
public Expression typeCheckCaller(FunctionCall caller, ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
XPathException
public boolean isTrustedResultType()
AbstractFunction
isTrustedResultType
in interface Function
isTrustedResultType
in class AbstractFunction
public java.lang.String getStaticBaseUriString()
public void exportAttributes(ExpressionPresenter out)
out
- the export destinationpublic void exportAdditionalArguments(SystemFunctionCall call, ExpressionPresenter out) throws XPathException
out
- the export destinationXPathException
public void importAttributes(java.util.Properties attributes) throws XPathException
attributes
- the attributes, as a properties objectXPathException
public java.lang.String getCompilerName()
public java.lang.String getStreamerName()
StreamerMap
. In non-streaming Saxon editions
(HE and PE) the method always returns null.public java.lang.String toShortString()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.