net.sf.saxon.sort
Class SortKeyDefinition

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

public class SortKeyDefinition
extends java.lang.Object
implements java.io.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  java.lang.String baseURI
           
protected  Expression caseOrder
           
protected  java.util.Comparator collation
           
protected  Expression collationName
           
protected  Expression dataTypeExpression
           
protected  boolean emptyLeast
           
protected  Expression language
           
protected  Expression order
           
protected  Container parentExpression
           
protected  Expression sortKey
           
 
Constructor Summary
SortKeyDefinition()
           
 
Method Summary
 java.lang.String getBaseURI()
           
 Expression getCaseOrder()
           
 java.util.Comparator getCollation()
           
 Expression getCollationName()
           
 Expression getDataTypeExpression()
           
 boolean getEmptyLeast()
           
 Expression getLanguage()
           
 Expression getOrder()
           
 Container getParentExpression()
           
 Expression getSortKey()
          Get the expression used as the sort key
 FixedSortKeyDefinition reduce(XPathContext context)
          Evaluate any aspects of the sort definition that were specified as AVTs, for example ascending/descending, language, case-order, data-type.
 void setBaseURI(java.lang.String baseURI)
           
 void setCaseOrder(Expression exp)
          Set the case order.
 void setCollation(java.util.Comparator collation)
           
 void setCollationName(Expression collationName)
          Set the collation.
 void setDataTypeExpression(Expression exp)
          Set the data type.
 void setEmptyLeast(boolean emptyLeast)
          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 setParentExpression(Container container)
           
 void setSortKey(Expression exp)
          Set the expression used as the sort key
 SortKeyDefinition simplify(StaticContext env, Executable exec)
           
 
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

collationName

protected Expression collationName

collation

protected java.util.Comparator collation

baseURI

protected java.lang.String baseURI

emptyLeast

protected boolean emptyLeast

parentExpression

protected Container parentExpression
Constructor Detail

SortKeyDefinition

public SortKeyDefinition()
Method Detail

setParentExpression

public void setParentExpression(Container container)

getParentExpression

public Container getParentExpression()

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".


getOrder

public Expression getOrder()

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.


getDataTypeExpression

public Expression getDataTypeExpression()

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".


getCaseOrder

public Expression getCaseOrder()

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").


getLanguage

public Expression getLanguage()

setCollationName

public void setCollationName(Expression collationName)
Set the collation.


getCollationName

public Expression getCollationName()

setCollation

public void setCollation(java.util.Comparator collation)

getCollation

public java.util.Comparator getCollation()

setBaseURI

public void setBaseURI(java.lang.String baseURI)

getBaseURI

public java.lang.String getBaseURI()

setEmptyLeast

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

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

getEmptyLeast

public boolean getEmptyLeast()

simplify

public SortKeyDefinition simplify(StaticContext env,
                                  Executable exec)
                           throws XPathException
Throws:
XPathException

reduce

public FixedSortKeyDefinition reduce(XPathContext context)
                              throws XPathException
Evaluate any aspects of the sort definition that were specified as AVTs, for example ascending/descending, language, case-order, data-type. This is done at the start of each sort. A FixedSortKeyDefinition is a SortKeyDefinition in which these properties are all known values.

Throws:
XPathException