Package net.sf.saxon.functions.hof
Class FunctionLiteral
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.Literal
-
- net.sf.saxon.functions.hof.FunctionLiteral
-
- All Implemented Interfaces:
ExportAgent,Locatable,IdentityComparable,Traceable
public class FunctionLiteral extends Literal
A FunctionLiteral is a wrapper around a FunctionItem; it is an expression, whose value is the function that it wraps. Note that a FunctionLiteral can be used only where the binding to a specific function is statically known. This works for constructor functions, for system functions that have no context dependency, and for references to user function (my:f#2) in XQuery, but not in XSLT where the reference cannot be fully resolved until separately-compiled packages are linked. In other cases aUserFunctionReferenceis used.
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
-
-
Constructor Summary
Constructors Constructor Description FunctionLiteral(Function value)Create a literal as a wrapper around a Value
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcomputeCardinality()Determine the cardinalityintcomputeHashCode()Return a hash code to support the equals() functionintcomputeSpecialProperties()Compute the static properties of this expression (other than its type).Expressioncopy(RebindingMap rebindings)Copy an expression.booleanequals(java.lang.Object obj)Determine whether two literals are equal, when considered as expressions.voidexport(ExpressionPresenter out)Diagnostic print of expression structure.java.lang.StringgetExpressionName()Get a name identifying the kind of expression, in terms meaningful to a user.FunctionItemTypegetItemType()Determine the data type of the items in the expression, if possibleFunctiongetValue()Get the value represented by this LiteralbooleanisVacuousExpression()Determine whether this is a vacuous expression as defined in the XQuery update specificationvoidsetRetainedStaticContext(RetainedStaticContext rsc)Set the retained static contextExpressionsimplify()Simplify an expressionExpressiontypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)TypeCheck an expression-
Methods inherited from class net.sf.saxon.expr.Literal
addToPathMap, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, exportAtomicValue, exportValue, getDependencies, getImplementationMethod, getIntegerBounds, getNetCost, getStaticUType, getStreamerName, hasEffectiveBooleanValue, isAtomic, isConstantBoolean, isConstantOne, isEmptySequence, isSubtreeExpression, iterate, iterate, makeEmptySequence, makeLiteral, makeLiteral, makeStringsLiteral, optimize, process, toPattern, toShortString, toString
-
Methods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, explain, getCardinality, getConfiguration, getCost, getEvaluationMethod, getExtraProperty, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isUpdatingExpression, markTailFunctionCalls, operandList, operands, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, suppressValidation, typeCheckChildren, typeError, unordered, verifyParentPointers
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
-
-
-
Constructor Detail
-
FunctionLiteral
public FunctionLiteral(Function value)
Create a literal as a wrapper around a Value- Parameters:
value- the value of this literal
-
-
Method Detail
-
getValue
public Function getValue()
Get the value represented by this Literal
-
simplify
public Expression simplify() throws XPathException
Simplify an expression- Overrides:
simplifyin classExpression- Returns:
- for a Value, this always returns the value unchanged
- Throws:
XPathException- if an error is discovered during expression rewriting
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
TypeCheck an expression- Overrides:
typeCheckin classLiteral- Parameters:
visitor- an expression visitorcontextInfo- Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.- Returns:
- for a Value, this always returns the value unchanged
- Throws:
XPathException- if an error is discovered during this phase (typically a type error)
-
getItemType
public FunctionItemType getItemType()
Determine the data type of the items in the expression, if possible- Overrides:
getItemTypein classLiteral- Returns:
- for the default implementation: AnyItemType (not known)
-
computeCardinality
public int computeCardinality()
Determine the cardinality- Overrides:
computeCardinalityin classLiteral- Returns:
- the computed cardinality, as one of the values
StaticProperty.ALLOWS_ZERO_OR_ONE,StaticProperty.EXACTLY_ONE,StaticProperty.ALLOWS_ONE_OR_MORE,StaticProperty.ALLOWS_ZERO_OR_MORE. May also returnStaticProperty.ALLOWS_ZEROif the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANYif if is known to return a sequence of length two or more.
-
computeSpecialProperties
public int computeSpecialProperties()
Compute the static properties of this expression (other than its type). For a Value, the only special property isStaticProperty.NO_NODES_NEWLY_CREATED.- Overrides:
computeSpecialPropertiesin classLiteral- Returns:
- the value
StaticProperty.NO_NODES_NEWLY_CREATED
-
isVacuousExpression
public boolean isVacuousExpression()
Determine whether this is a vacuous expression as defined in the XQuery update specification- Overrides:
isVacuousExpressionin classLiteral- Returns:
- true if this expression is vacuous
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.
-
setRetainedStaticContext
public void setRetainedStaticContext(RetainedStaticContext rsc)
Set the retained static context- Overrides:
setRetainedStaticContextin classExpression- Parameters:
rsc- the static context to be retained
-
equals
public boolean equals(java.lang.Object obj)
Determine whether two literals are equal, when considered as expressions.- Overrides:
equalsin classLiteral- Parameters:
obj- the other expression- Returns:
- true if the two literals are equal. The test here requires (a) identity in the sense defined by XML Schema (same value in the same value space), and (b) identical type annotations. For example the literal xs:int(3) is not equal (as an expression) to xs:short(3), because the two expressions are not interchangeable.
-
computeHashCode
public int computeHashCode()
Return a hash code to support the equals() function- Overrides:
computeHashCodein classLiteral- Returns:
- a computed hash code
-
getExpressionName
public java.lang.String getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionNamein classLiteral- Returns:
- a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in export() output displaying the expression.
-
export
public void export(ExpressionPresenter out) throws XPathException
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
exportin interfaceExportAgent- Overrides:
exportin classLiteral- Parameters:
out- the expression presenter used to display the structure- Throws:
XPathException- if the export fails, for example if an expression is found that won't work in the target environment.
-
-