public class SwitchExpression extends Expression implements TailCallReturner, ConditionalInstruction
Modifier and Type | Class and Description |
---|---|
static class |
SwitchExpression.SwitchCaseInfo
Data structure used for holding details of a switch expression
|
Modifier and Type | Field and Description |
---|---|
static OperandRole |
SUBJECT |
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 |
---|
SwitchExpression(SwitchExpression.SwitchCaseInfo switchCaseInfo)
Create a switch expression
|
Modifier and Type | Method and Description |
---|---|
boolean |
allowExtractingCommonSubexpressions()
Ask whether common subexpressions found in the operands of this expression can
be extracted and evaluated outside the expression itself.
|
protected int |
computeCardinality()
Compute the static cardinality of this expression
|
Expression |
copy(RebindingMap rebindings)
Copy an expression.
|
Item |
evaluateItem(XPathContext context)
Evaluate an expression as a single item.
|
void |
export(ExpressionPresenter out)
Diagnostic print of expression structure.
|
Operand |
getAction(int index) |
java.util.List<Operand> |
getActions() |
java.util.Map<AtomicMatchKey,java.lang.Integer> |
getCaseMap()
Get the map from XPathComparable objects representing the values to the expressions
to be executed for each of these values
|
StringCollator |
getCollation()
Get the collation used
|
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 data type of the expression, if possible.
|
Expression |
getOtherwiseExpression()
Get the default ("otherwise") expression
|
Operand |
getOtherwiseOperand() |
java.lang.String |
getStreamerName()
Get the (partial) name of a class that supports streaming of this kind of expression
|
Expression |
getSubjectExpression()
Get the subject expression (the expression that computes the switch value)
|
boolean |
isInstruction()
Ask whether this expression is an instruction.
|
SequenceIterator<?> |
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence.
|
java.lang.Iterable<Operand> |
operands()
Get the immediate sub-expressions of this expression, with information about the relationship
of each expression to its parent expression.
|
void |
process(XPathContext context)
Process the instruction, without returning any tail calls
|
TailCall |
processLeavingTail(XPathContext context)
ProcessLeavingTail: called to do the real work of this instruction.
|
void |
setInstruction(boolean inst)
Say whether this switch expression originates as an XSLT instruction
|
Expression |
unordered(boolean retainAllNodes,
boolean forStreaming)
Replace this expression by a simpler expression that delivers the results without regard
to order.
|
addToPathMap, adoptChildExpression, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeSpecialProperties, computeStaticProperties, dynamicError, effectiveBooleanValue, equals, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getConstructType, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimize, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toShortString, toString, typeCheck, typeCheckChildren, typeError, verifyParentPointers
public static final OperandRole SUBJECT
public SwitchExpression(SwitchExpression.SwitchCaseInfo switchCaseInfo)
switchCaseInfo
- details of the expression to be constructedpublic void setInstruction(boolean inst)
inst
- true if this started life as an xsl:choose instructionpublic boolean isInstruction()
isInstruction
in class Expression
public Expression getSubjectExpression()
public java.util.Map<AtomicMatchKey,java.lang.Integer> getCaseMap()
public Expression getOtherwiseExpression()
public Operand getAction(int index)
public java.util.List<Operand> getActions()
public Operand getOtherwiseOperand()
public java.lang.Iterable<Operand> operands()
Expression
If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.
operands
in class Expression
public StringCollator getCollation()
protected int computeCardinality()
computeCardinality
in class Expression
StaticProperty.ALLOWS_ZERO_OR_ONE
,
StaticProperty.EXACTLY_ONE
, StaticProperty.ALLOWS_ONE_OR_MORE
,
StaticProperty.ALLOWS_ZERO_OR_MORE
public boolean allowExtractingCommonSubexpressions()
allowExtractingCommonSubexpressions
in class Expression
public Expression copy(RebindingMap rebindings)
copy
in class Expression
rebindings
- variables that need to be re-boundpublic void export(ExpressionPresenter out) throws XPathException
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 ItemType getItemType()
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 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 Item evaluateItem(XPathContext context) throws XPathException
evaluateItem
in class Expression
context
- The context in which the expression is to be evaluatedXPathException
- if any dynamic error occurs evaluating the
expressionpublic SequenceIterator<?> iterate(XPathContext context) throws XPathException
iterate
in class Expression
context
- supplies the context for evaluationXPathException
- if any dynamic error occurs evaluating the
expressionpublic void process(XPathContext context) throws XPathException
process
in class Expression
context
- The dynamic context, giving access to the current node,
the current variables, etc.XPathException
- if a dynamic error occurspublic TailCall processLeavingTail(XPathContext context) throws XPathException
TailCallReturner
processLeavingTail
in interface TailCallReturner
context
- The dynamic context of the transformation, giving access to the current node,
the current variables, etc.XPathException
- if a dynamic error occurs during the evaluation
of the instructionpublic int getImplementationMethod()
Expression
getImplementationMethod
in class Expression
Expression.ITERATE_METHOD
or Expression.EVALUATE_METHOD
or
Expression.PROCESS_METHOD
public java.lang.String getExpressionName()
getExpressionName
in class Expression
public java.lang.String getStreamerName()
Expression
getStreamerName
in class Expression
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.