|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.saxon.expr.ExpressionTool
This class, ExpressionTool, contains a number of useful static methods for manipulating expressions. Most importantly, it provides the factory method make() for constructing a new expression
Method Summary | |
static int |
allocateSlots(Expression exp,
int nextFree,
SlotManager frame)
Allocate slot numbers to range variables |
static boolean |
callsFunction(Expression exp,
int fp)
Determine whether an expression contains a call on the function with a given fingerprint |
static void |
copyLocationInfo(Expression from,
Expression to)
Copy location information (the line number) from one expression to another |
static boolean |
dependsOnVariable(Expression e,
Binding[] bindingList)
Determine whether an expression depends on any one of a set of variables |
static Value |
eagerEvaluate(Expression exp,
XPathContext context)
Evaluate an expression now; lazy evaluation is not permitted in this case |
static void |
ebvError(java.lang.String reason)
|
static boolean |
effectiveBooleanValue(SequenceIterator iterator)
Determine the effective boolean value of a sequence, given an iterator over the sequence |
static void |
gatherCalledFunctions(Expression e,
java.util.List list)
Gather a list of all the user-defined functions which a given expression calls directly |
static void |
gatherReferencedVariables(Expression e,
java.util.List list)
Gather a list of all the variable bindings on which a given expression depends |
static javax.xml.transform.SourceLocator |
getLocator(Expression exp)
Get location information for an expression in the form of a SourceLocator |
static java.lang.String |
indent(int level)
Construct indent string, for diagnostic output |
static boolean |
isRepeatedSubexpression(Expression parent,
Expression child,
StaticContext env)
Determine whether an expression is a repeatedly-evaluated subexpression of a parent expression. |
static boolean |
isVariableReplaceableByDot(Expression exp,
Binding[] binding)
Determine whether it is possible to rearrange an expression so that all references to a given variable are replaced by a reference to ".". |
static ValueRepresentation |
lazyEvaluate(Expression exp,
XPathContext context,
int ref)
Do lazy evaluation of an expression. |
static Expression |
make(java.lang.String expression,
StaticContext env,
int start,
int terminator,
int lineNumber)
Parse an expression. |
static void |
makeParentReferences(Expression top)
Establish the links from subexpressions to their parent expressions, by means of a recursive tree walk. |
static boolean |
markTailFunctionCalls(Expression exp)
|
static Expression |
resolveCallsToCurrentFunction(Expression exp,
Configuration config)
Resolve calls to the current() function within an expression |
static Expression |
unsorted(Optimizer opt,
Expression exp,
boolean eliminateDuplicates)
Remove unwanted sorting from an expression, at compile time |
static Expression |
unsortedIfHomogeneous(Optimizer opt,
Expression exp,
boolean eliminateDuplicates)
Remove unwanted sorting from an expression, at compile time, if and only if it is known that the result of the expression will be homogeneous (all nodes, or all atomic values). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static Expression make(java.lang.String expression, StaticContext env, int start, int terminator, int lineNumber) throws XPathException
expression
- The expression (as a character string)env
- An object giving information about the compile-time
context of the expressionterminator
- The token that marks the end of this expression; typically
Tokenizer.EOF, but may for example be a right curly bracelineNumber
- the line number of the start of the expression
XPathException
- if the expression contains a static errorpublic static void copyLocationInfo(Expression from, Expression to)
public static void makeParentReferences(Expression top)
public static javax.xml.transform.SourceLocator getLocator(Expression exp)
public static boolean isRepeatedSubexpression(Expression parent, Expression child, StaticContext env)
public static Expression unsorted(Optimizer opt, Expression exp, boolean eliminateDuplicates) throws XPathException
XPathException
public static Expression unsortedIfHomogeneous(Optimizer opt, Expression exp, boolean eliminateDuplicates) throws XPathException
XPathException
public static ValueRepresentation lazyEvaluate(Expression exp, XPathContext context, int ref) throws XPathException
context
- the run-time evaluation context for the expression. If
the expression is not evaluated immediately, then parts of the
context on which the expression depends need to be saved as part of
the Closureref
- an indication of how the value will be used. The value 1 indicates that the value
is only expected to be used once, so that there is no need to keep it in memory. A small value >1
indicates multiple references, so the value will be saved when first evaluated. The special value
FILTERED indicates a reference within a loop of the form $x[predicate], indicating that the value
should be saved in a way that permits indexing.
XPathException
- if any error occurs in evaluating the
expressionpublic static Value eagerEvaluate(Expression exp, XPathContext context) throws XPathException
exp
- the expression to be evaluatedcontext
- the run-time evaluation context
XPathException
- if any dynamic error occurs evaluating the
expressionpublic static boolean markTailFunctionCalls(Expression exp)
public static java.lang.String indent(int level)
level
- the indentation level (the number of spaces to return)
public static int allocateSlots(Expression exp, int nextFree, SlotManager frame)
exp
- the expression whose range variables need to have slot numbers assignednextFree
- the next slot number that is available for allocationframe
- a SlotManager object that is used to track the mapping of slot numbers
to variable names for debugging purposes. May be null.
public static boolean effectiveBooleanValue(SequenceIterator iterator) throws XPathException
iterator
- An iterator over the sequence whose effective boolean value is required
XPathException
- if a dynamic error occurspublic static void ebvError(java.lang.String reason) throws XPathException
XPathException
public static boolean dependsOnVariable(Expression e, Binding[] bindingList)
e
- the expression being testedbindingList
- the set of variables being tested
public static void gatherReferencedVariables(Expression e, java.util.List list)
e
- the expression being testedlist
- a list to which the bindings are to be added. The items in this list must
implement Binding
public static boolean callsFunction(Expression exp, int fp)
exp
- The expression being testedfp
- The fingerprint of the name of the function
public static void gatherCalledFunctions(Expression e, java.util.List list)
e
- the expression being testedlist
- a list of the functions that are called. The items in this list must
be objects of class UserFunction
public static Expression resolveCallsToCurrentFunction(Expression exp, Configuration config) throws XPathException
XPathException
public static boolean isVariableReplaceableByDot(Expression exp, Binding[] binding)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |