01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.ui.client.util;
09:
10: import java.util.Comparator;
11:
12: /**
13: * Default <code>Comparator</code> implementation.
14: */
15: public class DefaultComparator implements Comparator {
16:
17: public int compare(Object o1, Object o2) {
18: if (o1 instanceof Comparable) {
19: return ((Comparable) o1).compareTo(o2);
20: } else {
21: return compareStrings(o1.toString(), o2.toString());
22: }
23: }
24:
25: protected int compareStrings(String s1, String s2) {
26: return s1.toLowerCase().compareTo(s2.toLowerCase());
27: }
28:
29: }
|