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.
| Modifier and Type | Field and Description |
|---|---|
protected int |
locationId |
protected int |
staticProperties |
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD| Constructor and Description |
|---|
ComputedExpression() |
| Modifier and Type | Method and Description |
|---|---|
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,
String code,
XPathContext context)
Method used in subclasses to signal a dynamic error
|
protected void |
dynamicError(String message,
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,
String errorCode,
XPathContext context)
Method used in subclasses to signal a runtime type error
|
protected void |
typeError(String message,
XPathContext context)
Method used in subclasses to signal a runtime type error
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdisplay, getItemType, optimize, typeCheckpublic Container getParentExpression()
getParentExpression in interface Expressionpublic void setParentExpression(Container parent)
public void adoptChildExpression(Expression child)
public int getImplementationMethod()
getImplementationMethod in interface Expressionpublic void setLocationId(int id)
public final int getLocationId()
public int getLineNumber()
getLineNumber in interface SourceLocatorpublic int getColumnNumber()
getColumnNumber in interface SourceLocatorpublic String getSystemId()
getSystemId in interface SourceLocatorpublic final String getPublicId()
getPublicId in interface SourceLocatorpublic Executable getExecutable()
getExecutable in interface Containerpublic LocationProvider getLocationProvider()
getLocationProvider in interface Containerpublic Expression simplify(StaticContext env) throws XPathException
simplify in interface ExpressionXPathException - if an error is discovered during expression
rewritingpublic Expression promote(PromotionOffer offer) throws XPathException
promote in interface Expressionoffer - 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 expressionXPathException - if any error is detectedpublic final Expression doPromotion(Expression subexpression, PromotionOffer offer) throws XPathException
XPathExceptionpublic final int getSpecialProperties()
getSpecialProperties in interface Expressionpublic final void computeStaticProperties()
public final void resetStaticProperties()
protected abstract int computeCardinality()
public int computeSpecialProperties()
public int getCardinality()
getCardinality in interface Expressionpublic int getDependencies()
getDependencies in interface Expressionpublic int computeDependencies()
public int getIntrinsicDependencies()
public Iterator iterateSubExpressions()
iterateSubExpressions in interface Expressionpublic void suppressValidation(int validationMode)
public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException
checkPermittedContents in interface ExpressionparentType - The schema typeenv - the static contextwhole - true if this expression is expected to make the whole content of the type, false
if it is expected to make up only a partXPathException - if the expression doesn't match the required content typepublic boolean markTailFunctionCalls()
public int[] getSlotsUsed()
public Item evaluateItem(XPathContext context) throws XPathException
evaluateItem in interface Expressioncontext - The context in which the expression is to be evaluatedXPathException - if any dynamic error occurs evaluating the
expressionpublic String evaluateAsString(XPathContext context) throws XPathException
evaluateAsString in interface Expressioncontext - The context in which the expression is to be evaluatedXPathException - if any dynamic error occurs evaluating the
expressionClassCastException - if the result type of the
expression is not xs:string?public SequenceIterator iterate(XPathContext context) throws XPathException
iterate in interface Expressioncontext - supplies the context for evaluationXPathException - if any dynamic error occurs evaluating the
expressionpublic boolean effectiveBooleanValue(XPathContext context) throws XPathException
effectiveBooleanValue in interface Expressioncontext - The context in which the expression is to be evaluatedXPathException - if any dynamic error occurs evaluating the
expressionpublic void process(XPathContext context) throws XPathException
process in interface Expressioncontext - The dynamic context, giving access to the current node,
the current variables, etc.XPathExceptionprotected void dynamicError(String message, XPathContext context) throws DynamicError
DynamicErrorprotected void dynamicError(String message, String code, XPathContext context) throws DynamicError
DynamicErrorprotected void typeError(String message, XPathContext context) throws DynamicError
DynamicErrorprotected void typeError(String message, String errorCode, XPathContext context) throws DynamicError
DynamicErrorpublic InstructionInfo getInstructionInfo()
getInstructionInfo in interface InstructionInfoProviderprotected int getConstructType()
Locationpublic boolean hasBadParentPointer()
public int getHostLanguage()
getHostLanguage in interface ContainerConfiguration.XSLT or Configuration.XQUERY