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
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 a
UserFunctionReference is used.-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.saxon.expr.Literal
Literal.LiteralElaborator -
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
ConstructorsConstructorDescriptionFunctionLiteral(FunctionItem value) Create a literal as a wrapper around a Value -
Method Summary
Modifier and TypeMethodDescriptionprotected intDetermine the cardinalityprotected intReturn a hash code to support the equals() functionprotected intCompute the static properties of this expression (other than its type).copy(RebindingMap rebindings) Copy an expression.booleanDetermine whether two literals are equal, when considered as expressions.voidDiagnostic print of expression structure.Get a name identifying the kind of expression, in terms meaningful to a user.Get the value represented by this LiteralDetermine the data type of the items in the expression, if possiblebooleanDetermine whether this is a vacuous expression as defined in the XQuery update specificationvoidSet the retained static contextsimplify()Simplify an expressiontypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) TypeCheck an expressionMethods inherited from class net.sf.saxon.expr.Literal
addToPathMap, effectiveBooleanValue, evaluateAsString, evaluateItem, exportAtomicValue, exportValue, getDependencies, getElaborator, getImplementationMethod, getIntegerBounds, getNetCost, getStaticUType, getStreamerName, hasEffectiveBooleanValue, isAtomic, isConstantBoolean, isConstantOne, isConstantZero, isEmptySequence, isInstance, isSubtreeExpression, iterate, iterate, makeEmptySequence, makeLiteral, makeLiteral, optimize, process, supportsLazyEvaluation, toPattern, toShortString, toStringMethods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dispatchTailCall, dynamicError, explain, getCardinality, getConfiguration, getCost, getEvaluationMethod, getExtraProperty, 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, makeElaborator, markTailFunctionCalls, operandList, operands, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, suppressValidation, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocationMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
Constructor Details
-
FunctionLiteral
Create a literal as a wrapper around a Value- Parameters:
value- the value of this literal
-
-
Method Details
-
getGroundedValue
Get the value represented by this Literal- Overrides:
getGroundedValuein classLiteral- Returns:
- the constant value
-
simplify
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
Determine the data type of the items in the expression, if possible- Overrides:
getItemTypein classLiteral- Returns:
- for the default implementation: AnyItemType (not known)
-
computeCardinality
protected 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
protected 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
Copy an expression. This makes a deep copy. -
setRetainedStaticContext
Set the retained static context- Overrides:
setRetainedStaticContextin classExpression- Parameters:
rsc- the static context to be retained
-
equals
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
protected int computeHashCode()Return a hash code to support the equals() function- Overrides:
computeHashCodein classLiteral- Returns:
- a computed hash code
-
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
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.
-