Package net.sf.saxon.expr
Class SimpleExpression
java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.expr.SimpleExpression
- All Implemented Interfaces:
Callable,ExportAgent,Locatable,IdentityComparable,Traceable
- Direct Known Subclasses:
SQLConnect.ConnectInstruction
An abstract implementation of Expression designed to make it easy to implement new expressions,
in particular, expressions to support extension instructions.
An implementation of this class must supply the Callable.call(XPathContext, net.sf.saxon.om.Sequence[])
method to evaluate the expression and return its result.
-
Nested Class Summary
Nested Classes -
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected intDetermine the static cardinality of the expression.copy(RebindingMap rebindings) Copy an expression.protected SimpleExpressionHelper method for subclasses to implement the copy() operation: this method can be applied to the new expression to copy operands from the old expressionsfinal ItemevaluateItem(XPathContext context) Evaluate an expression as a single item.voidexport(ExpressionPresenter destination) Diagnostic print of expression structure.Make an elaborator for this expressionReturn a distinguishing name for the expression, for use in diagnostics.Determine the data type of the items returned by this expression.protected OperandArrayGet the data structure holding the operands of this expression.final SequenceIteratoriterate(XPathContext context) Return an Iterator to iterate over the values of a sequence.operands()Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.final voidprocess(Outputter output, XPathContext context) Process the instruction, without returning any tail callsvoidsetArguments(Expression[] sub) Set the immediate sub-expressions of this expression.protected voidsetOperanda(OperandArray operanda) Set the data structure for the operands of this expression.Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeSpecialProperties, computeStaticProperties, dispatchTailCall, dynamicError, effectiveBooleanValue, equals, evaluateAsString, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExpressionName, getExtraProperty, getImplementationMethod, getIntegerBounds, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimize, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, toShortString, toString, typeCheck, 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
-
SimpleExpression
public SimpleExpression()Constructor
-
-
Method Details
-
setOperanda
Set the data structure for the operands of this expression. This must be created during initialisation of the expression and must not be subsequently changed- Parameters:
operanda- the data structure for expression operands
-
getOperanda
Get the data structure holding the operands of this expression.- Returns:
- the data structure holding expression operands
-
operands
Description copied from class:ExpressionGet the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.
- Overrides:
operandsin classExpression- Returns:
- an iterator containing the sub-expressions of this expression
-
setArguments
Set the immediate sub-expressions of this expression.- Parameters:
sub- an array containing the sub-expressions of this expression
-
copy
Copy an expression. This makes a deep copy.- Specified by:
copyin classExpression- Parameters:
rebindings- variables that need to be re-bound- Returns:
- the copy of the original expression
-
simpleCopy
-
copyOperandsFrom
Helper method for subclasses to implement the copy() operation: this method can be applied to the new expression to copy operands from the old expressions- Parameters:
se1- the expression being copied- Returns:
- the target object of this method (for convenience)
-
getItemType
Determine the data type of the items returned by this expression. This implementation returns "item()", which can be overridden in a subclass.- Specified by:
getItemTypein classExpression- Returns:
- the data type
-
computeCardinality
protected int computeCardinality()Determine the static cardinality of the expression. This implementation returns "zero or more", which can be overridden in a subclass.- Specified by:
computeCardinalityin classExpression- 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.
-
evaluateItem
Evaluate an expression as a single item. This always returns either a single Item or null (denoting the empty sequence). No conversion is done. This method should not be used unless the static type of the expression is a subtype of "item" or "item?": that is, it should not be called if the expression may return a sequence. There is no guarantee that this condition will be detected.- Overrides:
evaluateItemin classExpression- Parameters:
context- The context in which the expression is to be evaluated- Returns:
- the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
- Throws:
XPathException- if any dynamic error occurs evaluating the expression
-
iterate
Return an Iterator to iterate over the values of a sequence. The value of every expression can be regarded as a sequence, so this method is supported for all expressions. This default implementation handles iteration for expressions that return singleton values: for non-singleton expressions, the subclass must provide its own implementation.- Overrides:
iteratein classExpression- Parameters:
context- supplies the context for evaluation- Returns:
- a SequenceIterator that can be used to iterate over the result of the expression
- Throws:
XPathException- if any dynamic error occurs evaluating the expression
-
process
Process the instruction, without returning any tail calls- Overrides:
processin classExpression- Parameters:
output- the destination for the resultcontext- The dynamic context, giving access to the current node,- Throws:
XPathException- if a dynamic error occurs
-
export
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
exportin interfaceExportAgent- Specified by:
exportin classExpression- Parameters:
destination- 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.
-
getExpressionType
Return a distinguishing name for the expression, for use in diagnostics. By default the class name is used.- Returns:
- a distinguishing name for the expression (defaults to the name of the implementation class)
-
getElaborator
Description copied from class:ExpressionMake an elaborator for this expression- Overrides:
getElaboratorin classExpression- Returns:
- an appropriate
Elaborator
-