|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.saxon.expr.ComputedExpression
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
|
Fields inherited from interface net.sf.saxon.expr.Expression |
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD |
Constructor Summary | |
ComputedExpression()
|
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(java.lang.String message,
java.lang.String code,
XPathContext context)
Method used in subclasses to signal a dynamic error |
protected void |
dynamicError(java.lang.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. |
java.lang.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. |
java.lang.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). |
java.lang.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. |
java.util.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(java.lang.String message,
java.lang.String errorCode,
XPathContext context)
Method used in subclasses to signal a runtime type error |
protected void |
typeError(java.lang.String message,
XPathContext context)
Method used in subclasses to signal a runtime type error |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.saxon.expr.Expression |
display, getItemType, optimize, typeCheck |
Field Detail |
protected int staticProperties
protected int locationId
Constructor Detail |
public ComputedExpression()
Method Detail |
public Container getParentExpression()
getParentExpression
in interface Expression
public void setParentExpression(Container parent)
public void adoptChildExpression(Expression child)
public int getImplementationMethod()
getImplementationMethod
in interface Expression
public void setLocationId(int id)
public final int getLocationId()
public int getLineNumber()
getLineNumber
in interface javax.xml.transform.SourceLocator
public int getColumnNumber()
getColumnNumber
in interface javax.xml.transform.SourceLocator
public java.lang.String getSystemId()
getSystemId
in interface javax.xml.transform.SourceLocator
public final java.lang.String getPublicId()
getPublicId
in interface javax.xml.transform.SourceLocator
public Executable getExecutable()
getExecutable
in interface Container
public LocationProvider getLocationProvider()
getLocationProvider
in interface Container
public Expression simplify(StaticContext env) throws XPathException
simplify
in interface Expression
XPathException
- if an error is discovered during expression
rewritingpublic Expression promote(PromotionOffer offer) throws XPathException
promote
in interface Expression
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
XPathException
- if any error is detectedpublic final Expression doPromotion(Expression subexpression, PromotionOffer offer) throws XPathException
XPathException
public final int getSpecialProperties()
getSpecialProperties
in interface Expression
public final void computeStaticProperties()
public final void resetStaticProperties()
protected abstract int computeCardinality()
public int computeSpecialProperties()
public int getCardinality()
getCardinality
in interface Expression
public int getDependencies()
getDependencies
in interface Expression
public int computeDependencies()
public int getIntrinsicDependencies()
public java.util.Iterator iterateSubExpressions()
iterateSubExpressions
in interface Expression
public void suppressValidation(int validationMode)
public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException
checkPermittedContents
in interface Expression
parentType
- 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 part
XPathException
- 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 Expression
context
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expressionpublic java.lang.String evaluateAsString(XPathContext context) throws XPathException
evaluateAsString
in interface Expression
context
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expression
java.lang.ClassCastException
- if the result type of the
expression is not xs:string?public SequenceIterator iterate(XPathContext context) throws XPathException
iterate
in interface Expression
context
- supplies the context for evaluation
XPathException
- if any dynamic error occurs evaluating the
expressionpublic boolean effectiveBooleanValue(XPathContext context) throws XPathException
effectiveBooleanValue
in interface Expression
context
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expressionpublic void process(XPathContext context) throws XPathException
process
in interface Expression
context
- The dynamic context, giving access to the current node,
the current variables, etc.
XPathException
protected void dynamicError(java.lang.String message, XPathContext context) throws DynamicError
DynamicError
protected void dynamicError(java.lang.String message, java.lang.String code, XPathContext context) throws DynamicError
DynamicError
protected void typeError(java.lang.String message, XPathContext context) throws DynamicError
DynamicError
protected void typeError(java.lang.String message, java.lang.String errorCode, XPathContext context) throws DynamicError
DynamicError
public InstructionInfo getInstructionInfo()
getInstructionInfo
in interface InstructionInfoProvider
protected int getConstructType()
Location
public boolean hasBadParentPointer()
public int getHostLanguage()
getHostLanguage
in interface Container
Configuration.XSLT
or Configuration.XQUERY
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |