01 /*
02 * OntologyItemComparator.java
03 *
04 * Niraj Aswani, 09/March/07
05 *
06 * $Id: OntologyItemComparator.html,v 1.0 2007/03/09 16:13:01 niraj Exp $
07 */
08
09 package gate.gui.ontology;
10
11 import gate.creole.ontology.OResource;
12 import java.util.Comparator;
13
14 /**
15 * A Comparator that sorts the resources in ontology based on their URIs
16 *
17 * @author niraj
18 *
19 */
20 public class OntologyItemComparator implements Comparator<OResource> {
21 public int compare(OResource resource1, OResource resource2) {
22 if (resource1 == null) return (resource2 != null) ? -1 : 0;
23 if (resource2 == null) return 1;
24 String name1 = resource1.getURI().getResourceName();
25 String name2 = resource2.getURI().getResourceName();
26 if (name1 == null) return (name2 != null) ? -1 : 0;
27 if (name2 == null) return 1;
28 else return name1.compareTo(name2);
29 }
30 }
|