1 package uk.ac.ebi.intenz.domain.constants;
2
3
4
5
6
7
8
9
10
11 public class EnzymeNameQualifierConstant {
12
13 public static final EnzymeNameQualifierConstant UNDEF = new EnzymeNameQualifierConstant("NON");
14 public static final EnzymeNameQualifierConstant MISLEADING = new EnzymeNameQualifierConstant("MIS");
15 public static final EnzymeNameQualifierConstant AMBIGUOUS = new EnzymeNameQualifierConstant("AMB");
16 public static final EnzymeNameQualifierConstant OBSOLETE = new EnzymeNameQualifierConstant("OBS");
17 public static final EnzymeNameQualifierConstant MISPRINT = new EnzymeNameQualifierConstant("MPR");
18 public static final EnzymeNameQualifierConstant INCORRECT = new EnzymeNameQualifierConstant("INC");
19
20 private String qualifier;
21
22
23
24
25
26
27
28
29
30 public static EnzymeNameQualifierConstant valueOf(String qualifier) {
31 if (qualifier == null) throw new NullPointerException("Parameter 'qualifier' must not be null.");
32
33 if (qualifier.equals(UNDEF.toString()) || qualifier.equals("")) return UNDEF;
34 if (qualifier.equals(MISLEADING.toString())) return MISLEADING;
35 if (qualifier.equals(AMBIGUOUS.toString())) return AMBIGUOUS;
36 if (qualifier.equals(OBSOLETE.toString())) return OBSOLETE;
37 if (qualifier.equals(MISPRINT.toString())) return MISPRINT;
38 if (qualifier.equals(INCORRECT.toString())) return INCORRECT;
39 throw new IllegalArgumentException();
40 }
41
42
43
44
45
46
47 private EnzymeNameQualifierConstant(String qualifier) {
48 this.qualifier = qualifier;
49 }
50
51
52
53
54
55
56
57 public boolean equals(Object o) {
58 if (this == o) return true;
59 if (!(o instanceof EnzymeNameQualifierConstant)) return false;
60
61 final EnzymeNameQualifierConstant enzymeNameQualifierConstant = (EnzymeNameQualifierConstant) o;
62
63 if (qualifier != null ? !qualifier.equals(enzymeNameQualifierConstant.qualifier) : enzymeNameQualifierConstant.qualifier != null) return false;
64
65 return true;
66 }
67
68
69
70
71
72
73 public int hashCode() {
74 return (qualifier != null ? qualifier.hashCode() : 0);
75 }
76
77
78
79
80
81
82 public String toString() {
83 return qualifier;
84 }
85
86
87
88
89
90
91
92
93
94 public String toASCII(EnzymeNameQualifierConstant name) {
95 if(this == MISLEADING) return "[misleading]";
96 if(this == OBSOLETE) return "[obsolete]";
97 if(this == AMBIGUOUS) return "[ambiguous]";
98 if(this == MISPRINT) return "[misprint]";
99 if(this == INCORRECT) return "[incorrect]";
100 return "";
101 }
102
103
104
105
106
107
108
109
110
111 public String toHTML(String name) {
112 if(this == MISLEADING) return "[misleading]";
113 if(this == OBSOLETE) return "[obsolete]";
114 if(this == AMBIGUOUS) return "[<a href=\"search.do?q="+name+"\">ambiguous</a>]";
115 if(this == MISPRINT) return "[misprint]";
116 if(this == INCORRECT) return "[incorrect]";
117 return "";
118 }
119
120 public String getLabel(){
121 if(this == MISLEADING) return "misleading";
122 if(this == OBSOLETE) return "obsolete";
123 if(this == AMBIGUOUS) return "ambiguous";
124 if(this == MISPRINT) return "misprint";
125 if(this == INCORRECT) return "incorrect";
126 return null;
127 }
128
129
130
131
132
133
134
135
136 public String toEditableHTML() {
137 StringBuffer html = new StringBuffer();
138
139 html.append("Additional characteristic:\n<select name=\"characteristics\" size=\"1\">\n");
140 html.append(getEditableHTML());
141 html.append("</select>\n");
142
143 return html.toString();
144 }
145
146
147
148
149
150
151
152
153 private String getEditableHTML() {
154 StringBuffer html = new StringBuffer();
155
156 if(this == UNDEF) {
157 html.append("<option selected=\"selected\" value=\"NON\"><NONE></option>");
158 html.append("<option value=\"MIS\">misleading</option>");
159 html.append("<option value=\"OBS\">obsolete</option>");
160 html.append("<option value=\"AMB\">ambiguous</option>");
161 html.append("<option value=\"MPR\">misprint</option>");
162 html.append("<option value=\"INC\">incorrect</option>");
163 }
164
165 if(this == MISLEADING) {
166 html.append("<option selected=\"selected\" value=\"MIS\">misleading</option>");
167 html.append("<option value=\"NON\"><NONE></option>");
168 html.append("<option value=\"OBS\">obsolete</option>");
169 html.append("<option value=\"AMB\">ambiguous</option>");
170 html.append("<option value=\"MPR\">misprint</option>");
171 html.append("<option value=\"INC\">incorrect</option>");
172 }
173
174 if(this == OBSOLETE) {
175 html.append("<option selected=\"selected\" value=\"OBS\">obsolete</option>");
176 html.append("<option value=\"NON\"><NONE></option>");
177 html.append("<option value=\"MIS\">misleading</option>");
178 html.append("<option value=\"AMB\">ambiguous</option>");
179 html.append("<option value=\"MPR\">misprint</option>");
180 html.append("<option value=\"INC\">incorrect</option>");
181 }
182
183 if(this == AMBIGUOUS) {
184 html.append("<option selected=\"selected\" value=\"AMB\">ambiguous</option>");
185 html.append("<option value=\"NON\"><NONE></option>");
186 html.append("<option value=\"MIS\">misleading</option>");
187 html.append("<option value=\"OBS\">obsolete</option>");
188 html.append("<option value=\"MPR\">misprint</option>");
189 html.append("<option value=\"INC\">incorrect</option>");
190 }
191
192 if(this == MISPRINT) {
193 html.append("<option selected=\"selected\" value=\"AMB\">ambiguous</option>");
194 html.append("<option value=\"NON\"><NONE></option>");
195 html.append("<option value=\"MIS\">misleading</option>");
196 html.append("<option value=\"AMB\">ambiguous</option>");
197 html.append("<option value=\"OBS\">obsolete</option>");
198 html.append("<option value=\"INC\">incorrect</option>");
199 }
200
201 if(this == INCORRECT) {
202 html.append("<option selected=\"selected\" value=\"AMB\">ambiguous</option>");
203 html.append("<option value=\"NON\"><NONE></option>");
204 html.append("<option value=\"MIS\">misleading</option>");
205 html.append("<option value=\"AMB\">ambiguous</option>");
206 html.append("<option value=\"OBS\">obsolete</option>");
207 html.append("<option value=\"MPR\">misprint</option>");
208 }
209
210 return html.toString();
211 }
212 }
213
214