public class CompiledExpression extends Expression
GeneratedCode
, to which evaluation is delegatedEFFECTIVE_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 and Description |
---|
CompiledExpression(Expression original,
GeneratedCode byteCode) |
Modifier and Type | Method and Description |
---|---|
PathMap.PathMapNodeSet |
addToPathMap(PathMap pathMap,
PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap.
|
void |
checkForUpdatingSubexpressions()
Check to ensure that this expression does not contain any inappropriate updating subexpressions.
|
void |
checkPermittedContents(SchemaType parentType,
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.
|
protected int |
computeCardinality()
Compute the static cardinality of this expression
|
int |
computeDependencies()
Compute the dependencies of an expression, as the union of the
dependencies of its subexpressions.
|
int |
computeHashCode()
Hashcode supporting equals()
|
protected int |
computeSpecialProperties()
Compute the special properties of this expression.
|
Expression |
copy(RebindingMap rebindings)
Copy an expression.
|
boolean |
effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the expression.
|
boolean |
equals(java.lang.Object other)
Is this expression the same as another expression?
|
Item |
evaluateItem(XPathContext context)
Evaluate an expression as a single item.
|
void |
evaluatePendingUpdates(XPathContext context,
PendingUpdateList pul)
Evaluate an updating expression, adding the results to a Pending Update List.
|
void |
export(ExpressionPresenter out)
Diagnostic print of expression structure.
|
int |
getCardinality()
Determine the static cardinality of the expression.
|
java.lang.String |
getClassName() |
int |
getConstructType()
Get the type of this expression for use in tracing and diagnostics
|
int |
getDependencies()
Determine which aspects of the context the expression depends on.
|
java.lang.String |
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.
|
GeneratedCode |
getGeneratedCode() |
int |
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
|
Expression |
getInterpretedExpression()
Get the original (uncompiled) expression of which this is the compiled form
|
int |
getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived
from the dependencies of its subexpressions.
|
ItemType |
getItemType()
Determine the static item type of the expression, as precisely possible.
|
StructuredQName |
getObjectName() |
java.util.Iterator<java.lang.String> |
getProperties()
Get an iterator over all the properties available.
|
java.lang.Object |
getProperty(java.lang.String name) |
boolean |
isSubtreeExpression()
Determine whether the expression can be evaluated without reference to the part of the context
document outside the subtree rooted at the context node.
|
boolean |
isUpdatingExpression()
Determine whether this is an updating expression as defined in the XQuery update specification
|
boolean |
isVacuousExpression()
Determine whether this is a vacuous expression as defined in the XQuery update specification
|
SequenceIterator<?> |
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence.
|
void |
process(XPathContext context)
Process the instruction, without returning any tail calls
|
void |
setClassName(java.lang.String cname) |
java.lang.String |
toString()
The toString() method for an expression attempts to give a representation of the expression
in an XPath-like form.
|
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, computeStaticProperties, dynamicError, evaluateAsString, explain, getConfiguration, getCost, getEvaluationMethod, getExtraProperty, getIntegerBounds, getLocalRetainedStaticContext, getLocation, getNetCost, getPackageData, getParentExpression, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, markTailFunctionCalls, operandList, operands, operandSparseList, optimize, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toShortString, typeCheck, typeCheckChildren, typeError, unordered, verifyParentPointers
public CompiledExpression(Expression original, GeneratedCode byteCode)
public Expression getInterpretedExpression()
getInterpretedExpression
in class Expression
public GeneratedCode getGeneratedCode()
public void setClassName(java.lang.String cname)
public java.lang.String getClassName()
public java.lang.String getExpressionName()
Expression
getExpressionName
in class Expression
public int getImplementationMethod()
Expression
getImplementationMethod
in class Expression
Expression.ITERATE_METHOD
or Expression.EVALUATE_METHOD
or
Expression.PROCESS_METHOD
public int getCardinality()
Expression
getCardinality
in class Expression
public ItemType getItemType()
Expression
This method should always return a result, though it may be the best approximation that is available at the time.
getItemType
in class Expression
public int getDependencies()
Expression
getDependencies
in class Expression
public void process(XPathContext context) throws XPathException
Expression
process
in class Expression
context
- The dynamic context, giving access to the current node,
the current variables, etc.XPathException
- if a dynamic error occurspublic void evaluatePendingUpdates(XPathContext context, PendingUpdateList pul) throws XPathException
Expression
evaluatePendingUpdates
in class Expression
context
- the XPath dynamic evaluation contextpul
- the pending update list to which the results should be writtenXPathException
- if evaluation failspublic java.lang.String toString()
Expression
The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.
For subclasses of Expression that represent XPath expressions, the result should always be a string that parses as an XPath 3.0 expression. The expression produced should be equivalent to the original making certain assumptions about the static context. In general the expansion will make no assumptions about namespace bindings, except that (a) the prefix "xs" is used to refer to the XML Schema namespace, and (b) the default function namespace is assumed to be the "fn" namespace.
In the case of XSLT instructions and XQuery expressions, the toString() method gives an abstracted view of the syntax that is not designed in general to be parseable.
toString
in class Expression
public void export(ExpressionPresenter out) throws XPathException
Expression
export
in interface ExportAgent
export
in class Expression
out
- the expression presenter used to display the structureXPathException
- if the export fails, for example if an expression is found that won't work
in the target environment.public void checkPermittedContents(SchemaType parentType, boolean whole) throws XPathException
Expression
checkPermittedContents
in class Expression
parentType
- the "given complex type": the method is checking that the nodes returned by this
expression are acceptable members of the content model of this typewhole
- if true, we want to check that the value of this expression satisfies the content model
as a whole; if false we want to check that the value of the expression is acceptable as one part
of the contentXPathException
- if the value delivered by this expression cannot be part of the content model
of the given typeprotected int computeCardinality()
Expression
computeCardinality
in class Expression
StaticProperty.ALLOWS_ZERO_OR_ONE
,
StaticProperty.EXACTLY_ONE
, StaticProperty.ALLOWS_ONE_OR_MORE
,
StaticProperty.ALLOWS_ZERO_OR_MORE
. May also return StaticProperty.ALLOWS_ZERO
if
the result is known to be an empty sequence, or StaticProperty.ALLOWS_MANY
if
if is known to return a sequence of length two or more.protected int computeSpecialProperties()
Expression
StaticProperty
. The "special" properties are properties
other than cardinality and dependencies, and most of them relate to properties of node sequences, for
example whether the nodes are in document order.computeSpecialProperties
in class Expression
public int computeDependencies()
Expression
computeDependencies
in class Expression
public int getIntrinsicDependencies()
Expression
getIntrinsicDependencies
in class Expression
public void checkForUpdatingSubexpressions() throws XPathException
Expression
checkForUpdatingSubexpressions
in class Expression
XPathException
- if the expression has a non-permitted updating subexpressionpublic boolean isUpdatingExpression()
Expression
isUpdatingExpression
in class Expression
public boolean isVacuousExpression()
Expression
isVacuousExpression
in class Expression
public Expression copy(RebindingMap rebindings)
Expression
copy
in class Expression
rebindings
- a mutable list of (old binding, new binding) pairs
that is used to update the bindings held in any
local variable references that are copied.public int getConstructType()
Expression
getConstructType
in class Expression
LocationKind
public StructuredQName getObjectName()
getObjectName
in class Expression
public boolean equals(java.lang.Object other)
equals
in class Expression
other
- the expression to be compared with this onepublic int computeHashCode()
computeHashCode
in class Expression
public java.lang.Object getProperty(java.lang.String name)
getProperty
in class Expression
public java.util.Iterator<java.lang.String> getProperties()
Expression
getProperties
in class Expression
public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
Expression
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 addedpublic boolean isSubtreeExpression()
Expression
isSubtreeExpression
in class Expression
public SequenceIterator<?> iterate(XPathContext context) throws XPathException
Expression
iterate
in class Expression
context
- supplies the context for evaluationXPathException
- if any dynamic error occurs evaluating the
expressionpublic Item evaluateItem(XPathContext context) throws XPathException
Expression
evaluateItem
in class Expression
context
- The context in which the expression is to be evaluatedXPathException
- if any dynamic error occurs evaluating the
expressionpublic boolean effectiveBooleanValue(XPathContext context) throws XPathException
Expression
effectiveBooleanValue
in class Expression
context
- The context in which the expression is to be evaluatedXPathException
- if any dynamic error occurs evaluating the
expressionCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.