| java.lang.Object net.sf.saxon.expr.ExpressionTool
ExpressionTool | public class ExpressionTool (Code) | | 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 | |
public static int | allocateSlots(Expression exp, int nextFree, SlotManager frame) Allocate slot numbers to range variables
Parameters: exp - the expression whose range variables need to have slot numbers assigned Parameters: nextFree - the next slot number that is available for allocation Parameters: frame - a SlotManager object that is used to track the mapping of slot numbersto variable names for debugging purposes. | public static boolean | callsFunction(Expression exp, int fp) | public static void | copyLocationInfo(Expression from, Expression to) | public static boolean | dependsOnVariable(Expression e, Binding[] bindingList) | public static Value | eagerEvaluate(Expression exp, XPathContext context) | public static void | ebvError(String reason) | public static boolean | effectiveBooleanValue(SequenceIterator iterator) | public static void | gatherCalledFunctions(Expression e, List list) Gather a list of all the user-defined functions which a given expression calls directly
Parameters: e - the expression being tested Parameters: list - a list of the functions that are called. | public static void | gatherReferencedVariables(Expression e, List list) Gather a list of all the variable bindings on which a given expression depends
Parameters: e - the expression being tested Parameters: list - a list to which the bindings are to be added. | public static SourceLocator | getLocator(Expression exp) | public static String | indent(int level) | public static boolean | isRepeatedSubexpression(Expression parent, Expression child, StaticContext env) Determine whether an expression is a repeatedly-evaluated subexpression
of a parent expression. | public 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 ".". | public static ValueRepresentation | lazyEvaluate(Expression exp, XPathContext context, int ref) Do lazy evaluation of an expression. | public static Expression | make(String expression, StaticContext env, int start, int terminator, int lineNumber) Parse an expression. | public static void | makeParentReferences(Expression top) Establish the links from subexpressions to their parent expressions,
by means of a recursive tree walk. | public static boolean | markTailFunctionCalls(Expression exp) | public static Expression | resolveCallsToCurrentFunction(Expression exp, Configuration config) | public static Expression | unsorted(Optimizer opt, Expression exp, boolean eliminateDuplicates) | public 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). |
allocateSlots | public static int allocateSlots(Expression exp, int nextFree, SlotManager frame)(Code) | | Allocate slot numbers to range variables
Parameters: exp - the expression whose range variables need to have slot numbers assigned Parameters: nextFree - the next slot number that is available for allocation Parameters: frame - a SlotManager object that is used to track the mapping of slot numbersto variable names for debugging purposes. May be null. the next unallocated slot number. |
callsFunction | public static boolean callsFunction(Expression exp, int fp)(Code) | | Determine whether an expression contains a call on the function with a given fingerprint
Parameters: exp - The expression being tested Parameters: fp - The fingerprint of the name of the function true if the expression contains a call on the function |
copyLocationInfo | public static void copyLocationInfo(Expression from, Expression to)(Code) | | Copy location information (currently the line number and parent) from one expression
to another
|
dependsOnVariable | public static boolean dependsOnVariable(Expression e, Binding[] bindingList)(Code) | | Determine whether an expression depends on any one of a set of variables
Parameters: e - the expression being tested Parameters: bindingList - the set of variables being tested true if the expression depends on one of the given variables |
eagerEvaluate | public static Value eagerEvaluate(Expression exp, XPathContext context) throws XPathException(Code) | | Evaluate an expression now; lazy evaluation is not permitted in this case
Parameters: exp - the expression to be evaluated Parameters: context - the run-time evaluation context exception: net.sf.saxon.trans.XPathException - if any dynamic error occurs evaluating theexpression the result of evaluating the expression |
effectiveBooleanValue | public static boolean effectiveBooleanValue(SequenceIterator iterator) throws XPathException(Code) | | Determine the effective boolean value of a sequence, given an iterator over the sequence
Parameters: iterator - An iterator over the sequence whose effective boolean value is required the effective boolean value throws: XPathException - if a dynamic error occurs |
gatherCalledFunctions | public static void gatherCalledFunctions(Expression e, List list)(Code) | | Gather a list of all the user-defined functions which a given expression calls directly
Parameters: e - the expression being tested Parameters: list - a list of the functions that are called. The items in this list mustbe objects of class UserFunction |
gatherReferencedVariables | public static void gatherReferencedVariables(Expression e, List list)(Code) | | Gather a list of all the variable bindings on which a given expression depends
Parameters: e - the expression being tested Parameters: list - a list to which the bindings are to be added. The items in this list mustimplement Binding |
indent | public static String indent(int level)(Code) | | Construct indent string, for diagnostic output
Parameters: level - the indentation level (the number of spaces to return) a string of "level*2" spaces |
isRepeatedSubexpression | public static boolean isRepeatedSubexpression(Expression parent, Expression child, StaticContext env)(Code) | | Determine whether an expression is a repeatedly-evaluated subexpression
of a parent expression. For example, the predicate in a filter expression is
a repeatedly-evaluated subexpression of the filter expression.
|
isVariableReplaceableByDot | public static boolean isVariableReplaceableByDot(Expression exp, Binding[] binding)(Code) | | Determine whether it is possible to rearrange an expression so that all references to a given
variable are replaced by a reference to ".". This is true of there are no references to the variable
within a filter predicate or on the rhs of a "/" operator.
|
lazyEvaluate | public static ValueRepresentation lazyEvaluate(Expression exp, XPathContext context, int ref) throws XPathException(Code) | | Do lazy evaluation of an expression. This will return a value, which may optionally
be a SequenceIntent, which is a wrapper around an iterator over the value of the expression.
Parameters: context - the run-time evaluation context for the expression. Ifthe expression is not evaluated immediately, then parts of thecontext on which the expression depends need to be saved as part ofthe Closure Parameters: ref - an indication of how the value will be used. The value 1 indicates that the valueis only expected to be used once, so that there is no need to keep it in memory. A small value >1indicates multiple references, so the value will be saved when first evaluated. The special valueFILTERED indicates a reference within a loop of the form $x[predicate], indicating that the valueshould be saved in a way that permits indexing. exception: XPathException - if any error occurs in evaluating theexpression a value: either the actual value obtained by evaluating theexpression, or a Closure containing all the information needed toevaluate it later |
make | public static Expression make(String expression, StaticContext env, int start, int terminator, int lineNumber) throws XPathException(Code) | | Parse an expression. This performs the basic analysis of the expression against the
grammar, it binds variable references and function calls to variable definitions and
function definitions, and it performs context-independent expression rewriting for
optimization purposes.
exception: net.sf.saxon.trans.XPathException - if the expression contains a static error Parameters: expression - The expression (as a character string) Parameters: env - An object giving information about the compile-timecontext of the expression Parameters: terminator - The token that marks the end of this expression; typicallyTokenizer.EOF, but may for example be a right curly brace Parameters: lineNumber - the line number of the start of the expression an object of type Expression |
makeParentReferences | public static void makeParentReferences(Expression top)(Code) | | Establish the links from subexpressions to their parent expressions,
by means of a recursive tree walk.
|
markTailFunctionCalls | public static boolean markTailFunctionCalls(Expression exp)(Code) | | |
unsortedIfHomogeneous | public static Expression unsortedIfHomogeneous(Optimizer opt, Expression exp, boolean eliminateDuplicates) throws XPathException(Code) | | 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).
This is done when we need the effective boolean value of a sequence: the EBV of a
homogenous sequence does not depend on its order, but this is not true when atomic
values and nodes are mixed: (N, AV) is true, but (AV, N) is an error.
|
|
|