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