net.sf.saxon.expr
public abstract class ComputedExpression extends Object implements Serializable, Expression, InstructionInfoProvider, Container
This class is an abstract superclass for different kinds of expression. This includes XSLT instructions, which are treated just like XPath expressions. Every expression is either a constant Value, or a ComputedExpression.
There are three principal methods for evaluating an expression: iterate(), which an iterator over the result of the expression as a sequence; evaluateItem(), which returns an object that is an instance of net.sf.saxon.om.Item; and process(), which pushes the results of the expression to a Receiver. All three methods take an XPathContext object to supply the evaluation context; for an expression that is a Value, this argument is ignored and may be null. This root class provides an implementation of iterate() in terms of evaluateItem() that works only for singleton expressions, and an implementation of evaluateItem() in terms of iterate() that works only for non-singleton expressions. Subclasses of expression must therefore provide either iterate() or evaluateItem() or process(): they do not have to provide all three.
Note that the methods that take an XPathContext argument are run-time methods. The methods without such an argument are compile-time methods. Run-time methods must not modify the state of the Expression object.
Field Summary | |
---|---|
protected int | locationId |
protected int | staticProperties |
Method Summary | |
---|---|
void | adoptChildExpression(Expression child) |
void | checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole)
Check that any elements and attributes constructed or returned by this expression are acceptable
in the content model of a given complex type. |
protected abstract int | computeCardinality() |
int | computeDependencies()
Compute the dependencies of an expression, as the union of the
dependencies of its subexpressions. |
int | computeSpecialProperties() |
void | computeStaticProperties()
Compute the static properties. |
Expression | doPromotion(Expression subexpression, PromotionOffer offer)
Promote a subexpression if possible, and if the expression was changed, carry out housekeeping
to reset the static properties and correct the parent pointers in the tree |
protected void | dynamicError(String message, XPathContext context)
Method used in subclasses to signal a dynamic error |
protected void | dynamicError(String message, String code, XPathContext context)
Method used in subclasses to signal a dynamic error |
boolean | effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the expression. |
String | evaluateAsString(XPathContext context)
Evaluate an expression as a String. |
Item | evaluateItem(XPathContext context)
Evaluate an expression as a single item. |
int | getCardinality()
Determine the static cardinality of the expression. |
int | getColumnNumber()
Get the column number of the expression |
protected int | getConstructType()
Get the type of this expression for use in tracing and diagnostics |
int | getDependencies()
Determine which aspects of the context the expression depends on. |
Executable | getExecutable()
Get the executable containing this expression |
int | getHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container |
int | getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
|
InstructionInfo | getInstructionInfo()
Get InstructionInfo for this expression |
int | getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived
from the dependencies of its subexpressions. |
int | getLineNumber()
Get the line number of the expression |
int | getLocationId()
Get the location ID of the expression |
LocationProvider | getLocationProvider()
Get the LocationProvider allowing location identifiers to be resolved. |
Container | getParentExpression()
Get the expression that immediately contains this expression. |
String | getPublicId()
Get the publicId of the module containing the expression (to satisfy the SourceLocator interface) |
int[] | getSlotsUsed()
Get the local variables (identified by their slot numbers) on which this expression depends.
|
int | getSpecialProperties()
Get the static properties of this expression (other than its type). |
String | getSystemId()
Get the systemId of the module containing the expression |
boolean | hasBadParentPointer()
Diagnostic method: search the tree for an expression whose parent expression is incorrectly set |
SequenceIterator | iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence. |
Iterator | iterateSubExpressions()
Get the immediate sub-expressions of this expression. |
boolean | markTailFunctionCalls()
Mark tail-recursive calls on stylesheet functions. |
void | process(XPathContext context)
Process the instruction, without returning any tail calls |
Expression | promote(PromotionOffer offer)
Offer promotion for this subexpression. |
void | resetStaticProperties()
Reset the static properties. |
void | setLocationId(int id)
Set the location ID on an expression. |
void | setParentExpression(Container parent) |
Expression | simplify(StaticContext env)
Simplify an expression. |
void | suppressValidation(int validationMode)
Suppress validation on contained element constructors, on the grounds that the parent element
is already performing validation. |
protected void | typeError(String message, XPathContext context)
Method used in subclasses to signal a runtime type error |
protected void | typeError(String message, String errorCode, XPathContext context)
Method used in subclasses to signal a runtime type error |
Returns: the depencies, as a bit-mask
Parameters: context The context in which the expression is to be evaluated
Returns: the effective boolean value
Throws: XPathException if any dynamic error occurs evaluating the expression
Parameters: context The context in which the expression is to be evaluated
Returns: the value of the expression, evaluated in the current context. The expression must return a string or (); if the value of the expression is (), this method returns "".
Throws: XPathException if any dynamic error occurs evaluating the expression ClassCastException if the result type of the expression is not xs:string?
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
Returns: one of the values Cardinality.ONE_OR_MORE, Cardinality.ZERO_OR_MORE, Cardinality.EXACTLY_ONE, Cardinality.ZERO_OR_ONE, Cardinality.EMPTY. This default implementation returns ZERO_OR_MORE (which effectively gives no information).
Returns: the type of expression, as enumerated in class Location
Returns: a set of bit-significant flags identifying the dependencies of the expression
Returns: a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
Returns: the expression that contains this expression, if known; return null if there is no containing expression or if the containing expression is unknown.
Returns: a set of flags indicating static properties of this expression
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
Returns: an iterator containing the sub-expressions of this expression
Returns: true if a tail recursive call was found and if this call accounts for the whole of the value.
Parameters: context The dynamic context, giving access to the current node, the current variables, etc.
Parameters: offer details of the offer, for example the offer to move expressions that don't depend on the context to an outer level in the containing expression
Returns: if the offer is not accepted, return this expression unchanged. Otherwise return the result of rewriting the expression to promote this subexpression
Throws: net.sf.saxon.trans.XPathException if any error is detected
Returns: the simplified expression
Throws: XPathException if an error is discovered during expression rewriting