|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.expr.Expression net.sf.saxon.expr.VariableReference
public class VariableReference
Variable reference: a reference to a variable. This may be an XSLT-defined variable, a range variable defined within the XPath expression, or a variable defined in some other static context.
Field Summary |
---|
Fields inherited from class net.sf.saxon.expr.Expression |
---|
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD |
Constructor Summary | |
---|---|
VariableReference()
Create a Variable Reference |
|
VariableReference(Binding binding)
Create a Variable Reference |
Method Summary | |
---|---|
PathMap.PathMapNodeSet |
addToPathMap(PathMap pathMap,
PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap. |
int |
computeCardinality()
Get the static cardinality |
int |
computeSpecialProperties()
Determine the special properties of this expression |
Expression |
copy()
Create a clone copy of this VariableReference |
boolean |
equals(Object other)
Test if this expression is the same as another expression. |
Item |
evaluateItem(XPathContext c)
Evaluate an expression as a single item. |
ValueRepresentation |
evaluateVariable(XPathContext c)
Evaluate this variable |
void |
explain(ExpressionPresenter destination)
Diagnostic print of expression structure. |
void |
fixup(Binding binding)
Fix up this variable reference to a Binding object, which enables the value of the variable to be located at run-time. |
Binding |
getBinding()
Get the object bound to the variable |
String |
getDisplayName()
Get the display name of the variable. |
int |
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). |
int |
getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. |
ItemType |
getItemType(TypeHierarchy th)
Determine the data type of the expression, if possible |
int |
hashCode()
get HashCode for comparing two expressions |
boolean |
isFiltered()
Determine whether this variable reference is filtered |
boolean |
isFlattened()
Test whether this variable reference is flattened - that is, whether it is atomized etc |
boolean |
isInLoop()
Determine whether this variable reference appears in a loop relative to its declaration. |
SequenceIterator |
iterate(XPathContext c)
Get the value of this variable in a given context. |
Expression |
optimize(ExpressionVisitor visitor,
ItemType contextItemType)
Type-check the expression. |
void |
process(XPathContext c)
Process the instruction, without returning any tail calls |
Expression |
promote(PromotionOffer offer)
Promote this expression if possible |
void |
refineVariableReference(Expression parent)
Replace this VariableReference where appropriate by a more efficient implementation. |
void |
refineVariableType(ItemType type,
int cardinality,
Value constantValue,
int properties,
ExpressionVisitor visitor)
|
void |
setFiltered(boolean filtered)
Mark an expression as filtered: that is, it appears as the base expression in a filter expression. |
void |
setFlattened(boolean flattened)
Mark an expression as being "flattened". |
void |
setStaticType(SequenceType type,
Value value,
int properties)
Set static type. |
String |
toString()
The toString() method for an expression attempts to give a representation of the expression in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath. |
Expression |
typeCheck(ExpressionVisitor visitor,
ItemType contextItemType)
Type-check the expression. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public VariableReference()
public VariableReference(Binding binding)
binding
- the variable binding to which this variable refersMethod Detail |
---|
public Expression copy()
copy
in class Expression
public void setStaticType(SequenceType type, Value value, int properties)
setStaticType
in interface BindingReference
type
- the static type of the variablevalue
- the value of the variable if this is a compile-time constantproperties
- static properties of the expression to which the variable is boundpublic void setFlattened(boolean flattened)
setFlattened
in class Expression
flattened
- set to true if the result of the expression is atomized or otherwise turned into
an atomic valuepublic boolean isFlattened()
public void setFiltered(boolean filtered)
setFiltered
in class Expression
filtered
- if true, marks this expression as the base of a filter expressionpublic boolean isFiltered()
public boolean isInLoop()
public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException
typeCheck
in class Expression
visitor
- an expression visitorcontextItemType
- 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
XPathException
- if an error is discovered during this phase
(typically a type error)public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException
optimize
in class Expression
visitor
- an expression visitorcontextItemType
- 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
XPathException
- if an error is discovered during this phase
(typically a type error)public void fixup(Binding binding)
fixup
in interface BindingReference
public void refineVariableType(ItemType type, int cardinality, Value constantValue, int properties, ExpressionVisitor visitor)
public void refineVariableReference(Expression parent)
parent
- the parent expression of this variable referencepublic ItemType getItemType(TypeHierarchy th)
getItemType
in class Expression
th
- the type hierarchy cache
public int computeCardinality()
StaticProperty.ALLOWS_ZERO_OR_ONE
,
StaticProperty.EXACTLY_ONE
, StaticProperty.ALLOWS_ONE_OR_MORE
,
StaticProperty.ALLOWS_ZERO_OR_MORE
public int computeSpecialProperties()
StaticProperty.NON_CREATIVE
(unless the variable is assignable using saxon:assign)public boolean equals(Object other)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int getIntrinsicDependencies()
Expression
getIntrinsicDependencies
in class Expression
public Expression promote(PromotionOffer offer) throws XPathException
promote
in class Expression
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 int getImplementationMethod()
getImplementationMethod
in class Expression
Expression.ITERATE_METHOD
or Expression.EVALUATE_METHOD
or
Expression.PROCESS_METHOD
public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
The default implementation of this method assumes that an expression does no navigation other than the navigation done by evaluating its subexpressions, and that the subexpressions are evaluated in the same context as the containing expression. The method must be overridden for any expression where these assumptions do not hold. For example, implementations exist for AxisExpression, ParentExpression, and RootExpression (because they perform navigation), and for the doc(), document(), and collection() functions because they create a new navigation root. Implementations also exist for PathExpression and FilterExpression because they have subexpressions that are evaluated in a different context from the calling expression.
addToPathMap
in class Expression
pathMap
- the PathMap to which the expression should be addedpathMapNodeSet
- the PathMapNodeSet to which the paths embodied in this expression should be added
public SequenceIterator iterate(XPathContext c) throws XPathException
iterate
in interface SequenceIterable
iterate
in class Expression
c
- the XPathContext which contains the relevant variable bindings
XPathException
- if the variable is undefinedpublic Item evaluateItem(XPathContext c) throws XPathException
Expression
evaluateItem
in interface EvaluableItem
evaluateItem
in class Expression
c
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expressionpublic void process(XPathContext c) throws XPathException
Expression
process
in class Expression
c
- The dynamic context, giving access to the current node,
the current variables, etc.
XPathException
public ValueRepresentation evaluateVariable(XPathContext c) throws XPathException
c
- the XPath dynamic context
XPathException
- if any error occurspublic Binding getBinding()
public String getDisplayName()
public String toString()
toString
in class Expression
public void explain(ExpressionPresenter destination)
explain
in class Expression
destination
- the expression presenter used to display the structure
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |