public abstract class Expression extends Object
Modifier and Type | Field and Description |
---|---|
protected StaticContext |
staticContext |
Constructor and Description |
---|
Expression() |
Modifier and Type | Method and Description |
---|---|
boolean |
containsReferences()
Determine whether the expression contains any references to variables
|
abstract void |
display(int level)
Diagnostic print of expression structure
|
NodeEnumeration |
enumerate(Context context,
boolean sorted)
Return an enumeration of nodes in a nodeset.
|
abstract Value |
evaluate(Context context)
Evaluate an expression.
|
boolean |
evaluateAsBoolean(Context context)
Evaluate an expression as a Boolean.
The result of x.evaluateAsBoolean(c) must be equivalent to x.evaluate(c).asBoolean(); but optimisations are possible when it is known that a boolean result is required, especially in the case of a NodeSet. |
NodeSetValue |
evaluateAsNodeSet(Context context)
Evaluate an expression as a NodeSet.
|
double |
evaluateAsNumber(Context context)
Evaluate an expression as a Number.
The result of x.evaluateAsNumber(c) must be equivalent to x.evaluate(c).asNumber(); but optimisations are possible when it is known that a numeric result is required, especially in the case of a NodeSet. |
String |
evaluateAsString(Context context)
Evaluate an expression as a String.
The result of x.evaluateAsString(c) must be equivalent to x.evaluate(c).asString(); but optimisations are possible when it is known that a string result is required, especially in the case of a NodeSet. |
abstract int |
getDataType()
Determine the data type of the expression, if possible
|
abstract int |
getDependencies()
Determine which aspects of the context the expression depends on.
|
StaticContext |
getStaticContext()
Determine the static context used when the expression was parsed
|
protected static String |
indent(int level)
Construct indent string, for diagnostic output
|
boolean |
isContextDocumentNodeSet()
Determine, in the case of an expression whose data type is Value.NODESET,
whether all the nodes in the node-set are guaranteed to come from the same
document as the context node.
|
static Expression |
make(String expression,
StaticContext env)
Parse an expression
|
void |
outputStringValue(Outputter out,
Context context)
Evaluate an expression as a String and write the result to the
specified outputter.
|
abstract Expression |
reduce(int dependencies,
Context context)
Perform a partial evaluation of the expression, by eliminating specified dependencies
on the context.
|
void |
setStaticContext(StaticContext sc)
Set the static context used when the expression was parsed
|
Expression |
simplify()
Simplify an expression.
|
boolean |
usesCurrent()
Determine whether the expression uses the current() function.
|
protected StaticContext staticContext
public static Expression make(String expression, StaticContext env) throws XPathException
expression
- The expression (as a character string)env
- An object giving information about the compile-time context of the expressionXPathException
public Expression simplify() throws XPathException
XPathException
public final void setStaticContext(StaticContext sc)
public final StaticContext getStaticContext()
public boolean containsReferences() throws XPathException
XPathException
public abstract Value evaluate(Context context) throws XPathException
context
- The context in which the expression is to be evaluatedXPathException
public boolean evaluateAsBoolean(Context context) throws XPathException
context
- The context in which the expression is to be evaluatedXPathException
public double evaluateAsNumber(Context context) throws XPathException
context
- The context in which the expression is to be evaluatedXPathException
public String evaluateAsString(Context context) throws XPathException
context
- The context in which the expression is to be evaluatedXPathException
public void outputStringValue(Outputter out, Context context) throws TransformerException
out
- The required outputtercontext
- The context in which the expression is to be evaluatedTransformerException
public NodeSetValue evaluateAsNodeSet(Context context) throws XPathException
context
- The context in which the expression is to be evaluatedXPathException
- when the expression does not return a nodeset.public NodeEnumeration enumerate(Context context, boolean sorted) throws XPathException
context
- The context in which the expression is to be evaluatedsorted
- Indicates whether the nodes are required in document order. If
this is false, they may come in any order, but there will be no duplicates.XPathException
- when the expression does not return a nodeset.public abstract int getDataType()
public boolean isContextDocumentNodeSet()
public boolean usesCurrent()
public abstract int getDependencies()
public abstract Expression reduce(int dependencies, Context context) throws XPathException
dependencies
- The dependencies to be removed, e.g. Context.VARIABLEScontext
- The context to be used for the partial evaluationXPathException
public abstract void display(int level)
protected static String indent(int level)