public class Ordering extends Object implements Comparator<Object>, Serializable, XMLSerializable
Modifier and Type | Field and Description |
---|---|
protected boolean |
nullSortedFirst |
protected boolean |
pathExceptionSuppressed |
protected SortOrder |
sortOrder |
protected Expression |
sortSpec |
protected String |
sortSpecString |
Constructor and Description |
---|
Ordering() |
Ordering(Expression sortSpec) |
Ordering(Expression sortSpec,
SortOrder sortOrder) |
Ordering(String sortPathSpec)
Create an ordering instance with a provided path and ascending sorting
strategy.
|
Ordering(String sortPathSpec,
SortOrder sortOrder) |
Modifier and Type | Method and Description |
---|---|
int |
compare(Object o1,
Object o2)
Comparable interface implementation.
|
void |
encodeAsXML(XMLEncoder encoder)
Encodes itself as a query ordering.
|
boolean |
equals(Object object) |
SortOrder |
getSortOrder()
Returns sort order for this ordering
|
Expression |
getSortSpec()
Returns the expression defining a ordering Java Bean property.
|
String |
getSortSpecString()
Returns sortSpec string representation.
|
int |
hashCode() |
boolean |
isAscending()
Returns true if sorting is done in ascending order.
|
boolean |
isCaseInsensitive()
Returns true if the sorting is case insensitive
|
boolean |
isCaseSensitive()
Returns true if the sorting is case sensitive.
|
boolean |
isDescending()
Returns true if the sorting is done in descending order.
|
boolean |
isNullSortedFirst()
Get sort order for nulls.
|
boolean |
isPathExceptionSuppressed()
Is a path with a null in the middle is ignored.
|
<E> List<E> |
orderedList(Collection<E> objects) |
static <E> List<E> |
orderedList(Collection<E> objects,
List<? extends Ordering> orderings)
Orders a given list of objects, using a List of Orderings applied
according the default iteration order of the Orderings list.
|
void |
orderList(List<?> objects)
Orders the given list of objects according to the ordering that this
object specifies.
|
static void |
orderList(List<?> objects,
List<? extends 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()
If the sort order is DESCENDING or DESCENDING_INSENSITIVE, sets the sort
order to ASCENDING or ASCENDING_INSENSITIVE, respectively.
|
void |
setCaseInsensitive()
If the sort order is ASCENDING or DESCENDING, sets the sort order to
ASCENDING_INSENSITIVE or DESCENDING_INSENSITIVE, respectively.
|
void |
setCaseSensitive()
If the sort order is ASCENDING_INSENSITIVE or DESCENDING_INSENSITIVE,
sets the sort order to ASCENDING or DESCENDING, respectively.
|
void |
setDescending()
If the sort order is ASCENDING or ASCENDING_INSENSITIVE, sets the sort
order to DESCENDING or DESCENDING_INSENSITIVE, respectively.
|
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 |
setSortOrder(SortOrder order)
Sets the sort order for this ordering.
|
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() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
protected String sortSpecString
protected transient Expression sortSpec
protected SortOrder sortOrder
protected boolean pathExceptionSuppressed
protected boolean nullSortedFirst
public Ordering()
public Ordering(String sortPathSpec)
public Ordering(Expression sortSpec)
public Ordering(Expression sortSpec, SortOrder sortOrder)
public static void orderList(List<?> objects, List<? extends Ordering> orderings)
objects
- elements to sortorderings
- list of Orderings to be appliedpublic static <E> List<E> orderedList(Collection<E> objects, List<? extends Ordering> orderings)
objects
- elements to sortorderings
- list of Orderings to be appliedpublic boolean equals(Object object)
equals
in interface Comparator<Object>
equals
in class Object
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 void setSortOrder(SortOrder order)
public boolean isAscending()
public boolean isDescending()
public void setAscending()
public void setDescending()
public boolean isCaseInsensitive()
public boolean isCaseSensitive()
public void setCaseInsensitive()
public void setCaseSensitive()
public Expression getSortSpec()
public void setSortSpec(Expression sortSpec)
public void orderList(List<?> objects)
objects
- a List of objects to be sortedpublic <E> List<E> orderedList(Collection<E> objects)
public int compare(Object o1, Object o2)
compare
in interface Comparator<Object>
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
public SortOrder getSortOrder()
Copyright © 2001–2018 Apache Cayenne. All rights reserved.