|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.query.Ordering
public class Ordering
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.
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 boolean |
nullSortedFirst
|
protected boolean |
pathExceptionSuppressed
|
protected Expression |
sortSpec
|
protected String |
sortSpecString
|
Constructor Summary | |
---|---|
Ordering()
|
|
Ordering(Expression sortExpression,
boolean ascending)
|
|
Ordering(Expression sortExpression,
boolean ascending,
boolean caseInsensitive)
|
|
Ordering(String sortPathSpec,
boolean ascending)
|
|
Ordering(String sortPathSpec,
boolean ascending,
boolean caseInsensitive)
|
Method Summary | |
---|---|
int |
compare(Object o1,
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. |
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 |
boolean |
isNullSortedFirst()
Get sort order for nulls. |
boolean |
isPathExceptionSuppressed()
Is a path with a null in the middle is ignored. |
void |
orderList(List<?> objects)
Orders the given list of objects according to the ordering that this object specifies. |
static void |
orderList(List<?> objects,
List<Ordering> 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 |
setNullSortedFirst(boolean nullSortedFirst)
Sets sort order for whether nulls are at the top or bottom of the resulting list. |
void |
setPathExceptionSupressed(boolean pathExceptionSuppressed)
Sets whether a path with a null in the middle is ignored. |
void |
setSortSpec(Expression sortSpec)
Sets the expression defining a ordering Java Bean property. |
void |
setSortSpecString(String sortSpecString)
Sets sortSpec to be an expression represented by string argument. |
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 |
---|
public static final boolean ASC
public static final boolean DESC
protected String sortSpecString
protected transient Expression sortSpec
protected boolean ascending
protected boolean caseInsensitive
protected boolean pathExceptionSuppressed
protected boolean nullSortedFirst
Constructor Detail |
---|
public Ordering()
public Ordering(String sortPathSpec, boolean ascending)
public Ordering(String sortPathSpec, boolean ascending, boolean caseInsensitive)
public Ordering(Expression sortExpression, boolean ascending)
public Ordering(Expression sortExpression, boolean ascending, boolean caseInsensitive)
Method Detail |
---|
public static void orderList(List<?> objects, List<Ordering> orderings)
public void setSortSpecString(String sortSpecString)
public void setNullSortedFirst(boolean nullSortedFirst)
nullSortedFirst
- true sorts nulls to the top of the list, false sorts nulls to the bottompublic boolean isNullSortedFirst()
public void setPathExceptionSupressed(boolean pathExceptionSuppressed)
painting
on artist.name
would by default throw an exception if the artist was null.
If set to true, then this is treated just like a null value.
Default is false.
pathExceptionSuppressed
- true to suppress exceptions and sort as nullpublic boolean isPathExceptionSuppressed()
public String getSortSpecString()
public boolean isAscending()
public void setAscending(boolean ascending)
ascending
property of this Ordering.
public boolean isCaseInsensitive()
public void setCaseInsensitive(boolean caseInsensitive)
caseInsensitive
property of this Ordering.
public Expression getSortSpec()
public void setSortSpec(Expression sortSpec)
public void orderList(List<?> objects)
objects
- a List of objects to be sortedpublic int compare(Object o1, Object o2)
compare
in interface Comparator<Object>
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |