1ef6086e34f69c138342204a3d00c44748adc8dc
[jalview.git] / src / jalview / schemabinding / version2 / descriptors / ColourDescriptor.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.Colour;
25
26 /**
27  * Class ColourDescriptor.
28  * 
29  * @version $Revision$ $Date$
30  */
31 public class ColourDescriptor 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 ColourDescriptor()
64   {
65     super();
66     _xmlName = "colour";
67     _elementDefinition = true;
68     org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
69     org.exolab.castor.mapping.FieldHandler handler = null;
70     org.exolab.castor.xml.FieldValidator fieldValidator = null;
71     // -- initialize attribute descriptors
72
73     // -- _name
74     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
75             java.lang.String.class, "_name", "Name",
76             org.exolab.castor.xml.NodeType.Attribute);
77     desc.setImmutable(true);
78     handler = new org.exolab.castor.xml.XMLFieldHandler()
79     {
80       public java.lang.Object getValue(java.lang.Object object)
81               throws IllegalStateException
82       {
83         Colour target = (Colour) object;
84         return target.getName();
85       }
86
87       public void setValue(java.lang.Object object, java.lang.Object value)
88               throws IllegalStateException, IllegalArgumentException
89       {
90         try
91         {
92           Colour target = (Colour) object;
93           target.setName((java.lang.String) value);
94         } catch (java.lang.Exception ex)
95         {
96           throw new IllegalStateException(ex.toString());
97         }
98       }
99
100       public java.lang.Object newInstance(java.lang.Object parent)
101       {
102         return null;
103       }
104     };
105     desc.setHandler(handler);
106     desc.setMultivalued(false);
107     addFieldDescriptor(desc);
108
109     // -- validation code for: _name
110     fieldValidator = new org.exolab.castor.xml.FieldValidator();
111     { // -- local scope
112       org.exolab.castor.xml.validators.StringValidator typeValidator;
113       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
114       fieldValidator.setValidator(typeValidator);
115       typeValidator.setWhiteSpace("preserve");
116     }
117     desc.setValidator(fieldValidator);
118     // -- _RGB
119     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
120             java.lang.String.class, "_RGB", "RGB",
121             org.exolab.castor.xml.NodeType.Attribute);
122     desc.setImmutable(true);
123     handler = new org.exolab.castor.xml.XMLFieldHandler()
124     {
125       public java.lang.Object getValue(java.lang.Object object)
126               throws IllegalStateException
127       {
128         Colour target = (Colour) object;
129         return target.getRGB();
130       }
131
132       public void setValue(java.lang.Object object, java.lang.Object value)
133               throws IllegalStateException, IllegalArgumentException
134       {
135         try
136         {
137           Colour target = (Colour) object;
138           target.setRGB((java.lang.String) value);
139         } catch (java.lang.Exception ex)
140         {
141           throw new IllegalStateException(ex.toString());
142         }
143       }
144
145       public java.lang.Object newInstance(java.lang.Object parent)
146       {
147         return null;
148       }
149     };
150     desc.setHandler(handler);
151     desc.setRequired(true);
152     desc.setMultivalued(false);
153     addFieldDescriptor(desc);
154
155     // -- validation code for: _RGB
156     fieldValidator = new org.exolab.castor.xml.FieldValidator();
157     fieldValidator.setMinOccurs(1);
158     { // -- local scope
159       org.exolab.castor.xml.validators.StringValidator typeValidator;
160       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
161       fieldValidator.setValidator(typeValidator);
162       typeValidator.setWhiteSpace("preserve");
163     }
164     desc.setValidator(fieldValidator);
165     // -- _minRGB
166     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
167             java.lang.String.class, "_minRGB", "minRGB",
168             org.exolab.castor.xml.NodeType.Attribute);
169     desc.setImmutable(true);
170     handler = new org.exolab.castor.xml.XMLFieldHandler()
171     {
172       public java.lang.Object getValue(java.lang.Object object)
173               throws IllegalStateException
174       {
175         Colour target = (Colour) object;
176         return target.getMinRGB();
177       }
178
179       public void setValue(java.lang.Object object, java.lang.Object value)
180               throws IllegalStateException, IllegalArgumentException
181       {
182         try
183         {
184           Colour target = (Colour) object;
185           target.setMinRGB((java.lang.String) value);
186         } catch (java.lang.Exception ex)
187         {
188           throw new IllegalStateException(ex.toString());
189         }
190       }
191
192       public java.lang.Object newInstance(java.lang.Object parent)
193       {
194         return null;
195       }
196     };
197     desc.setHandler(handler);
198     desc.setMultivalued(false);
199     addFieldDescriptor(desc);
200
201     // -- validation code for: _minRGB
202     fieldValidator = new org.exolab.castor.xml.FieldValidator();
203     { // -- local scope
204       org.exolab.castor.xml.validators.StringValidator typeValidator;
205       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
206       fieldValidator.setValidator(typeValidator);
207       typeValidator.setWhiteSpace("preserve");
208     }
209     desc.setValidator(fieldValidator);
210     // -- _threshType
211     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
212             java.lang.String.class, "_threshType", "threshType",
213             org.exolab.castor.xml.NodeType.Attribute);
214     desc.setImmutable(true);
215     handler = new org.exolab.castor.xml.XMLFieldHandler()
216     {
217       public java.lang.Object getValue(java.lang.Object object)
218               throws IllegalStateException
219       {
220         Colour target = (Colour) object;
221         return target.getThreshType();
222       }
223
224       public void setValue(java.lang.Object object, java.lang.Object value)
225               throws IllegalStateException, IllegalArgumentException
226       {
227         try
228         {
229           Colour target = (Colour) object;
230           target.setThreshType((java.lang.String) value);
231         } catch (java.lang.Exception ex)
232         {
233           throw new IllegalStateException(ex.toString());
234         }
235       }
236
237       public java.lang.Object newInstance(java.lang.Object parent)
238       {
239         return null;
240       }
241     };
242     desc.setHandler(handler);
243     desc.setMultivalued(false);
244     addFieldDescriptor(desc);
245
246     // -- validation code for: _threshType
247     fieldValidator = new org.exolab.castor.xml.FieldValidator();
248     { // -- local scope
249       org.exolab.castor.xml.validators.StringValidator typeValidator;
250       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
251       fieldValidator.setValidator(typeValidator);
252       typeValidator.setWhiteSpace("preserve");
253     }
254     desc.setValidator(fieldValidator);
255     // -- _threshold
256     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
257             java.lang.Float.TYPE, "_threshold", "threshold",
258             org.exolab.castor.xml.NodeType.Attribute);
259     handler = new org.exolab.castor.xml.XMLFieldHandler()
260     {
261       public java.lang.Object getValue(java.lang.Object object)
262               throws IllegalStateException
263       {
264         Colour target = (Colour) object;
265         if (!target.hasThreshold())
266         {
267           return null;
268         }
269         return new java.lang.Float(target.getThreshold());
270       }
271
272       public void setValue(java.lang.Object object, java.lang.Object value)
273               throws IllegalStateException, IllegalArgumentException
274       {
275         try
276         {
277           Colour target = (Colour) object;
278           // if null, use delete method for optional primitives
279           if (value == null)
280           {
281             target.deleteThreshold();
282             return;
283           }
284           target.setThreshold(((java.lang.Float) value).floatValue());
285         } catch (java.lang.Exception ex)
286         {
287           throw new IllegalStateException(ex.toString());
288         }
289       }
290
291       public java.lang.Object newInstance(java.lang.Object parent)
292       {
293         return null;
294       }
295     };
296     desc.setHandler(handler);
297     desc.setMultivalued(false);
298     addFieldDescriptor(desc);
299
300     // -- validation code for: _threshold
301     fieldValidator = new org.exolab.castor.xml.FieldValidator();
302     { // -- local scope
303       org.exolab.castor.xml.validators.FloatValidator typeValidator;
304       typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
305       fieldValidator.setValidator(typeValidator);
306       typeValidator.setMinInclusive((float) -3.4028235E38);
307       typeValidator.setMaxInclusive((float) 3.4028235E38);
308     }
309     desc.setValidator(fieldValidator);
310     // -- _max
311     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
312             java.lang.Float.TYPE, "_max", "max",
313             org.exolab.castor.xml.NodeType.Attribute);
314     handler = new org.exolab.castor.xml.XMLFieldHandler()
315     {
316       public java.lang.Object getValue(java.lang.Object object)
317               throws IllegalStateException
318       {
319         Colour target = (Colour) object;
320         if (!target.hasMax())
321         {
322           return null;
323         }
324         return new java.lang.Float(target.getMax());
325       }
326
327       public void setValue(java.lang.Object object, java.lang.Object value)
328               throws IllegalStateException, IllegalArgumentException
329       {
330         try
331         {
332           Colour target = (Colour) object;
333           // if null, use delete method for optional primitives
334           if (value == null)
335           {
336             target.deleteMax();
337             return;
338           }
339           target.setMax(((java.lang.Float) value).floatValue());
340         } catch (java.lang.Exception ex)
341         {
342           throw new IllegalStateException(ex.toString());
343         }
344       }
345
346       public java.lang.Object newInstance(java.lang.Object parent)
347       {
348         return null;
349       }
350     };
351     desc.setHandler(handler);
352     desc.setMultivalued(false);
353     addFieldDescriptor(desc);
354
355     // -- validation code for: _max
356     fieldValidator = new org.exolab.castor.xml.FieldValidator();
357     { // -- local scope
358       org.exolab.castor.xml.validators.FloatValidator typeValidator;
359       typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
360       fieldValidator.setValidator(typeValidator);
361       typeValidator.setMinInclusive((float) -3.4028235E38);
362       typeValidator.setMaxInclusive((float) 3.4028235E38);
363     }
364     desc.setValidator(fieldValidator);
365     // -- _min
366     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
367             java.lang.Float.TYPE, "_min", "min",
368             org.exolab.castor.xml.NodeType.Attribute);
369     handler = new org.exolab.castor.xml.XMLFieldHandler()
370     {
371       public java.lang.Object getValue(java.lang.Object object)
372               throws IllegalStateException
373       {
374         Colour target = (Colour) object;
375         if (!target.hasMin())
376         {
377           return null;
378         }
379         return new java.lang.Float(target.getMin());
380       }
381
382       public void setValue(java.lang.Object object, java.lang.Object value)
383               throws IllegalStateException, IllegalArgumentException
384       {
385         try
386         {
387           Colour target = (Colour) object;
388           // if null, use delete method for optional primitives
389           if (value == null)
390           {
391             target.deleteMin();
392             return;
393           }
394           target.setMin(((java.lang.Float) value).floatValue());
395         } catch (java.lang.Exception ex)
396         {
397           throw new IllegalStateException(ex.toString());
398         }
399       }
400
401       public java.lang.Object newInstance(java.lang.Object parent)
402       {
403         return null;
404       }
405     };
406     desc.setHandler(handler);
407     desc.setMultivalued(false);
408     addFieldDescriptor(desc);
409
410     // -- validation code for: _min
411     fieldValidator = new org.exolab.castor.xml.FieldValidator();
412     { // -- local scope
413       org.exolab.castor.xml.validators.FloatValidator typeValidator;
414       typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
415       fieldValidator.setValidator(typeValidator);
416       typeValidator.setMinInclusive((float) -3.4028235E38);
417       typeValidator.setMaxInclusive((float) 3.4028235E38);
418     }
419     desc.setValidator(fieldValidator);
420     // -- _colourByLabel
421     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
422             java.lang.Boolean.TYPE, "_colourByLabel", "colourByLabel",
423             org.exolab.castor.xml.NodeType.Attribute);
424     handler = new org.exolab.castor.xml.XMLFieldHandler()
425     {
426       public java.lang.Object getValue(java.lang.Object object)
427               throws IllegalStateException
428       {
429         Colour target = (Colour) object;
430         if (!target.hasColourByLabel())
431         {
432           return null;
433         }
434         return (target.getColourByLabel() ? java.lang.Boolean.TRUE
435                 : java.lang.Boolean.FALSE);
436       }
437
438       public void setValue(java.lang.Object object, java.lang.Object value)
439               throws IllegalStateException, IllegalArgumentException
440       {
441         try
442         {
443           Colour target = (Colour) object;
444           // if null, use delete method for optional primitives
445           if (value == null)
446           {
447             target.deleteColourByLabel();
448             return;
449           }
450           target.setColourByLabel(((java.lang.Boolean) value)
451                   .booleanValue());
452         } catch (java.lang.Exception ex)
453         {
454           throw new IllegalStateException(ex.toString());
455         }
456       }
457
458       public java.lang.Object newInstance(java.lang.Object parent)
459       {
460         return null;
461       }
462     };
463     desc.setHandler(handler);
464     desc.setMultivalued(false);
465     addFieldDescriptor(desc);
466
467     // -- validation code for: _colourByLabel
468     fieldValidator = new org.exolab.castor.xml.FieldValidator();
469     { // -- local scope
470       org.exolab.castor.xml.validators.BooleanValidator typeValidator;
471       typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
472       fieldValidator.setValidator(typeValidator);
473     }
474     desc.setValidator(fieldValidator);
475     // -- _autoScale
476     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
477             java.lang.Boolean.TYPE, "_autoScale", "autoScale",
478             org.exolab.castor.xml.NodeType.Attribute);
479     handler = new org.exolab.castor.xml.XMLFieldHandler()
480     {
481       public java.lang.Object getValue(java.lang.Object object)
482               throws IllegalStateException
483       {
484         Colour target = (Colour) object;
485         if (!target.hasAutoScale())
486         {
487           return null;
488         }
489         return (target.getAutoScale() ? java.lang.Boolean.TRUE
490                 : java.lang.Boolean.FALSE);
491       }
492
493       public void setValue(java.lang.Object object, java.lang.Object value)
494               throws IllegalStateException, IllegalArgumentException
495       {
496         try
497         {
498           Colour target = (Colour) object;
499           // if null, use delete method for optional primitives
500           if (value == null)
501           {
502             target.deleteAutoScale();
503             return;
504           }
505           target.setAutoScale(((java.lang.Boolean) value).booleanValue());
506         } catch (java.lang.Exception ex)
507         {
508           throw new IllegalStateException(ex.toString());
509         }
510       }
511
512       public java.lang.Object newInstance(java.lang.Object parent)
513       {
514         return null;
515       }
516     };
517     desc.setHandler(handler);
518     desc.setMultivalued(false);
519     addFieldDescriptor(desc);
520
521     // -- validation code for: _autoScale
522     fieldValidator = new org.exolab.castor.xml.FieldValidator();
523     { // -- local scope
524       org.exolab.castor.xml.validators.BooleanValidator typeValidator;
525       typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
526       fieldValidator.setValidator(typeValidator);
527     }
528     desc.setValidator(fieldValidator);
529     // -- initialize element descriptors
530
531   }
532
533   // -----------/
534   // - Methods -/
535   // -----------/
536
537   /**
538    * Method getAccessMode.
539    * 
540    * @return the access mode specified for this class.
541    */
542   public org.exolab.castor.mapping.AccessMode getAccessMode()
543   {
544     return null;
545   }
546
547   /**
548    * Method getIdentity.
549    * 
550    * @return the identity field, null if this class has no identity.
551    */
552   public org.exolab.castor.mapping.FieldDescriptor getIdentity()
553   {
554     return super.getIdentity();
555   }
556
557   /**
558    * Method getJavaClass.
559    * 
560    * @return the Java class represented by this descriptor.
561    */
562   public java.lang.Class getJavaClass()
563   {
564     return jalview.schemabinding.version2.Colour.class;
565   }
566
567   /**
568    * Method getNameSpacePrefix.
569    * 
570    * @return the namespace prefix to use when marshaling as XML.
571    */
572   public java.lang.String getNameSpacePrefix()
573   {
574     return _nsPrefix;
575   }
576
577   /**
578    * Method getNameSpaceURI.
579    * 
580    * @return the namespace URI used when marshaling and unmarshaling as XML.
581    */
582   public java.lang.String getNameSpaceURI()
583   {
584     return _nsURI;
585   }
586
587   /**
588    * Method getValidator.
589    * 
590    * @return a specific validator for the class described by this
591    *         ClassDescriptor.
592    */
593   public org.exolab.castor.xml.TypeValidator getValidator()
594   {
595     return this;
596   }
597
598   /**
599    * Method getXMLName.
600    * 
601    * @return the XML Name for the Class being described.
602    */
603   public java.lang.String getXMLName()
604   {
605     return _xmlName;
606   }
607
608   /**
609    * Method isElementDefinition.
610    * 
611    * @return true if XML schema definition of this Class is that of a global
612    *         element or element with anonymous type definition.
613    */
614   public boolean isElementDefinition()
615   {
616     return _elementDefinition;
617   }
618
619 }