public class SwitchExpression extends Expression
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_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
Constructor and Description |
---|
SwitchExpression(Expression commonlhs,
Map<AtomicMatchKey,Operand> cases,
Expression otherwise,
StringCollator collation) |
SwitchExpression(SwitchExpression.SwitchCaseInfo switchCaseInfo)
Create a switch expression
|
Modifier and Type | Method and Description |
---|---|
protected int |
computeCardinality()
Compute the static cardinality of this expression
|
Expression |
copy()
Copy an expression.
|
Item |
evaluateItem(XPathContext context)
Evaluate an expression as a single item.
|
void |
export(ExpressionPresenter out)
Diagnostic print of expression structure.
|
Map<AtomicMatchKey,Operand> |
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
|
ExpressionCompiler |
getExpressionCompiler()
Return the compiler of the Switch expression
|
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
|
Expression |
getSubjectExpression()
Get the subject expression (the expression that computes the switch value)
|
SequenceIterator |
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence.
|
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
|
Expression |
promote(PromotionOffer offer)
Offer promotion for this subexpression.
|
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, clearStreamabilityData, computeDependencies, computeSpecialProperties, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getConstructType, getCost, getDependencies, getEvaluationMethod, getExpressionName, getHostLanguage, getIntegerBounds, getIntrinsicDependencies, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getPosture, getPostureAndSweepIfKnown, getProperties, getProperty, getRetainedStaticContext, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStreamability, getStreamingAdjunct, getSweep, getSystemId, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isCallOnSystemFunction, isIdentical, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterateEvents, makeStreamingAdjunct, markTailFunctionCalls, operandList, operandSparseList, optimize, optimizeChildren, optimizeForType, promoteChildren, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setFiltered, setFlattened, setLocation, setParentExpression, setPostureAndSweep, setRetainedStaticContext, setRetainedStaticContextLocally, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toShortString, toStreamingPattern, toString, typeCheck, typeCheckChildren, typeError
public static final OperandRole SUBJECT
public SwitchExpression(SwitchExpression.SwitchCaseInfo switchCaseInfo)
switchCaseInfo
- details of the expression to be constructedpublic SwitchExpression(Expression commonlhs, Map<AtomicMatchKey,Operand> cases, Expression otherwise, StringCollator collation)
public Expression getSubjectExpression()
public Map<AtomicMatchKey,Operand> getCaseMap()
public Expression getOtherwiseExpression()
public 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 Expression copy()
copy
in class Expression
public void export(ExpressionPresenter out)
export
in class Expression
out
- the expression presenter used to display the structurepublic 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 promote(PromotionOffer offer) throws XPathException
promote
in class Expression
offer
- details of the offer, for example the offer to move
expressions that don't depend on the context to an outer level in
the containing expressionXPathException
- if any 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 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 int getImplementationMethod()
Expression
getImplementationMethod
in class Expression
Expression.ITERATE_METHOD
or Expression.EVALUATE_METHOD
or
Expression.PROCESS_METHOD
public ExpressionCompiler getExpressionCompiler()
getExpressionCompiler
in class Expression
Copyright (c) 2004-2014 Saxonica Limited. All rights reserved.