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