public class ExpressionVisitor extends Object implements TypeCheckerEnvironment
Modifier and Type | Class and Description |
---|---|
static class |
ExpressionVisitor.ContextItemType
A data structure that represents the required type of the context item, together
with information about whether it is known to be present or absent or whether it
is not known statically whether it is present or absent.
|
Constructor and Description |
---|
ExpressionVisitor()
Create an ExpressionVisitor
|
Modifier and Type | Method and Description |
---|---|
CollationMap |
getCollationMap() |
Configuration |
getConfiguration()
Get the Saxon configuration
|
Expression |
getCurrentExpression()
Get the current expression, the one being visited
|
Executable |
getExecutable()
Get the Executable containing the expressions being visited
|
Stack<Expression> |
getExpressionStack()
Get the stack containing all the expressions currently being visited
|
Expression |
getParentExpression()
Get the parent expression of the current expression in the expression tree
|
StaticContext |
getStaticContext()
Get the static context for the expressions being visited.
|
boolean |
isLoopingReference(Binding binding,
VariableReference ref) |
boolean |
isLoopingSubexpression(Expression ancestor)
Return true if the current expression at the top of the visitor's stack is evaluated repeatedly
when a given ancestor expression is evaluated once
|
boolean |
isOptimizeForStreaming()
Ask whether the visitor is to optimize expressions for evaluation in a streaming environment
|
void |
issueWarning(String message,
SourceLocator locator)
Issue a warning message
|
static ExpressionVisitor |
make(StaticContext env,
Executable exec)
Factory method: make an expression visitor
|
XPathContext |
makeDynamicContext()
Create a dynamic context suitable for early evaluation of constant subexpressions
|
Expression |
optimize(Expression exp,
ExpressionVisitor.ContextItemType contextItemType)
Optimize an expression, via the ExpressionVisitor
|
void |
resetStaticProperties()
Reset the static properties for the current expression and for all its containing expressions.
|
void |
setConfiguration(Configuration configuration)
Set the Saxon configuration
|
void |
setExecutable(Executable executable)
Set the Executable containing the expressions being visited
|
void |
setExpressionStack(Stack<Expression> expressionStack)
Set the stack used to hold the expressions being visited
|
void |
setOptimizeForStreaming(boolean option)
Tell the visitor to optimize expressions for evaluation in a streaming environment
|
void |
setStaticContext(StaticContext staticContext)
Set the static context for the expressions being visited.
|
Expression |
simplify(Expression exp)
Simplify an expression, via the ExpressionVisitor
|
Expression |
typeCheck(Expression exp,
ExpressionVisitor.ContextItemType contextItemType)
Type check an expression, via the ExpressionVisitor
|
public Configuration getConfiguration()
getConfiguration
in interface TypeCheckerEnvironment
public void setConfiguration(Configuration configuration)
configuration
- the Saxon configurationpublic Executable getExecutable()
public void setExecutable(Executable executable)
executable
- the Executablepublic CollationMap getCollationMap()
getCollationMap
in interface TypeCheckerEnvironment
public Stack<Expression> getExpressionStack()
Expression
public void setExpressionStack(Stack<Expression> expressionStack)
expressionStack
- the expression stackpublic StaticContext getStaticContext()
public void setStaticContext(StaticContext staticContext)
staticContext
- the static contextpublic Expression getCurrentExpression()
public static ExpressionVisitor make(StaticContext env, Executable exec)
env
- the static contextexec
- the executablepublic void issueWarning(String message, SourceLocator locator)
issueWarning
in interface TypeCheckerEnvironment
message
- the messagepublic XPathContext makeDynamicContext()
makeDynamicContext
in interface TypeCheckerEnvironment
public Expression simplify(Expression exp) throws XPathException
simplify
in interface TypeCheckerEnvironment
exp
- the expression to be simplified. Possibly null.XPathException
- if any error occurspublic Expression typeCheck(Expression exp, ExpressionVisitor.ContextItemType contextItemType) throws XPathException
typeCheck
in interface TypeCheckerEnvironment
exp
- the expression to be typecheckedcontextItemType
- the static type of the context item for this expression. The argument can be
set to null to indicate that it is known that the context item will be absent.XPathException
- if static type checking fails, that is, if the expression cannot possibly
deliver a value of the required typepublic void setOptimizeForStreaming(boolean option)
option
- true if optimizing for streamingpublic boolean isOptimizeForStreaming()
public Expression optimize(Expression exp, ExpressionVisitor.ContextItemType contextItemType) throws XPathException
exp
- the expression to be typecheckedcontextItemType
- the static type of the context item for this expression. Passing null indicates
that the context item will always be absentXPathException
- if a static error is foundpublic Expression getParentExpression()
public boolean isLoopingSubexpression(Expression ancestor)
ancestor
- the ancestor expression. May be null, in which case the search goes all the way
to the base of the stack.public boolean isLoopingReference(Binding binding, VariableReference ref)
public final void resetStaticProperties()
Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.