/Users/lyon/j4p/src/collections/sortable/ComparableString.java
|
1 package collections.sortable;
2
3 import java.text.Collator;
4 import java.util.Locale;
5
6 public class ComparableString implements
7 Comparable2 {
8 String str = null;
9 Collator collator =
10 Collator.getInstance(
11 Locale.ENGLISH);
12
13 ComparableString(String _s) {
14 str = _s;
15 }
16
17 public boolean equals(Object other) {
18 String s = (String) other;
19 return s.equals(str);
20 }
21
22 public boolean isLess(Object other) {
23 String s = (String) other;
24 return (collator.compare(str, s) < 0);
25
26 }
27
28 public boolean isGreater(Object other) {
29 String s = (String) other;
30 return (collator.compare(str, s) > 0);
31 }
32
33 public int hashCode() {
34 return str.hashCode();
35 }
36 }