|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.xpath.JAXPVariable
public final class JAXPVariable
An object representing an XPath variable for use in the JAXP XPath API. The object is created at compile time when the parser tries to bind a variable reference; the value is fetched at run-time from the XPathVariableResolver. With this interface, there is no way of reporting a static error if the variable has not been declared.
In Saxon terms, this class is both a VariableDeclaration and a Binding. Unlike a normal VariableDeclaration, it isn't created in advance, but is created on demand when the parser encounters a variable reference. This actually means that if the XPath expression contains two references to the same variable, two VariableDeclarations will be created; however, they will be indistinguishable to the VariableResolver. Acting as a VariableDeclaration, the object goes through the motions of fixing up a binding to a variable reference (in practice, of course, there is exactly one reference to the variable). Acting as a run-time binding, it then evaluates the variable by calling the XPathVariableResolver supplied by the API caller. If no XPathVariableResolver was supplied, an error is reported when a variable is encountered; but if the variable resolver doesn't recognize the variable name, it returns null, which is treated as an empty sequence.
Constructor Summary | |
---|---|
protected |
JAXPVariable(StructuredQName name,
XPathVariableResolver resolver)
Private constructor: for use only be the protected factory method make() |
Method Summary | |
---|---|
void |
addReference(boolean isLoopingReference)
Register a variable reference that refers to the variable bound in this expression |
ValueRepresentation |
evaluateVariable(XPathContext context)
Get the value of the variable. |
IntegerValue[] |
getIntegerBoundsForVariable()
If the variable is bound to an integer, get the minimum and maximum possible values. |
int |
getLocalSlotNumber()
If this is a local variable held on the local stack frame, return the corresponding slot number. |
SequenceType |
getRequiredType()
Get the declared type of the variable |
StructuredQName |
getVariableQName()
Get the name of the variable as a structured QName |
boolean |
isAssignable()
Test whether it is permitted to assign to the variable using the saxon:assign extension element. |
boolean |
isGlobal()
Indicate whether the binding is local or global. |
void |
registerReference(BindingReference ref)
Method called by the XPath expression parser to register a reference to this variable. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected JAXPVariable(StructuredQName name, XPathVariableResolver resolver)
name
- the name of the variableresolver
- the resolver used in conjunction with this variableMethod Detail |
---|
public SequenceType getRequiredType()
Binding
getRequiredType
in interface Binding
public boolean isGlobal()
isGlobal
in interface Binding
public final boolean isAssignable()
isAssignable
in interface Binding
public int getLocalSlotNumber()
getLocalSlotNumber
in interface Binding
public StructuredQName getVariableQName()
getVariableQName
in interface Binding
getVariableQName
in interface VariableDeclaration
public void addReference(boolean isLoopingReference)
Binding
addReference
in interface Binding
isLoopingReference
- - true if the reference occurs within a loop, such as the predicate
of a filter expressionpublic void registerReference(BindingReference ref)
registerReference
in interface VariableDeclaration
ref
- the variable referencepublic ValueRepresentation evaluateVariable(XPathContext context) throws XPathException
evaluateVariable
in interface Binding
context
- The dynamic evaluation context
XPathException
- if an error occurs while evaluating
the variablepublic IntegerValue[] getIntegerBoundsForVariable()
getIntegerBoundsForVariable
in interface Binding
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |