|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.util.UniversalComparator
public class UniversalComparator
The UniversalComparator is useful as a default if no other more specific sorting strategy is present. Its Collator first tries to order the objects by their natural order - if applicable (except for Strings, which will be sorted with a default Collator). If that fails, the objects will be sorted based on their toString() value using the embedded instance of a Collator. Also, this class gracefully handles null vaules.
Collator| Constructor Summary | |
|---|---|
UniversalComparator()
|
|
UniversalComparator(Collator collator)
|
|
| Method Summary | ||
|---|---|---|
int |
compare(Comparable o1,
Comparable o2)
|
|
int |
compare(Object o1,
Object o2)
null values are accepted and are sorted before a non-null value |
|
int |
compare(String o1,
String o2)
|
|
Collator |
getCollator()
provides access to the embedded collator |
|
static
|
reverse(Comparator<T> c)
a utility method for convenience that simply reverses the given ordering |
|
void |
setCollator(Collator collator)
allows to change the default collator in use |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
|---|
equals |
| Constructor Detail |
|---|
public UniversalComparator()
public UniversalComparator(Collator collator)
| Method Detail |
|---|
public Collator getCollator()
public void setCollator(Collator collator)
public int compare(Comparable o1,
Comparable o2)
public int compare(String o1,
String o2)
public int compare(Object o1,
Object o2)
compare in interface Comparator<Object>public static <T> Comparator<T> reverse(Comparator<T> c)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||