Class JAXPVariableReference
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.xpath.JAXPVariableReference
-
- All Implemented Interfaces:
Callable
,ExportAgent
,Locatable
,IdentityComparable
,Traceable
public class JAXPVariableReference extends Expression implements Callable
This class represents a variable in an XPath expression compiled using the JAXP XPath API. Although the class name suggests otherwise, the expression is not in fact a VariableReference; it's a custom expression which, on evaluation, calls the JAXP XPathVariableResolver to get the value of the variable.
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
-
-
Constructor Summary
Constructors Constructor Description JAXPVariableReference(StructuredQName name, javax.xml.xpath.XPathVariableResolver resolver)
Create the expression
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Sequence
call(XPathContext context, Sequence[] arguments)
Call the Callable.protected int
computeCardinality()
Get the static cardinalityprotected int
computeHashCode()
get HashCode for comparing two expressionsprotected int
computeSpecialProperties()
Determine the special properties of this expressionExpression
copy(RebindingMap rebindings)
Create a clone copy of this expressionboolean
equals(java.lang.Object other)
Is this expression the same as another expression?void
export(ExpressionPresenter destination)
Diagnostic print of expression structure.java.lang.String
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.int
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().ItemType
getItemType()
Determine the item typeSequenceIterator
iterate(XPathContext context)
Iterate over the value of the expressionjava.lang.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.-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operands, operandSparseList, optimize, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toShortString, typeCheck, typeCheckChildren, typeError, unordered, verifyParentPointers
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
-
-
-
Constructor Detail
-
JAXPVariableReference
public JAXPVariableReference(StructuredQName name, javax.xml.xpath.XPathVariableResolver resolver)
Create the expression- Parameters:
name
- the name of the expressionresolver
- the JAXP XPathVariableResolver
-
-
Method Detail
-
getExpressionName
public java.lang.String getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionName
in classExpression
- Returns:
- a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in explain() output displaying the expression.
-
copy
public Expression copy(RebindingMap rebindings)
Create a clone copy of this expression- Specified by:
copy
in classExpression
- Parameters:
rebindings
- the rebinding map- Returns:
- a copy of this expression
-
getItemType
public ItemType getItemType()
Determine the item type- Specified by:
getItemType
in classExpression
- Returns:
- a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)
-
computeCardinality
protected int computeCardinality()
Get the static cardinality- Specified by:
computeCardinality
in classExpression
- Returns:
- the computed cardinality, as one of the values
StaticProperty.ALLOWS_ZERO_OR_ONE
,StaticProperty.EXACTLY_ONE
,StaticProperty.ALLOWS_ONE_OR_MORE
,StaticProperty.ALLOWS_ZERO_OR_MORE
. May also returnStaticProperty.ALLOWS_ZERO
if the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANY
if if is known to return a sequence of length two or more.
-
computeSpecialProperties
protected int computeSpecialProperties()
Determine the special properties of this expression- Overrides:
computeSpecialProperties
in classExpression
- Returns:
- the value
StaticProperty.NO_NODES_NEWLY_CREATED
-
getImplementationMethod
public int getImplementationMethod()
Description copied from class:Expression
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.- Specified by:
getImplementationMethod
in classExpression
- Returns:
- the implementation method, for example
Expression.ITERATE_METHOD
orExpression.EVALUATE_METHOD
orExpression.PROCESS_METHOD
-
equals
public boolean equals(java.lang.Object other)
Is this expression the same as another expression?- Overrides:
equals
in classExpression
- Parameters:
other
- the other operand; the result is false if this is not an Expression- Returns:
- true if the other operand is an expression and if it can be determined that the two expressions are equivalent, in the sense that they will always return the same result.
-
computeHashCode
protected int computeHashCode()
get HashCode for comparing two expressions- Overrides:
computeHashCode
in classExpression
- Returns:
- a computed hash code
-
call
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException
Description copied from interface:Callable
Call the Callable.- Specified by:
call
in interfaceCallable
- Parameters:
context
- the dynamic evaluation contextarguments
- the values of the arguments, supplied as Sequences.Generally it is advisable, if calling iterate() to process a supplied sequence, to call it only once; if the value is required more than once, it should first be converted to a
GroundedValue
by calling the utility method SequenceTool.toGroundedValue().If the expected value is a single item, the item should be obtained by calling Sequence.head(): it cannot be assumed that the item will be passed as an instance of
Item
orAtomicValue
.It is the caller's responsibility to perform any type conversions required to convert arguments to the type expected by the callee. An exception is where this Callable is explicitly an argument-converting wrapper around the original Callable.
- Returns:
- the result of the evaluation, in the form of a Sequence. It is the responsibility of the callee to ensure that the type of result conforms to the expected result type.
- Throws:
XPathException
- if a dynamic error occurs during the evaluation of the expression
-
iterate
public SequenceIterator iterate(XPathContext context) throws XPathException
Iterate over the value of the expression- Overrides:
iterate
in classExpression
- Parameters:
context
- supplies the context for evaluation- Returns:
- a SequenceIterator that can be used to iterate over the result of the expression
- Throws:
XPathException
- if any dynamic error occurs evaluating the expression
-
toString
public java.lang.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. In the case of XSLT instructions, the toString() method gives an abstracted view of the syntax- Overrides:
toString
in classExpression
- Returns:
- a representation of the expression as a string
-
export
public void export(ExpressionPresenter destination) throws XPathException
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Specified by:
export
in classExpression
- Parameters:
destination
- the expression presenter used to display the structure- Throws:
XPathException
- if the export fails, for example if an expression is found that won't work in the target environment.
-
-