removed autogenerated todo
[jalview.git] / src / jalview / datamodel / DBRefEntry.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer
3  * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.datamodel;
20
21 public class DBRefEntry
22 {
23   String source="", version="", accessionId="";
24   /**
25    * maps from associated sequence to the database sequence's coordinate system
26    */
27   Mapping map=null;
28   public DBRefEntry() {
29       
30   }
31   public DBRefEntry(String source, String version, String accessionId)
32   {
33     this(source, version, accessionId, null);
34   }
35   public DBRefEntry(String source, String version, String accessionId, Mapping map) {
36     this.source = source;
37     this.version = version;
38     this.accessionId = accessionId;
39     this.map = map;
40   }
41   public DBRefEntry(DBRefEntry entry)
42   {
43     this(new String(entry.source), new String(entry.version), new String(entry.accessionId), new Mapping(entry.map));
44   }
45   public boolean equals(DBRefEntry entry) {
46       if (entry==this)
47           return true;
48       if (entry==null)
49           return false;
50       if (equalRef(entry)
51               &&
52           ((map==null && entry.map==null) || (map!=null && entry.map!=null && map.equals(entry.map)))) {
53               return true;
54           }
55       return false;
56   }
57   /**
58    * test for similar DBRef attributes, except for the map object.
59    * @param entry 
60    * @return true if source, accession and version are equal with those of entry
61    */
62   public boolean equalRef(DBRefEntry entry)
63   {
64     if (entry==null)
65     {
66       return false;
67     }
68     if (entry==this)
69       return true;
70     if ((source!=null && entry.source!=null && source.equals(entry.source))
71             &&
72             (accessionId!=null && entry.accessionId!=null && accessionId.equals(entry.accessionId))
73             &&
74             (version!=null && entry.version!=null && version.equals(entry.version))
75             )
76     {
77       return true;
78     }
79     return false;
80   }
81   public String getSource()
82   {
83     return source;
84   }
85
86   public String getVersion()
87   {
88     return version;
89   }
90
91   public String getAccessionId()
92   {
93     return accessionId;
94   }
95 /**
96  * @param accessionId the accessionId to set
97  */
98 public void setAccessionId(String accessionId) {
99     this.accessionId = accessionId;
100 }
101 /**
102  * @param source the source to set
103  */
104 public void setSource(String source) {
105     this.source = source;
106 }
107 /**
108  * @param version the version to set
109  */
110 public void setVersion(String version) {
111     this.version = version;
112 }
113 /**
114  * @return the map
115  */
116 public Mapping getMap() {
117     return map;
118 }
119 /**
120  * @param map the map to set
121  */
122 public void setMap(Mapping map) {
123     this.map = map;
124 }
125 public boolean hasMap()
126 {
127   return map!=null;
128 }
129 /**
130  * 
131  * @return source+":"+accessionId
132  */
133 public String getSrcAccString()
134 {
135   return ((source!=null) ? source : "")
136     + ":" + ((accessionId!=null) ? accessionId : "");
137 }
138 }