|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.saxon.expr.ComputedExpression
This class is an abstract superclass for different kinds of XPath expression.
There are two principal methods for evaluating an expression: iterate(), which an iterator over the result of the expression as a sequence, and evaluateItem(), which returns an object that is an instance of net.sf.saxon.om.Item. Both 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(): they do not have to provide both.
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 short |
lineNumber
|
static Expression[] |
NO_ARGUMENTS
A zero-length array of expressions, used for functions that have no arguments or expressions that have no subexpressions |
protected int |
staticProperties
|
Constructor Summary | |
ComputedExpression()
|
Method Summary | |
protected abstract int |
computeCardinality()
|
int |
computeDependencies()
Compute the dependencies of an expression, as the union of the dependencies of its subexpressions. |
protected int |
computeSpecialProperties()
|
void |
computeStaticProperties()
Compute the static properties. |
protected void |
dynamicError(java.lang.String message)
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 |
getDependencies()
Determine which aspects of the context the expression depends on. |
int |
getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. |
short |
getLineNumber()
Get the line number on the expression |
javax.xml.transform.SourceLocator |
getSourceLocator()
Get a SourceLocator for this expression (needed to make the expression an Instr) |
int |
getSpecialProperties()
Get the static properties of this expression (other than its type). |
Expression[] |
getSubExpressions()
Get the immediate sub-expressions of this expression. |
SequenceIterator |
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence. |
boolean |
markTailFunctionCalls()
Mark tail-recursive calls on stylesheet functions. |
Expression |
promote(PromotionOffer offer)
Offer promotion for this subexpression. |
void |
setLineNumber(short line)
Set the line number on an expression. |
Expression |
simplify()
Simplify an expression. |
protected void |
typeError(java.lang.String message)
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 |
analyze, display, getItemType |
Field Detail |
protected int staticProperties
protected short lineNumber
public static final Expression[] NO_ARGUMENTS
Constructor Detail |
public ComputedExpression()
Method Detail |
public void setLineNumber(short line)
public short getLineNumber()
public Expression simplify() 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 int getSpecialProperties()
getSpecialProperties
in interface Expression
public final void computeStaticProperties()
protected abstract int computeCardinality()
protected int computeSpecialProperties()
public int getCardinality()
getCardinality
in interface Expression
public int getDependencies()
getDependencies
in interface Expression
public int computeDependencies()
public int getIntrinsicDependencies()
public Expression[] getSubExpressions()
getSubExpressions
in interface Expression
public boolean markTailFunctionCalls()
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
expressionprotected void dynamicError(java.lang.String message) throws XPathException.Dynamic
XPathException.Dynamic
protected void typeError(java.lang.String message) throws XPathException.Type
XPathException.Type
public javax.xml.transform.SourceLocator getSourceLocator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |