public class SortExpression extends Expression implements SortKeyEvaluator
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 |
---|
SortExpression(Expression select,
SortKeyDefinitionList sortKeys)
Create a sort expression
|
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
|
int |
computeSpecialProperties()
Get the static properties of this expression (other than its type).
|
Expression |
copy()
Copy an expression.
|
AtomicValue |
evaluateSortKey(int n,
XPathContext c)
Callback for evaluating the sort keys
|
void |
export(ExpressionPresenter out)
Diagnostic print of expression structure.
|
Expression |
getBaseExpression()
Get the expression defining the sequence being sorted
|
Operand |
getBaseOperand()
Get the operand representing the expresion being sorted
|
AtomicComparer[] |
getComparators()
Get the comparators, if known statically.
|
ExpressionCompiler |
getExpressionCompiler()
Return the bytecode compiler for the Sort expression
|
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 items returned by the expression, if possible
|
Expression |
getSelect() |
SortKeyDefinition |
getSortKeyDefinition(int i) |
SortKeyDefinitionList |
getSortKeyDefinitionList() |
StreamingAdjunct |
getStreamingAdjunct()
Get a class that supports streamed evaluation of this expression
|
boolean |
isSortKey(Expression child)
Test whether a given expression is one of the sort keys
|
SequenceIterator |
iterate(XPathContext context)
Enumerate the results of the expression
|
Iterable<Operand> |
operands()
Get the immediate sub-expressions of this expression, with information about the relationship
of each expression to its parent expression.
|
Expression |
optimize(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType)
Perform optimisation of an expression and its subexpressions.
|
Expression |
promote(PromotionOffer offer)
Offer promotion for this subexpression.
|
void |
setSelect(Expression select) |
void |
setSortKeyDefinitionList(SortKeyDefinitionList skd) |
String |
toShortString()
Produce a short string identifying the expression for use in error messages
|
Expression |
typeCheck(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Type-check the expression
|
adoptChildExpression, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, clearStreamabilityData, computeDependencies, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getConstructType, getCost, getDependencies, getEvaluationMethod, getHostLanguage, getIntegerBounds, getIntrinsicDependencies, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getPosture, getPostureAndSweepIfKnown, getProperties, getProperty, getRetainedStaticContext, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStreamability, getSweep, getSystemId, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isCallOnSystemFunction, isIdentical, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterateEvents, makeStreamingAdjunct, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, optimizeForType, process, promoteChildren, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setFiltered, setFlattened, setLocation, setParentExpression, setPostureAndSweep, setRetainedStaticContext, setRetainedStaticContextLocally, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toStreamingPattern, toString, typeCheckChildren, typeError, unordered
public SortExpression(Expression select, SortKeyDefinitionList sortKeys)
select
- the expression whose result is to be sortedsortKeys
- the set of sort key definitions to be used, in major to minor orderpublic String getExpressionName()
getExpressionName
in class Expression
public Operand getBaseOperand()
public Expression getBaseExpression()
public AtomicComparer[] getComparators()
public Iterable<Operand> operands()
operands
in class Expression
public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
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 Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
typeCheck
in class Expression
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 Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
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 Expression
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 Expression copy()
copy
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 boolean isSortKey(Expression child)
child
- the given expressionpublic 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 ItemType getItemType()
getItemType
in class Expression
public int computeSpecialProperties()
computeSpecialProperties
in class Expression
public int getImplementationMethod()
getImplementationMethod
in class Expression
Expression.ITERATE_METHOD
or Expression.EVALUATE_METHOD
or
Expression.PROCESS_METHOD
public SequenceIterator iterate(XPathContext context) throws XPathException
iterate
in class Expression
context
- supplies the context for evaluationXPathException
- if any dynamic error occurs evaluating the
expressionpublic AtomicValue evaluateSortKey(int n, XPathContext c) throws XPathException
evaluateSortKey
in interface SortKeyEvaluator
XPathException
public String toShortString()
Expression
toShortString
in class Expression
public ExpressionCompiler getExpressionCompiler()
getExpressionCompiler
in class Expression
public StreamingAdjunct getStreamingAdjunct()
getStreamingAdjunct
in class Expression
public void export(ExpressionPresenter out)
export
in class Expression
out
- the expression presenter used to display the structurepublic Expression getSelect()
public void setSelect(Expression select)
public SortKeyDefinitionList getSortKeyDefinitionList()
public SortKeyDefinition getSortKeyDefinition(int i)
public void setSortKeyDefinitionList(SortKeyDefinitionList skd)
Copyright (c) 2004-2014 Saxonica Limited. All rights reserved.