01: /*
02: * This program is free software; you can redistribute it and/or modify
03: * it under the terms of the GNU General Public License as published by
04: * the Free Software Foundation; either version 2 of the License, or
05: * (at your option) any later version.
06: *
07: * This program is distributed in the hope that it will be useful,
08: * but WITHOUT ANY WARRANTY; without even the implied warranty of
09: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10: * GNU General Public License for more details.
11: *
12: * You should have received a copy of the GNU General Public License
13: * along with this program; if not, write to the Free Software
14: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15: */
16:
17: /*
18: * EnsembleLibraryModelComparator.java
19: * Copyright (C) 2006 Robert Jung
20: *
21: */
22:
23: package weka.classifiers;
24:
25: import java.io.Serializable;
26: import java.util.Comparator;
27:
28: /**
29: * This class is a Comparator for the LibraryModel class. It basically ranks
30: * them alphabetically based on their String Representations
31: *
32: * @author Robert Jung (mrbobjung@gmail.com)
33: * @version $Revision: 1.1 $
34: */
35: public final class EnsembleLibraryModelComparator implements
36: Comparator, Serializable {
37:
38: /** for serialization */
39: private static final long serialVersionUID = -6522464740036141188L;
40:
41: /**
42: * Compares its two arguments for order.
43: *
44: * @param o1 first object
45: * @param o2 second object
46: * @return a negative integer, zero, or a positive integer as the
47: * first argument is less than, equal to, or greater than
48: * the second.
49: */
50: public int compare(Object o1, Object o2) {
51:
52: int comparison = 0;
53:
54: if (o1 instanceof EnsembleLibraryModel
55: && o2 instanceof EnsembleLibraryModel) {
56:
57: comparison = ((String) ((EnsembleLibraryModel) o1)
58: .getStringRepresentation())
59: .compareTo(((String) ((EnsembleLibraryModel) o2)
60: .getStringRepresentation()));
61:
62: }
63:
64: return comparison;
65: }
66: }
|