01: /*
02: * StringSorter.java
03: *
04: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: *
20: */
21:
22: package org.underworldlabs.swing.util;
23:
24: import java.util.Comparator;
25:
26: /* ----------------------------------------------------------
27: * CVS NOTE: Changes to the CVS repository prior to the
28: * release of version 3.0.0beta1 has meant a
29: * resetting of CVS revision numbers.
30: * ----------------------------------------------------------
31: */
32:
33: /**
34: * Simple string sorter.
35: *
36: * @author Takis Diakoumis
37: * @version $Revision: 1.4 $
38: * @date $Date: 2006/05/14 06:56:07 $
39: */
40: public class StringSorter implements Comparator {
41:
42: public int compare(Object obj1, Object obj2) {
43: String value1 = (String) obj1;
44: String value2 = (String) obj2;
45:
46: int result = value1.compareTo(value2);
47:
48: if (result < 0) {
49: return -1;
50: } else if (result > 0) {
51: return 1;
52: } else {
53: return 0;
54: }
55: }
56:
57: }
|