Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.query
Class Ordering

    java.lang.Object
      org.apache.cayenne.query.Ordering

All Implemented Interfaces:
  java.io.Serializable, java.util.Comparator, XMLSerializable

    public class Ordering

extends java.lang.Object
implements java.util.Comparator, java.io.Serializable, XMLSerializable

Defines object sorting criteria, used either for in-memory sorting of object lists or as a specification for building ORDER BY clause of a SelectQuery query. Note that in case of in-memory sorting, Ordering can be used with any JavaBeans, not just DataObjects.

Author:
  Andrus Adamchik, Craig Miskell
See Also:
  Serialized Form

Field Summary
`static boolean` | `ASC` Symbolic representation of ascending ordering criterion.
`protected boolean` | `ascending`
`protected boolean` | `caseInsensitive`
`static boolean` | `DESC` Symbolic representation of descending ordering criterion.
`protected Expression` | `sortSpec`
`protected java.lang.String` | `sortSpecString`

Constructor Summary
`Ordering()`
`Ordering(Expression sortExpression, boolean ascending)`
`Ordering(Expression sortExpression, boolean ascending, boolean caseInsensitive)`
`Ordering(java.lang.String sortPathSpec, boolean ascending)`
`Ordering(java.lang.String sortPathSpec, boolean ascending, boolean caseInsensitive)`

Method Summary
`int` | `compare(java.lang.Object o1, java.lang.Object o2)` Comparable interface implementation.
`void` | `encodeAsXML(XMLEncoder encoder)` Encodes itself as a query ordering.
`Expression` | `getSortSpec()` Returns the expression defining a ordering Java Bean property.
`java.lang.String` | `getSortSpecString()` Returns sortSpec string representation.
`boolean` | `isAscending()` Returns true if sorting is done in ascending order.
`boolean` | `isCaseInsensitive()` Returns true if the sorting is case insensitive
`void` | `orderList(java.util.List objects)` Orders the given list of objects according to the ordering that this object specifies.
`static void` | `orderList(java.util.List objects, java.util.List orderings)` Orders a given list of objects, using a List of Orderings applied according the default iteration order of the Orderings list.
`void` | `setAscending(boolean ascending)` Sets `ascending` property of this Ordering.
`void` | `setCaseInsensitive(boolean caseInsensitive)` Sets `caseInsensitive` property of this Ordering.
`void` | `setSortSpec(Expression sortSpec)` Sets the expression defining a ordering Java Bean property.
`void` | `setSortSpecString(java.lang.String sortSpecString)` Sets sortSpec to be an expression represented by string argument.
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Comparator
`equals`

Field Detail

### ASC

    public static final boolean ASC

  Symbolic representation of ascending ordering criterion.

  See Also:
    Constant Field Values

### DESC

    public static final boolean DESC

  Symbolic representation of descending ordering criterion.

  See Also:
    Constant Field Values

### sortSpecString

    protected java.lang.String sortSpecString

### sortSpec

    protected transient Expression sortSpec

### ascending

    protected boolean ascending

### caseInsensitive

    protected boolean caseInsensitive

Constructor Detail

### Ordering

    public Ordering()

### Ordering

    public Ordering(java.lang.String sortPathSpec,
                    boolean ascending)

### Ordering

    public Ordering(java.lang.String sortPathSpec,
                    boolean ascending,
                    boolean caseInsensitive)

### Ordering

    public Ordering(Expression sortExpression,
                    boolean ascending)

### Ordering

    public Ordering(Expression sortExpression,
                    boolean ascending,
                    boolean caseInsensitive)

Method Detail

### orderList

    public static void orderList(java.util.List objects,
                                 java.util.List orderings)

  Orders a given list of objects, using a List of Orderings applied according the default iteration order of the Orderings list. I.e. each Ordering with lower index is more significant than any other Ordering with higer index. List being ordered is modified in place.

### setSortSpecString

    public void setSortSpecString(java.lang.String sortSpecString)

  Sets sortSpec to be an expression represented by string argument.

  Since:
    1.1

### getSortSpecString

    public java.lang.String getSortSpecString()

  Returns sortSpec string representation.

  Since:
    1.1

### isAscending

    public boolean isAscending()

  Returns true if sorting is done in ascending order.

### setAscending

    public void setAscending(boolean ascending)

  Sets `ascending` property of this Ordering.

### isCaseInsensitive

    public boolean isCaseInsensitive()

  Returns true if the sorting is case insensitive

### setCaseInsensitive

    public void setCaseInsensitive(boolean caseInsensitive)

  Sets `caseInsensitive` property of this Ordering.

### getSortSpec

    public Expression getSortSpec()

  Returns the expression defining a ordering Java Bean property.

### setSortSpec

    public void setSortSpec(Expression sortSpec)

  Sets the expression defining a ordering Java Bean property.

### orderList

    public void orderList(java.util.List objects)

  Orders the given list of objects according to the ordering that this object specifies. List is modified in-place.

  Parameters:
    `objects` - a List of objects to be sorted

### compare

    public int compare(java.lang.Object o1,
                       java.lang.Object o2)

  Comparable interface implementation. Can compare two Java Beans based on the stored expression.

  Specified by:
    `compare` in interface `java.util.Comparator`

### encodeAsXML

    public void encodeAsXML(XMLEncoder encoder)

  Encodes itself as a query ordering.

  Specified by:
    `encodeAsXML` in interface `XMLSerializable`
  Since:
    1.1

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 Apache.org All Rights Reserved.