public class SlashExpression extends BinaryExpression implements ContextSwitchingExpression
operator
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 and Description |
---|
SlashExpression(Expression start,
Expression step)
Constructor
|
Modifier and Type | Method and Description |
---|---|
PathMap.PathMapNodeSet |
addToPathMap(PathMap pathMap,
PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap.
|
int |
computeCardinality()
Determine the static cardinality of the expression
|
int |
computeHashCode()
get HashCode for comparing two expressions
|
int |
computeSpecialProperties()
Get the static properties of this expression (other than its type).
|
Expression |
copy(RebindingMap rebindings)
Copy an expression.
|
boolean |
equals(java.lang.Object other)
Is this expression the same as another expression?
|
void |
export(ExpressionPresenter destination)
Diagnostic print of expression structure.
|
Expression |
getActionExpression()
Get the step expression (the right-hand operand)
|
double |
getCost()
Return the estimated cost of evaluating an expression.
|
java.lang.String |
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.
|
Expression |
getFirstStep()
Get the first step in this expression.
|
int |
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
|
IntegerValue[] |
getIntegerBounds()
For an expression that returns an integer or a sequence of integers, get
a lower and upper bound on the values of the integers that may be returned, from
static analysis.
|
ItemType |
getItemType()
Determine the data type of the items returned by this exprssion
|
Expression |
getLastStep()
Get the last step of the path expression
|
Expression |
getLeadingSteps()
Get a path expression consisting of all steps except the last
|
protected OperandRole |
getOperandRole(int arg)
Get the operand role
|
Expression |
getRemainingSteps()
Get all steps after the first.
|
Expression |
getSelectExpression()
Get the start expression (the left-hand operand)
|
Expression |
getStart()
Get the left-hand operand
|
UType |
getStaticUType(UType contextItemType)
Get the static type of the expression as a UType, following precisely the type
inference rules defined in the XSLT 3.0 specification.
|
Expression |
getStep()
Get the right-hand operand
|
java.lang.String |
getStreamerName()
Get the (partial) name of a class that supports streaming of this kind of expression
|
boolean |
isAbsolute()
Test whether a path expression is an absolute path - that is, a path whose first step selects a
document node
|
boolean |
isContextFree()
A SlashExpression is context free if the right-hand argument is an AxisExpression.
|
SequenceIterator<?> |
iterate(XPathContext context)
Iterate the path-expression in a given context
|
Expression |
optimize(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType)
Perform optimisation of an expression and its subexpressions.
|
protected Expression |
promoteFocusIndependentSubexpressions(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType)
If any subexpressions within the step are not dependent on the focus,
and if they are not "creative" expressions (expressions that can create new nodes), then
promote them: this causes them to be evaluated once, outside the path expression
|
void |
setContextFree(boolean free)
Mark this expression as being context free (or not).
|
void |
setStart(Expression start)
Set the left-hand operand
|
void |
setStep(Expression step)
Set the right-hand operand
|
SlashExpression |
simplifyDescendantPath(StaticContext env) |
Pattern |
toPattern(Configuration config)
Convert this expression to an equivalent XSLT pattern
|
java.lang.String |
toShortString()
Produce a short string identifying the expression for use in error messages
|
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.
|
SlashExpression |
tryToMakeAbsolute()
Test whether a path expression is an absolute path - that is, a path whose first step selects a
document node; if not, see if it can be converted to an absolute path.
|
Expression |
tryToMakeSorted(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType) |
Expression |
typeCheck(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Type-check the expression
|
Expression |
unordered(boolean retainAllNodes,
boolean forStreaming)
Replace this expression by a simpler expression that delivers the results without regard
to order.
|
displayOperator, explainExtraAttributes, getLhs, getLhsExpression, getOperator, getRhs, getRhsExpression, isAssociative, isCommutative, isInverse, operands, setFlattened, setLhsExpression, setRhsExpression, tag
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getConstructType, getDependencies, getEvaluationMethod, getExtraProperty, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, typeCheckChildren, typeError, verifyParentPointers
public SlashExpression(Expression start, Expression step)
start
- The left hand operand (which must always select a sequence of nodes).step
- The step to be followed from each node in the start expression to yield a new
sequence; this may return either nodes or atomic values (but not a mixture of the two)protected OperandRole getOperandRole(int arg)
BinaryExpression
getOperandRole
in class BinaryExpression
arg
- which argument: 0 for the lhs, 1 for the rhspublic Expression getStart()
public void setStart(Expression start)
start
- the left-hand operandpublic Expression getStep()
public void setStep(Expression step)
step
- the right-hand operandpublic java.lang.String getExpressionName()
Expression
getExpressionName
in class Expression
public Expression getSelectExpression()
getSelectExpression
in interface ContextSwitchingExpression
public Expression getActionExpression()
getActionExpression
in interface ContextSwitchingExpression
public final ItemType getItemType()
getItemType
in class Expression
public UType getStaticUType(UType contextItemType)
getStaticUType
in class Expression
contextItemType
- public IntegerValue[] getIntegerBounds()
getIntegerBounds
in class Expression
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
typeCheck
in class BinaryExpression
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly)
absent; its static type; its streaming posture.XPathException
- if an error is discovered during this phase
(typically a type error)public SlashExpression simplifyDescendantPath(StaticContext env)
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
BinaryExpression
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.
optimize
in class BinaryExpression
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 SlashExpression tryToMakeAbsolute()
public double getCost()
getCost
in class Expression
public Expression tryToMakeSorted(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
XPathException
protected Expression promoteFocusIndependentSubexpressions(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
visitor
- the expression visitorcontextItemType
- the type of the context item for evaluating the start expressionXPathException
- if a static error is detectedpublic Expression unordered(boolean retainAllNodes, boolean forStreaming) throws XPathException
unordered
in class Expression
retainAllNodes
- set to true if the result must contain exactly the same nodes as the
original; set to false if the result can eliminate (or introduce) duplicates.forStreaming
- set to true if optimizing for streamingXPathException
- if the rewrite failspublic PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
addToPathMap
in class Expression
pathMap
- the PathMap to which the expression should be addedpathMapNodeSet
- public int getImplementationMethod()
getImplementationMethod
in class BinaryExpression
Expression.ITERATE_METHOD
or Expression.EVALUATE_METHOD
or
Expression.PROCESS_METHOD
public Expression copy(RebindingMap rebindings)
copy
in class Expression
rebindings
- public int computeSpecialProperties()
computeSpecialProperties
in class BinaryExpression
StaticProperty.NO_NODES_NEWLY_CREATED
. This is overridden
for some subclasses.public int computeCardinality()
computeCardinality
in class BinaryExpression
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.public Pattern toPattern(Configuration config) throws XPathException
toPattern
in class Expression
config
- the Saxon configurationXPathException
- if conversion is not possiblepublic boolean isContextFree()
public void setContextFree(boolean free)
free
- true if the expression has been assessed as context-free, that is, if the
right-hand operand is an AxisExpressionpublic boolean equals(java.lang.Object other)
equals
in class BinaryExpression
other
- the other operand; the result is false if this is not an Expressionpublic int computeHashCode()
computeHashCode
in class BinaryExpression
public SequenceIterator<?> iterate(XPathContext context) throws XPathException
iterate
in class Expression
context
- the evaluation contextXPathException
- if any dynamic error occurs evaluating the
expressionpublic void export(ExpressionPresenter destination) throws XPathException
export
in interface ExportAgent
export
in class BinaryExpression
destination
- the output destination for the displayed expression treeXPathException
- if the export fails, for example if an expression is found that won't work
in the target environment.public java.lang.String toString()
toString
in class BinaryExpression
public java.lang.String toShortString()
Expression
toShortString
in class BinaryExpression
public Expression getFirstStep()
public Expression getRemainingSteps()
public Expression getLastStep()
public Expression getLeadingSteps()
public boolean isAbsolute()
public java.lang.String getStreamerName()
getStreamerName
in class Expression
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.