merge from 2_4_Release branch
[jalview.git] / src / jalview / schemabinding / version2 / descriptors / ThresholdLineDescriptor.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
3  * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  * \r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  * \r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  * \r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 package jalview.schemabinding.version2.descriptors;\r
20 \r
21 // ---------------------------------/\r
22 // - Imported classes and packages -/\r
23 // ---------------------------------/\r
24 \r
25 import jalview.schemabinding.version2.ThresholdLine;\r
26 \r
27 /**\r
28  * Class ThresholdLineDescriptor.\r
29  * \r
30  * @version $Revision$ $Date$\r
31  */\r
32 public class ThresholdLineDescriptor extends\r
33         org.exolab.castor.xml.util.XMLClassDescriptorImpl\r
34 {\r
35 \r
36   // --------------------------/\r
37   // - Class/Member Variables -/\r
38   // --------------------------/\r
39 \r
40   /**\r
41    * Field _elementDefinition.\r
42    */\r
43   private boolean _elementDefinition;\r
44 \r
45   /**\r
46    * Field _nsPrefix.\r
47    */\r
48   private java.lang.String _nsPrefix;\r
49 \r
50   /**\r
51    * Field _nsURI.\r
52    */\r
53   private java.lang.String _nsURI;\r
54 \r
55   /**\r
56    * Field _xmlName.\r
57    */\r
58   private java.lang.String _xmlName;\r
59 \r
60   // ----------------/\r
61   // - Constructors -/\r
62   // ----------------/\r
63 \r
64   public ThresholdLineDescriptor()\r
65   {\r
66     super();\r
67     _nsURI = "www.vamsas.ac.uk/jalview/version2";\r
68     _xmlName = "thresholdLine";\r
69     _elementDefinition = true;\r
70     org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;\r
71     org.exolab.castor.mapping.FieldHandler handler = null;\r
72     org.exolab.castor.xml.FieldValidator fieldValidator = null;\r
73     // -- initialize attribute descriptors\r
74 \r
75     // -- _label\r
76     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(\r
77             java.lang.String.class, "_label", "label",\r
78             org.exolab.castor.xml.NodeType.Attribute);\r
79     desc.setImmutable(true);\r
80     handler = new org.exolab.castor.xml.XMLFieldHandler()\r
81     {\r
82       public java.lang.Object getValue(java.lang.Object object)\r
83               throws IllegalStateException\r
84       {\r
85         ThresholdLine target = (ThresholdLine) object;\r
86         return target.getLabel();\r
87       }\r
88 \r
89       public void setValue(java.lang.Object object, java.lang.Object value)\r
90               throws IllegalStateException, IllegalArgumentException\r
91       {\r
92         try\r
93         {\r
94           ThresholdLine target = (ThresholdLine) object;\r
95           target.setLabel((java.lang.String) value);\r
96         } catch (java.lang.Exception ex)\r
97         {\r
98           throw new IllegalStateException(ex.toString());\r
99         }\r
100       }\r
101 \r
102       public java.lang.Object newInstance(java.lang.Object parent)\r
103       {\r
104         return null;\r
105       }\r
106     };\r
107     desc.setHandler(handler);\r
108     desc.setMultivalued(false);\r
109     addFieldDescriptor(desc);\r
110 \r
111     // -- validation code for: _label\r
112     fieldValidator = new org.exolab.castor.xml.FieldValidator();\r
113     { // -- local scope\r
114       org.exolab.castor.xml.validators.StringValidator typeValidator;\r
115       typeValidator = new org.exolab.castor.xml.validators.StringValidator();\r
116       fieldValidator.setValidator(typeValidator);\r
117       typeValidator.setWhiteSpace("preserve");\r
118     }\r
119     desc.setValidator(fieldValidator);\r
120     // -- _value\r
121     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(\r
122             java.lang.Float.TYPE, "_value", "value",\r
123             org.exolab.castor.xml.NodeType.Attribute);\r
124     handler = new org.exolab.castor.xml.XMLFieldHandler()\r
125     {\r
126       public java.lang.Object getValue(java.lang.Object object)\r
127               throws IllegalStateException\r
128       {\r
129         ThresholdLine target = (ThresholdLine) object;\r
130         if (!target.hasValue())\r
131         {\r
132           return null;\r
133         }\r
134         return new java.lang.Float(target.getValue());\r
135       }\r
136 \r
137       public void setValue(java.lang.Object object, java.lang.Object value)\r
138               throws IllegalStateException, IllegalArgumentException\r
139       {\r
140         try\r
141         {\r
142           ThresholdLine target = (ThresholdLine) object;\r
143           // if null, use delete method for optional primitives\r
144           if (value == null)\r
145           {\r
146             target.deleteValue();\r
147             return;\r
148           }\r
149           target.setValue(((java.lang.Float) value).floatValue());\r
150         } catch (java.lang.Exception ex)\r
151         {\r
152           throw new IllegalStateException(ex.toString());\r
153         }\r
154       }\r
155 \r
156       public java.lang.Object newInstance(java.lang.Object parent)\r
157       {\r
158         return null;\r
159       }\r
160     };\r
161     desc.setHandler(handler);\r
162     desc.setMultivalued(false);\r
163     addFieldDescriptor(desc);\r
164 \r
165     // -- validation code for: _value\r
166     fieldValidator = new org.exolab.castor.xml.FieldValidator();\r
167     { // -- local scope\r
168       org.exolab.castor.xml.validators.FloatValidator typeValidator;\r
169       typeValidator = new org.exolab.castor.xml.validators.FloatValidator();\r
170       fieldValidator.setValidator(typeValidator);\r
171       typeValidator.setMinInclusive((float) -3.4028235E38);\r
172       typeValidator.setMaxInclusive((float) 3.4028235E38);\r
173     }\r
174     desc.setValidator(fieldValidator);\r
175     // -- _colour\r
176     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(\r
177             java.lang.Integer.TYPE, "_colour", "colour",\r
178             org.exolab.castor.xml.NodeType.Attribute);\r
179     handler = new org.exolab.castor.xml.XMLFieldHandler()\r
180     {\r
181       public java.lang.Object getValue(java.lang.Object object)\r
182               throws IllegalStateException\r
183       {\r
184         ThresholdLine target = (ThresholdLine) object;\r
185         if (!target.hasColour())\r
186         {\r
187           return null;\r
188         }\r
189         return new java.lang.Integer(target.getColour());\r
190       }\r
191 \r
192       public void setValue(java.lang.Object object, java.lang.Object value)\r
193               throws IllegalStateException, IllegalArgumentException\r
194       {\r
195         try\r
196         {\r
197           ThresholdLine target = (ThresholdLine) object;\r
198           // if null, use delete method for optional primitives\r
199           if (value == null)\r
200           {\r
201             target.deleteColour();\r
202             return;\r
203           }\r
204           target.setColour(((java.lang.Integer) value).intValue());\r
205         } catch (java.lang.Exception ex)\r
206         {\r
207           throw new IllegalStateException(ex.toString());\r
208         }\r
209       }\r
210 \r
211       public java.lang.Object newInstance(java.lang.Object parent)\r
212       {\r
213         return null;\r
214       }\r
215     };\r
216     desc.setHandler(handler);\r
217     desc.setMultivalued(false);\r
218     addFieldDescriptor(desc);\r
219 \r
220     // -- validation code for: _colour\r
221     fieldValidator = new org.exolab.castor.xml.FieldValidator();\r
222     { // -- local scope\r
223       org.exolab.castor.xml.validators.IntValidator typeValidator;\r
224       typeValidator = new org.exolab.castor.xml.validators.IntValidator();\r
225       fieldValidator.setValidator(typeValidator);\r
226       typeValidator.setMinInclusive(-2147483648);\r
227       typeValidator.setMaxInclusive(2147483647);\r
228     }\r
229     desc.setValidator(fieldValidator);\r
230     // -- initialize element descriptors\r
231 \r
232   }\r
233 \r
234   // -----------/\r
235   // - Methods -/\r
236   // -----------/\r
237 \r
238   /**\r
239    * Method getAccessMode.\r
240    * \r
241    * @return the access mode specified for this class.\r
242    */\r
243   public org.exolab.castor.mapping.AccessMode getAccessMode()\r
244   {\r
245     return null;\r
246   }\r
247 \r
248   /**\r
249    * Method getIdentity.\r
250    * \r
251    * @return the identity field, null if this class has no identity.\r
252    */\r
253   public org.exolab.castor.mapping.FieldDescriptor getIdentity()\r
254   {\r
255     return super.getIdentity();\r
256   }\r
257 \r
258   /**\r
259    * Method getJavaClass.\r
260    * \r
261    * @return the Java class represented by this descriptor.\r
262    */\r
263   public java.lang.Class getJavaClass()\r
264   {\r
265     return jalview.schemabinding.version2.ThresholdLine.class;\r
266   }\r
267 \r
268   /**\r
269    * Method getNameSpacePrefix.\r
270    * \r
271    * @return the namespace prefix to use when marshaling as XML.\r
272    */\r
273   public java.lang.String getNameSpacePrefix()\r
274   {\r
275     return _nsPrefix;\r
276   }\r
277 \r
278   /**\r
279    * Method getNameSpaceURI.\r
280    * \r
281    * @return the namespace URI used when marshaling and unmarshaling as XML.\r
282    */\r
283   public java.lang.String getNameSpaceURI()\r
284   {\r
285     return _nsURI;\r
286   }\r
287 \r
288   /**\r
289    * Method getValidator.\r
290    * \r
291    * @return a specific validator for the class described by this\r
292    *         ClassDescriptor.\r
293    */\r
294   public org.exolab.castor.xml.TypeValidator getValidator()\r
295   {\r
296     return this;\r
297   }\r
298 \r
299   /**\r
300    * Method getXMLName.\r
301    * \r
302    * @return the XML Name for the Class being described.\r
303    */\r
304   public java.lang.String getXMLName()\r
305   {\r
306     return _xmlName;\r
307   }\r
308 \r
309   /**\r
310    * Method isElementDefinition.\r
311    * \r
312    * @return true if XML schema definition of this Class is that of a global\r
313    *         element or element with anonymous type definition.\r
314    */\r
315   public boolean isElementDefinition()\r
316   {\r
317     return _elementDefinition;\r
318   }\r
319 \r
320 }\r