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.nbio.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        @Override
043        public String toString(){
044                String txt = "Synonym: name:"+name+ " category:" + category + " scope: " +scope;
045                return txt;
046        }
047
048        public final static Comparator<Synonym> COMPARATOR = new Comparator<Synonym>() {
049                @Override
050                public int compare(Synonym a, Synonym b) {
051                        if (a == null && b == null)
052                                return 0;
053                        else if (a == null)
054                                return -1;
055                        else if (b == null)
056                                return 1;
057                        else {
058                                if ((a.getCategory() == null) && (b.getCategory() == null))
059                                        return 0;
060                                else if ( a.getCategory()==null)
061                                        return -1;
062                                else if ( b.getCategory()==null)
063                                        return 1;
064
065                                return a.getCategory().compareToIgnoreCase(
066                                                b.getCategory());
067                        }
068                }
069        };
070
071        public Synonym() {
072        }
073        public String getName() {
074                return name;
075        }
076        public void setName(String name) {
077                this.name = name;
078        }
079        public String getCategory() {
080                return category;
081        }
082        public void setCategory(String category) {
083                this.category = category;
084        }
085        public int getScope() {
086                return scope;
087        }
088        public void setScope(int scope) {
089                this.scope = scope;
090        }
091        @Override
092        public int compareTo(Synonym o) {
093                return COMPARATOR.compare(this, o);
094        }
095}