001/*
002 *                  BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 * 
020 * Created on Jan 24, 2008
021 * 
022 */
023
024package org.biojava.ontology;
025
026import java.util.Comparator;
027
028
029public class Synonym implements Comparable<Synonym>{
030
031
032        public final static int UNKNOWN_SCOPE = -1;
033        public final static int RELATED_SYNONYM = 0;
034        public final static int EXACT_SYNONYM = 1;
035        public final static int NARROW_SYNONYM = 2;
036        public final static int BROAD_SYNONYM = 3;
037
038        int scope;
039        String category;
040        String name;
041        
042        public String toString(){
043                String txt = "Synonym: name:"+name+ " category:" + category + " scope: " +scope;
044                return txt;
045        }
046        
047        public final static Comparator<Synonym> COMPARATOR = new Comparator<Synonym>() {
048                public int compare(Synonym a, Synonym b) {
049                        if (a == null && b == null)
050                                return 0;
051                        else if (a == null)
052                                return -1;
053                        else if (b == null)
054                                return 1;
055                        else {
056                                if ((a.getCategory() == null) && (b.getCategory() == null))
057                                        return 0;
058                                else if ( a.getCategory()==null)
059                                        return -1;
060                                else if ( b.getCategory()==null)
061                                        return 1;                               
062                                
063                                return ((Synonym) a).getCategory().compareToIgnoreCase(
064                                                ((Synonym) b).getCategory());
065                        }
066                }
067        };
068
069        public Synonym() {
070        }
071        public String getName() {
072                return name;
073        }
074        public void setName(String name) {
075                this.name = name;
076        }
077        public String getCategory() {
078                return category;
079        }
080        public void setCategory(String category) {
081                this.category = category;
082        }
083        public int getScope() {
084                return scope;
085        }
086        public void setScope(int scope) {
087                this.scope = scope;
088        }
089        public int compareTo(Synonym o) {
090                return COMPARATOR.compare(this, o);
091        }
092}