af72c3ae903be7a6d28771d7083f396e5a4120b6
[jalview.git] / src / jalview / schemabinding / version2 / descriptors / AnnotationElementDescriptor.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3  * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10  *  
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.schemabinding.version2.descriptors;
19
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
23
24 import jalview.schemabinding.version2.AnnotationElement;
25
26 /**
27  * Class AnnotationElementDescriptor.
28  * 
29  * @version $Revision$ $Date$
30  */
31 public class AnnotationElementDescriptor extends
32         org.exolab.castor.xml.util.XMLClassDescriptorImpl
33 {
34
35   // --------------------------/
36   // - Class/Member Variables -/
37   // --------------------------/
38
39   /**
40    * Field _elementDefinition.
41    */
42   private boolean _elementDefinition;
43
44   /**
45    * Field _nsPrefix.
46    */
47   private java.lang.String _nsPrefix;
48
49   /**
50    * Field _nsURI.
51    */
52   private java.lang.String _nsURI;
53
54   /**
55    * Field _xmlName.
56    */
57   private java.lang.String _xmlName;
58
59   // ----------------/
60   // - Constructors -/
61   // ----------------/
62
63   public AnnotationElementDescriptor()
64   {
65     super();
66     _nsURI = "www.vamsas.ac.uk/jalview/version2";
67     _xmlName = "annotationElement";
68     _elementDefinition = true;
69
70     // -- set grouping compositor
71     setCompositorAsSequence();
72     org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
73     org.exolab.castor.mapping.FieldHandler handler = null;
74     org.exolab.castor.xml.FieldValidator fieldValidator = null;
75     // -- initialize attribute descriptors
76
77     // -- _position
78     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
79             java.lang.Integer.TYPE, "_position", "position",
80             org.exolab.castor.xml.NodeType.Attribute);
81     handler = new org.exolab.castor.xml.XMLFieldHandler()
82     {
83       public java.lang.Object getValue(java.lang.Object object)
84               throws IllegalStateException
85       {
86         AnnotationElement target = (AnnotationElement) object;
87         if (!target.hasPosition())
88         {
89           return null;
90         }
91         return new java.lang.Integer(target.getPosition());
92       }
93
94       public void setValue(java.lang.Object object, java.lang.Object value)
95               throws IllegalStateException, IllegalArgumentException
96       {
97         try
98         {
99           AnnotationElement target = (AnnotationElement) object;
100           // ignore null values for non optional primitives
101           if (value == null)
102           {
103             return;
104           }
105
106           target.setPosition(((java.lang.Integer) value).intValue());
107         } catch (java.lang.Exception ex)
108         {
109           throw new IllegalStateException(ex.toString());
110         }
111       }
112
113       public java.lang.Object newInstance(java.lang.Object parent)
114       {
115         return null;
116       }
117     };
118     desc.setHandler(handler);
119     desc.setRequired(true);
120     desc.setMultivalued(false);
121     addFieldDescriptor(desc);
122
123     // -- validation code for: _position
124     fieldValidator = new org.exolab.castor.xml.FieldValidator();
125     fieldValidator.setMinOccurs(1);
126     { // -- local scope
127       org.exolab.castor.xml.validators.IntValidator typeValidator;
128       typeValidator = new org.exolab.castor.xml.validators.IntValidator();
129       fieldValidator.setValidator(typeValidator);
130       typeValidator.setMinInclusive(-2147483648);
131       typeValidator.setMaxInclusive(2147483647);
132     }
133     desc.setValidator(fieldValidator);
134     // -- _colour
135     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
136             java.lang.Integer.TYPE, "_colour", "colour",
137             org.exolab.castor.xml.NodeType.Attribute);
138     handler = new org.exolab.castor.xml.XMLFieldHandler()
139     {
140       public java.lang.Object getValue(java.lang.Object object)
141               throws IllegalStateException
142       {
143         AnnotationElement target = (AnnotationElement) object;
144         if (!target.hasColour())
145         {
146           return null;
147         }
148         return new java.lang.Integer(target.getColour());
149       }
150
151       public void setValue(java.lang.Object object, java.lang.Object value)
152               throws IllegalStateException, IllegalArgumentException
153       {
154         try
155         {
156           AnnotationElement target = (AnnotationElement) object;
157           // if null, use delete method for optional primitives
158           if (value == null)
159           {
160             target.deleteColour();
161             return;
162           }
163           target.setColour(((java.lang.Integer) value).intValue());
164         } catch (java.lang.Exception ex)
165         {
166           throw new IllegalStateException(ex.toString());
167         }
168       }
169
170       public java.lang.Object newInstance(java.lang.Object parent)
171       {
172         return null;
173       }
174     };
175     desc.setHandler(handler);
176     desc.setMultivalued(false);
177     addFieldDescriptor(desc);
178
179     // -- validation code for: _colour
180     fieldValidator = new org.exolab.castor.xml.FieldValidator();
181     { // -- local scope
182       org.exolab.castor.xml.validators.IntValidator typeValidator;
183       typeValidator = new org.exolab.castor.xml.validators.IntValidator();
184       fieldValidator.setValidator(typeValidator);
185       typeValidator.setMinInclusive(-2147483648);
186       typeValidator.setMaxInclusive(2147483647);
187     }
188     desc.setValidator(fieldValidator);
189     // -- initialize element descriptors
190
191     // -- _displayCharacter
192     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
193             java.lang.String.class, "_displayCharacter",
194             "displayCharacter", org.exolab.castor.xml.NodeType.Element);
195     desc.setImmutable(true);
196     handler = new org.exolab.castor.xml.XMLFieldHandler()
197     {
198       public java.lang.Object getValue(java.lang.Object object)
199               throws IllegalStateException
200       {
201         AnnotationElement target = (AnnotationElement) object;
202         return target.getDisplayCharacter();
203       }
204
205       public void setValue(java.lang.Object object, java.lang.Object value)
206               throws IllegalStateException, IllegalArgumentException
207       {
208         try
209         {
210           AnnotationElement target = (AnnotationElement) object;
211           target.setDisplayCharacter((java.lang.String) value);
212         } catch (java.lang.Exception ex)
213         {
214           throw new IllegalStateException(ex.toString());
215         }
216       }
217
218       public java.lang.Object newInstance(java.lang.Object parent)
219       {
220         return null;
221       }
222     };
223     desc.setHandler(handler);
224     desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
225     desc.setMultivalued(false);
226     addFieldDescriptor(desc);
227
228     // -- validation code for: _displayCharacter
229     fieldValidator = new org.exolab.castor.xml.FieldValidator();
230     { // -- local scope
231       org.exolab.castor.xml.validators.StringValidator typeValidator;
232       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
233       fieldValidator.setValidator(typeValidator);
234       typeValidator.setWhiteSpace("preserve");
235     }
236     desc.setValidator(fieldValidator);
237     // -- _description
238     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
239             java.lang.String.class, "_description", "description",
240             org.exolab.castor.xml.NodeType.Element);
241     desc.setImmutable(true);
242     handler = new org.exolab.castor.xml.XMLFieldHandler()
243     {
244       public java.lang.Object getValue(java.lang.Object object)
245               throws IllegalStateException
246       {
247         AnnotationElement target = (AnnotationElement) object;
248         return target.getDescription();
249       }
250
251       public void setValue(java.lang.Object object, java.lang.Object value)
252               throws IllegalStateException, IllegalArgumentException
253       {
254         try
255         {
256           AnnotationElement target = (AnnotationElement) object;
257           target.setDescription((java.lang.String) value);
258         } catch (java.lang.Exception ex)
259         {
260           throw new IllegalStateException(ex.toString());
261         }
262       }
263
264       public java.lang.Object newInstance(java.lang.Object parent)
265       {
266         return null;
267       }
268     };
269     desc.setHandler(handler);
270     desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
271     desc.setMultivalued(false);
272     addFieldDescriptor(desc);
273
274     // -- validation code for: _description
275     fieldValidator = new org.exolab.castor.xml.FieldValidator();
276     { // -- local scope
277       org.exolab.castor.xml.validators.StringValidator typeValidator;
278       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
279       fieldValidator.setValidator(typeValidator);
280       typeValidator.setWhiteSpace("preserve");
281     }
282     desc.setValidator(fieldValidator);
283     // -- _secondaryStructure
284     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
285             java.lang.String.class, "_secondaryStructure",
286             "secondaryStructure", org.exolab.castor.xml.NodeType.Element);
287     desc.setImmutable(true);
288     handler = new org.exolab.castor.xml.XMLFieldHandler()
289     {
290       public java.lang.Object getValue(java.lang.Object object)
291               throws IllegalStateException
292       {
293         AnnotationElement target = (AnnotationElement) object;
294         return target.getSecondaryStructure();
295       }
296
297       public void setValue(java.lang.Object object, java.lang.Object value)
298               throws IllegalStateException, IllegalArgumentException
299       {
300         try
301         {
302           AnnotationElement target = (AnnotationElement) object;
303           target.setSecondaryStructure((java.lang.String) value);
304         } catch (java.lang.Exception ex)
305         {
306           throw new IllegalStateException(ex.toString());
307         }
308       }
309
310       public java.lang.Object newInstance(java.lang.Object parent)
311       {
312         return null;
313       }
314     };
315     desc.setHandler(handler);
316     desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
317     desc.setMultivalued(false);
318     addFieldDescriptor(desc);
319
320     // -- validation code for: _secondaryStructure
321     fieldValidator = new org.exolab.castor.xml.FieldValidator();
322     { // -- local scope
323       org.exolab.castor.xml.validators.StringValidator typeValidator;
324       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
325       fieldValidator.setValidator(typeValidator);
326       typeValidator.setWhiteSpace("preserve");
327       typeValidator.setLength(1);
328     }
329     desc.setValidator(fieldValidator);
330     // -- _value
331     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
332             java.lang.Float.TYPE, "_value", "value",
333             org.exolab.castor.xml.NodeType.Element);
334     handler = new org.exolab.castor.xml.XMLFieldHandler()
335     {
336       public java.lang.Object getValue(java.lang.Object object)
337               throws IllegalStateException
338       {
339         AnnotationElement target = (AnnotationElement) object;
340         if (!target.hasValue())
341         {
342           return null;
343         }
344         return new java.lang.Float(target.getValue());
345       }
346
347       public void setValue(java.lang.Object object, java.lang.Object value)
348               throws IllegalStateException, IllegalArgumentException
349       {
350         try
351         {
352           AnnotationElement target = (AnnotationElement) object;
353           // if null, use delete method for optional primitives
354           if (value == null)
355           {
356             target.deleteValue();
357             return;
358           }
359           target.setValue(((java.lang.Float) value).floatValue());
360         } catch (java.lang.Exception ex)
361         {
362           throw new IllegalStateException(ex.toString());
363         }
364       }
365
366       public java.lang.Object newInstance(java.lang.Object parent)
367       {
368         return null;
369       }
370     };
371     desc.setHandler(handler);
372     desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
373     desc.setMultivalued(false);
374     addFieldDescriptor(desc);
375
376     // -- validation code for: _value
377     fieldValidator = new org.exolab.castor.xml.FieldValidator();
378     { // -- local scope
379       org.exolab.castor.xml.validators.FloatValidator typeValidator;
380       typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
381       fieldValidator.setValidator(typeValidator);
382       typeValidator.setMinInclusive((float) -3.4028235E38);
383       typeValidator.setMaxInclusive((float) 3.4028235E38);
384     }
385     desc.setValidator(fieldValidator);
386   }
387
388   // -----------/
389   // - Methods -/
390   // -----------/
391
392   /**
393    * Method getAccessMode.
394    * 
395    * @return the access mode specified for this class.
396    */
397   public org.exolab.castor.mapping.AccessMode getAccessMode()
398   {
399     return null;
400   }
401
402   /**
403    * Method getIdentity.
404    * 
405    * @return the identity field, null if this class has no identity.
406    */
407   public org.exolab.castor.mapping.FieldDescriptor getIdentity()
408   {
409     return super.getIdentity();
410   }
411
412   /**
413    * Method getJavaClass.
414    * 
415    * @return the Java class represented by this descriptor.
416    */
417   public java.lang.Class getJavaClass()
418   {
419     return jalview.schemabinding.version2.AnnotationElement.class;
420   }
421
422   /**
423    * Method getNameSpacePrefix.
424    * 
425    * @return the namespace prefix to use when marshaling as XML.
426    */
427   public java.lang.String getNameSpacePrefix()
428   {
429     return _nsPrefix;
430   }
431
432   /**
433    * Method getNameSpaceURI.
434    * 
435    * @return the namespace URI used when marshaling and unmarshaling as XML.
436    */
437   public java.lang.String getNameSpaceURI()
438   {
439     return _nsURI;
440   }
441
442   /**
443    * Method getValidator.
444    * 
445    * @return a specific validator for the class described by this
446    *         ClassDescriptor.
447    */
448   public org.exolab.castor.xml.TypeValidator getValidator()
449   {
450     return this;
451   }
452
453   /**
454    * Method getXMLName.
455    * 
456    * @return the XML Name for the Class being described.
457    */
458   public java.lang.String getXMLName()
459   {
460     return _xmlName;
461   }
462
463   /**
464    * Method isElementDefinition.
465    * 
466    * @return true if XML schema definition of this Class is that of a global
467    *         element or element with anonymous type definition.
468    */
469   public boolean isElementDefinition()
470   {
471     return _elementDefinition;
472   }
473
474 }