net.sf.saxon.sort

Class DocumentSorter

Implemented Interfaces:
EvaluableItem, InstructionInfoProvider, SequenceIterable, Serializable, SourceLocator

public class DocumentSorter
extends UnaryExpression

A DocumentSorter is an expression that sorts a sequence of nodes into document order.

Field Summary

Fields inherited from class net.sf.saxon.expr.UnaryExpression

operand

Fields inherited from class net.sf.saxon.expr.Expression

EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD, locationId, staticProperties

Constructor Summary

DocumentSorter(Expression base)

Method Summary

int
computeSpecialProperties()
Compute the special properties of this expression.
Expression
copy()
Copy an expression.
boolean
effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the expression.
void
explain(ExpressionPresenter out)
Diagnostic print of expression structure.
NodeOrderComparer
getComparer()
SequenceIterator
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence.
Expression
optimize(ExpressionVisitor visitor, ItemType contextItemType)
Perform optimisation of an expression and its subexpressions.
Expression
promote(PromotionOffer offer)
Promote this expression if possible
Expression
simplify(ExpressionVisitor visitor)
Simplify an expression.

Methods inherited from class net.sf.saxon.expr.UnaryExpression

computeCardinality, computeSpecialProperties, displayExpressionName, displayOperator, equals, explain, getBaseExpression, getItemType, hashCode, iterateSubExpressions, optimize, promote, replaceSubExpression, simplify, toString, typeCheck

Methods inherited from class net.sf.saxon.expr.Expression

addToPathMap, adoptChildExpression, checkPermittedContents, computeCardinality, computeDependencies, computeSpecialProperties, computeStaticProperties, copy, display, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, explain, explain, findParentOf, getCardinality, getColumnNumber, getConstructType, getContainer, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getInstructionInfo, getIntrinsicDependencies, getItemType, getLineNumber, getLocationId, getLocationProvider, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, iterate, iterateEvents, iterateSubExpressions, markTailFunctionCalls, optimize, process, promote, replaceSubExpression, resetLocalStaticProperties, setContainer, setFiltered, setFlattened, setLocationId, simplify, staticTypeCheck, suppressValidation, toString, typeCheck, typeError

Constructor Details

DocumentSorter

public DocumentSorter(Expression base)

Method Details

computeSpecialProperties

public int computeSpecialProperties()
Compute the special properties of this expression. These properties are denoted by a bit-significant integer, possible values are in class 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.
Overrides:
computeSpecialProperties in interface UnaryExpression
Returns:
the special properties, as a bit-significant integer

copy

public Expression copy()
Copy an expression. This makes a deep copy.
Overrides:
copy in interface Expression
Returns:
the copy of the original expression

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
            throws XPathException
Get the effective boolean value of the expression. This returns false if the value is the empty sequence, a zero-length string, a number equal to zero, or the boolean false. Otherwise it returns true.
Overrides:
effectiveBooleanValue in interface Expression
Parameters:
context - The context in which the expression is to be evaluated
Returns:
the effective boolean value
Throws:
XPathException - if any dynamic error occurs evaluating the expression

explain

public void explain(ExpressionPresenter out)
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
Overrides:
explain in interface UnaryExpression

getComparer

public NodeOrderComparer getComparer()

iterate

public SequenceIterator iterate(XPathContext context)
            throws XPathException
Return an Iterator to iterate over the values of a sequence. The value of every expression can be regarded as a sequence, so this method is supported for all expressions. This default implementation handles iteration for expressions that return singleton values: for non-singleton expressions, the subclass must provide its own implementation.
Specified by:
iterate in interface SequenceIterable
Overrides:
iterate in interface Expression
Parameters:
context - supplies the context for evaluation
Returns:
a SequenceIterator that can be used to iterate over the result of the expression
Throws:
XPathException - if any dynamic error occurs evaluating the expression

optimize

public Expression optimize(ExpressionVisitor visitor,
                           ItemType contextItemType)
            throws XPathException
Perform optimisation of an expression and its subexpressions. This is the third and final phase of static optimization.

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.

Overrides:
optimize in interface UnaryExpression
Parameters:
visitor - an expression visitor
contextItemType - 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
Returns:
the original expression, rewritten if appropriate to optimize execution
Throws:
XPathException - if an error is discovered during this phase (typically a type error)

promote

public Expression promote(PromotionOffer offer)
            throws XPathException
Promote this expression if possible
Overrides:
promote in interface UnaryExpression

simplify

public Expression simplify(ExpressionVisitor visitor)
            throws XPathException
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression). The default implementation does nothing.
Overrides:
simplify in interface UnaryExpression
Parameters:
visitor - an expression visitor
Returns:
the simplified expression
Throws:
XPathException - if an error is discovered during expression rewriting