|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.saxon.expr.Expression
public abstract class Expression
Interface supported by an XPath expression. This includes both compile-time and run-time methods.
Field Summary | |
---|---|
static int |
EVALUATE_METHOD
|
static int |
ITERATE_METHOD
|
static int |
PROCESS_METHOD
|
Constructor Summary | |
---|---|
Expression()
|
Method Summary | |
---|---|
void |
adoptChildExpression(Expression child)
Set up a parent-child relationship between this expression and a given child expression. |
void |
checkPermittedContents(SchemaType parentType,
StaticContext env,
boolean whole)
Check that any elements and attributes constructed or returned by this expression are acceptable in the content model of a given complex type. |
int |
computeDependencies()
Compute the dependencies of an expression, as the union of the dependencies of its subexpressions. |
int |
computeSpecialProperties()
|
void |
computeStaticProperties()
Compute the static properties. |
abstract void |
display(int level,
PrintStream out,
Configuration config)
Diagnostic print of expression structure. |
Expression |
doPromotion(Expression subexpression,
PromotionOffer offer)
Promote a subexpression if possible, and if the expression was changed, carry out housekeeping to reset the static properties and correct the parent pointers in the tree |
boolean |
effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the expression. |
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 |
getColumnNumber()
Get the column number of the expression |
Procedure |
getContainingProcedure()
Get the Procedure containing this expression. |
int |
getDependencies()
Determine which aspects of the context the expression depends on. |
Executable |
getExecutable()
Get the executable containing this expression |
int |
getHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container |
int |
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). |
InstructionInfo |
getInstructionInfo()
Get InstructionInfo for this expression |
int |
getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. |
abstract ItemType |
getItemType(TypeHierarchy th)
Determine the data type of the expression, if possible. |
int |
getLineNumber()
Get the line number of the expression |
int |
getLocationId()
Get the location ID of the expression |
LocationProvider |
getLocationProvider()
Get the LocationProvider allowing location identifiers to be resolved. |
Container |
getParentExpression()
Get the expression that immediately contains this expression. |
String |
getPublicId()
Get the publicId of the module containing the expression (to satisfy the SourceLocator interface) |
int[] |
getSlotsUsed()
Get the local variables (identified by their slot numbers) on which this expression depends. |
int |
getSpecialProperties()
Get the static properties of this expression (other than its type). |
String |
getSystemId()
Get the systemId of the module containing the expression |
boolean |
hasBadParentPointer()
Diagnostic method: search the tree for an expression whose parent expression is incorrectly set |
SequenceIterator |
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence. |
Iterator |
iterateSubExpressions()
Get the immediate sub-expressions of this expression. |
int |
markTailFunctionCalls(int nameCode,
int arity)
Mark tail-recursive calls on stylesheet functions. |
Expression |
optimize(Optimizer opt,
StaticContext env,
ItemType contextItemType)
Perform optimisation of an expression and its subexpressions. |
void |
process(XPathContext context)
Process the instruction, without returning any tail calls |
Expression |
promote(PromotionOffer offer)
Offer promotion for this subexpression. |
boolean |
replaceSubExpression(Expression original,
Expression replacement)
Replace one subexpression by a replacement subexpression |
void |
resetStaticProperties()
Reset the static properties. |
void |
setLocationId(int id)
Set the location ID on an expression. |
void |
setParentExpression(Container parent)
|
static void |
setParentExpression(Expression child,
Container parent)
|
Expression |
simplify(StaticContext env)
Simplify an expression. |
void |
suppressValidation(int validationMode)
Suppress validation on contained element constructors, on the grounds that the parent element is already performing validation. |
Expression |
typeCheck(StaticContext env,
ItemType contextItemType)
Perform type checking of an expression and its subexpressions. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int EVALUATE_METHOD
public static final int ITERATE_METHOD
public static final int PROCESS_METHOD
Constructor Detail |
---|
public Expression()
Method Detail |
---|
public int getImplementationMethod()
public Expression simplify(StaticContext env) throws XPathException
XPathException
- if an error is discovered during expression
rewritingpublic Expression typeCheck(StaticContext env, ItemType contextItemType) throws XPathException
This checks statically that the operands of the expression have the correct type; if necessary it generates code to do run-time type checking or type conversion. A static type error is reported only if execution cannot possibly succeed, that is, if a run-time type error is inevitable. The call may return a modified form of the expression.
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable. However, the types of such functions and variables may not be accurately known if they have not been explicitly declared.
If the implementation returns a value other than "this", then it is required to ensure that the parent pointer and location information in the returned expression have been set up correctly. It should not rely on the caller to do this, although for historical reasons many callers do so.
env
- the static context of the expressioncontextItemType
- the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPE
StaticError
- if an error is discovered during this phase
(typically a type error)
XPathException
public Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType) throws XPathException
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.
opt
- the optimizer in use. This provides access to supporting functions; it also allows
different optimization strategies to be used in different circumstances.env
- the static context of the expressioncontextItemType
- the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPE
StaticError
- if an error is discovered during this phase
(typically a type error)
XPathException
public Expression promote(PromotionOffer offer) throws XPathException
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()
public int getCardinality()
public abstract ItemType getItemType(TypeHierarchy th)
This method should always return a result, though it may be the best approximation that is available at the time.
th
-
public int getDependencies()
public Iterator iterateSubExpressions()
public Container getParentExpression()
public Item evaluateItem(XPathContext context) throws XPathException
evaluateItem
in interface EvaluableItem
context
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expressionpublic SequenceIterator iterate(XPathContext context) throws XPathException
iterate
in interface SequenceIterable
context
- supplies the context for evaluation
XPathException
- if any dynamic error occurs evaluating the
expressionpublic boolean effectiveBooleanValue(XPathContext context) throws XPathException
context
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expressionpublic String evaluateAsString(XPathContext context) throws XPathException
context
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expression
ClassCastException
- if the result type of the
expression is not xs:string?public void process(XPathContext context) throws XPathException
context
- The dynamic context, giving access to the current node,
the current variables, etc.
XPathException
public abstract void display(int level, PrintStream out, Configuration config)
level
- indentation level for this expressionout
- Output destinationconfig
- public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException
XPathException
public void setParentExpression(Container parent)
public static void setParentExpression(Expression child, Container parent)
public void adoptChildExpression(Expression child)
Note: many calls on this method are now redundant, but are kept in place for "belt-and-braces" reasons. The rule is that an implementation of simplify(), typeCheck(), or optimize() that returns a value other than "this" is required to set the location information and parent pointer in the new child expression. However, in the past this was often left to the caller, which did it by calling this method, either unconditionally on return from one of these methods, or after testing that the returned object was not the same as the original.
child
- the child expressionpublic void setLocationId(int id)
public final int getLocationId()
public int getLineNumber()
getLineNumber
in interface SourceLocator
public int getColumnNumber()
getColumnNumber
in interface SourceLocator
public String getSystemId()
getSystemId
in interface SourceLocator
public final String getPublicId()
getPublicId
in interface SourceLocator
public Executable getExecutable()
getExecutable
in interface Container
public Procedure getContainingProcedure()
public LocationProvider getLocationProvider()
getLocationProvider
in interface Container
public final Expression doPromotion(Expression subexpression, PromotionOffer offer) throws XPathException
XPathException
public final void computeStaticProperties()
public final void resetStaticProperties()
public int computeSpecialProperties()
public int computeDependencies()
public int getIntrinsicDependencies()
public boolean replaceSubExpression(Expression original, Expression replacement)
replaceSubExpression
in interface Container
original
- the original subexpressionreplacement
- the replacement subexpression
public void suppressValidation(int validationMode)
public int markTailFunctionCalls(int nameCode, int arity)
public int[] getSlotsUsed()
public InstructionInfo getInstructionInfo()
getInstructionInfo
in interface InstructionInfoProvider
public boolean hasBadParentPointer()
public int getHostLanguage()
getHostLanguage
in interface Container
Configuration.XSLT
or Configuration.XQUERY
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |