net.sf.saxon.sort
Class SortKeyDefinition

java.lang.Object
  extended by net.sf.saxon.sort.SortKeyDefinition
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
FixedSortKeyDefinition

public class SortKeyDefinition
extends Object
implements Serializable

A SortKeyDefinition defines one component of a sort key.
Note that most attributes defining the sort key can be attribute value templates, and can therefore vary from one invocation to another. We hold them as expressions. As soon as they are all known (which in general is only at run-time), the SortKeyDefinition is replaced by a FixedSortKeyDefinition in which all these values are fixed.

See Also:
Serialized Form

Field Summary
protected  Expression caseOrder
           
protected  Comparator collation
           
protected  Expression dataTypeExpression
           
protected  boolean emptyFirst
           
protected  Expression language
           
protected  Expression order
           
protected  Expression sortKey
           
 
Constructor Summary
SortKeyDefinition()
           
 
Method Summary
 boolean getEmptyFirst()
           
 Expression getSortKey()
          Get the expression used as the sort key
 FixedSortKeyDefinition reduce(XPathContext context)
          Eliminate dependencies of the sort key definition on the context.
 void setCaseOrder(Expression exp)
          Set the case order.
 void setCollation(Comparator collation)
          Set the collation.
 void setDataTypeExpression(Expression exp)
          Set the data type.
 void setEmptyFirst(boolean emptyFirst)
          Set whether empty sequence comes before other values or after them
 void setLanguage(Expression exp)
          Set the language.
 void setOrder(Expression exp)
          Set the order.
 void setSortKey(Expression exp)
          Set the expression used as the sort key
 SortKeyDefinition simplify()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sortKey

protected Expression sortKey

order

protected Expression order

dataTypeExpression

protected Expression dataTypeExpression

caseOrder

protected Expression caseOrder

language

protected Expression language

collation

protected Comparator collation

emptyFirst

protected boolean emptyFirst
Constructor Detail

SortKeyDefinition

public SortKeyDefinition()
Method Detail

setSortKey

public void setSortKey(Expression exp)
Set the expression used as the sort key


getSortKey

public Expression getSortKey()
Get the expression used as the sort key


setOrder

public void setOrder(Expression exp)
Set the order. This is supplied as an expression which must evaluate to "ascending" or "descending". If the order is fixed, supply e.g. new StringValue("ascending"). Default is "ascending".


setDataTypeExpression

public void setDataTypeExpression(Expression exp)
Set the data type. This is supplied as an expression which must evaluate to "text", "number", or a QName. If the data type is fixed, the valus should be supplied using setDataType() and not via this method.


setCaseOrder

public void setCaseOrder(Expression exp)
Set the case order. This is supplied as an expression which must evaluate to "upper-first" or "lower-first" or "#default". If the order is fixed, supply e.g. new StringValue("lower-first"). Default is "#default".


setLanguage

public void setLanguage(Expression exp)
Set the language. This is supplied as an expression which evaluates to the language name. If the order is fixed, supply e.g. new StringValue("de").


setCollation

public void setCollation(Comparator collation)
Set the collation.


setEmptyFirst

public void setEmptyFirst(boolean emptyFirst)
Set whether empty sequence comes before other values or after them

Parameters:
emptyFirst - true if () is considered lower than any other value

getEmptyFirst

public boolean getEmptyFirst()

simplify

public SortKeyDefinition simplify()
                           throws XPathException
Throws:
XPathException

reduce

public FixedSortKeyDefinition reduce(XPathContext context)
                              throws XPathException
Eliminate dependencies of the sort key definition on the context. For the sort key select expression, this means things that don't depend on the individual node: specifically, variables and current-group(). For the AVTs used to select data type, case order, language, it means all dependencies: after reduction, these values will be constants.

Throws:
XPathException