2 * BioJava development code
4 * This code may be freely distributed and modified under the
5 * terms of the GNU Lesser General Public Licence. This should
6 * be distributed with the code. If you do not have a copy,
9 * http://www.gnu.org/copyleft/lesser.html
11 * Copyright for this code is held jointly by the individual
12 * authors. These should be listed in @author doc comments.
14 * For more information on the BioJava project and its aims,
15 * or to join the biojava-l mailing list, visit the home page
18 * http://www.biojava.org/
20 * Created on Jan 24, 2008
24 package org.biojava.nbio.ontology;
26 import java.util.Comparator;
29 public class Synonym implements Comparable<Synonym>{
32 public final static int UNKNOWN_SCOPE = -1;
33 public final static int RELATED_SYNONYM = 0;
34 public final static int EXACT_SYNONYM = 1;
35 public final static int NARROW_SYNONYM = 2;
36 public final static int BROAD_SYNONYM = 3;
43 public String toString(){
44 String txt = "Synonym: name:"+name+ " category:" + category + " scope: " +scope;
51 return toString().hashCode();
55 public boolean equals(Object obj)
57 return obj instanceof Synonym
58 && ((Synonym) obj).toString().equals(this.toString());
61 public final static Comparator<Synonym> COMPARATOR = new Comparator<Synonym>()
64 public int compare(Synonym a, Synonym b) {
65 if (a == null && b == null)
81 String catA = a.getCategory();
82 String catB = b.getCategory();
83 if (catA == null && catB != null)
87 if (catA != null && catB == null)
91 if (catA != null && catB != null)
93 int comp = catA.compareToIgnoreCase(catB);
99 // todo check for null name
100 return a.getName().compareToIgnoreCase(b.getName());
106 public String getName() {
109 public void setName(String name) {
112 public String getCategory() {
115 public void setCategory(String category) {
116 this.category = category;
118 public int getScope() {
121 public void setScope(int scope) {
125 public int compareTo(Synonym o) {
126 return COMPARATOR.compare(this, o);