|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.sort.SortKey<String> edu.nrao.sss.sort.StringSortKey
public abstract class StringSortKey
A sort key for String
s.
Comparator
. The main job of the subclass
is to provide the strings to this parent class. Example:
/** * Sorts persons based on their names (surname then given names). */ public class PersonNameKey extends StringSortKey implements Comparator<Person> { public int compare(Person p1, Person p2) { return compareObjects(p1.getNameLastFirst(), p2.getNameLastFirst()); } }
Clients of the example PersonNameKey class are able to configure
that comparator via the setOrder
and
setIgnoreCase
methods, something they cannot
do with the plain Comparator interface. They may then place
instances of this class in a CompoundComparator
.
Version Info:
$Revision: 593 $ |
$Date: 2007-05-07 15:54:14 -0600 (Mon, 07 May 2007) $ |
$Author: dharland $ |
Constructor Summary | |
---|---|
protected |
StringSortKey()
Helps create a new, case-sensitive, instance. |
Method Summary | |
---|---|
protected int |
compareAscending(String o1,
String o2)
Uses the natural ordering of String and the value
of this key's ignoreCase property. |
protected int |
compareNatural(String o1,
String o2)
Uses the natural ordering of String and the value
of this key's ignoreCase property. |
void |
setIgnoreCase(boolean ignore)
Tells this key to either consider or ignore case when comparing strings. |
Methods inherited from class edu.nrao.sss.sort.SortKey |
---|
compareObjects, compareObjects, getOrder, nullOrdering, objectsAreEqual, setOrder |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected StringSortKey()
Method Detail |
---|
public void setIgnoreCase(boolean ignore)
ignore
- a value of true will instruct this key to ignore
case when comparing strings.protected int compareNatural(String o1, String o2)
String
and the value
of this key's ignoreCase
property.
compareNatural
in class SortKey<String>
protected int compareAscending(String o1, String o2)
String
and the value
of this key's ignoreCase
property.
compareAscending
in class SortKey<String>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |