55b7fe3779f71b86b2077a7cc251f39df0d6c722
[jalview.git] / src / jalview / schemabinding / version2 / descriptors / SettingDescriptor.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.Setting;
25
26 /**
27  * Class SettingDescriptor.
28  * 
29  * @version $Revision$ $Date$
30  */
31 public class SettingDescriptor 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 SettingDescriptor()
64   {
65     super();
66     _nsURI = "www.jalview.org";
67     _xmlName = "setting";
68     _elementDefinition = true;
69     org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
70     org.exolab.castor.mapping.FieldHandler handler = null;
71     org.exolab.castor.xml.FieldValidator fieldValidator = null;
72     // -- initialize attribute descriptors
73
74     // -- _type
75     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
76             java.lang.String.class, "_type", "type",
77             org.exolab.castor.xml.NodeType.Attribute);
78     desc.setImmutable(true);
79     handler = new org.exolab.castor.xml.XMLFieldHandler()
80     {
81       public java.lang.Object getValue(java.lang.Object object)
82               throws IllegalStateException
83       {
84         Setting target = (Setting) object;
85         return target.getType();
86       }
87
88       public void setValue(java.lang.Object object, java.lang.Object value)
89               throws IllegalStateException, IllegalArgumentException
90       {
91         try
92         {
93           Setting target = (Setting) object;
94           target.setType((java.lang.String) value);
95         } catch (java.lang.Exception ex)
96         {
97           throw new IllegalStateException(ex.toString());
98         }
99       }
100
101       public java.lang.Object newInstance(java.lang.Object parent)
102       {
103         return null;
104       }
105     };
106     desc.setHandler(handler);
107     desc.setRequired(true);
108     desc.setMultivalued(false);
109     addFieldDescriptor(desc);
110
111     // -- validation code for: _type
112     fieldValidator = new org.exolab.castor.xml.FieldValidator();
113     fieldValidator.setMinOccurs(1);
114     { // -- local scope
115       org.exolab.castor.xml.validators.StringValidator typeValidator;
116       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
117       fieldValidator.setValidator(typeValidator);
118       typeValidator.setWhiteSpace("preserve");
119     }
120     desc.setValidator(fieldValidator);
121     // -- _colour
122     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
123             java.lang.Integer.TYPE, "_colour", "colour",
124             org.exolab.castor.xml.NodeType.Attribute);
125     handler = new org.exolab.castor.xml.XMLFieldHandler()
126     {
127       public java.lang.Object getValue(java.lang.Object object)
128               throws IllegalStateException
129       {
130         Setting target = (Setting) object;
131         if (!target.hasColour())
132         {
133           return null;
134         }
135         return new java.lang.Integer(target.getColour());
136       }
137
138       public void setValue(java.lang.Object object, java.lang.Object value)
139               throws IllegalStateException, IllegalArgumentException
140       {
141         try
142         {
143           Setting target = (Setting) object;
144           // ignore null values for non optional primitives
145           if (value == null)
146           {
147             return;
148           }
149
150           target.setColour(((java.lang.Integer) value).intValue());
151         } catch (java.lang.Exception ex)
152         {
153           throw new IllegalStateException(ex.toString());
154         }
155       }
156
157       public java.lang.Object newInstance(java.lang.Object parent)
158       {
159         return null;
160       }
161     };
162     desc.setHandler(handler);
163     desc.setRequired(true);
164     desc.setMultivalued(false);
165     addFieldDescriptor(desc);
166
167     // -- validation code for: _colour
168     fieldValidator = new org.exolab.castor.xml.FieldValidator();
169     fieldValidator.setMinOccurs(1);
170     { // -- local scope
171       org.exolab.castor.xml.validators.IntValidator typeValidator;
172       typeValidator = new org.exolab.castor.xml.validators.IntValidator();
173       fieldValidator.setValidator(typeValidator);
174       typeValidator.setMinInclusive(-2147483648);
175       typeValidator.setMaxInclusive(2147483647);
176     }
177     desc.setValidator(fieldValidator);
178     // -- _display
179     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
180             java.lang.Boolean.TYPE, "_display", "display",
181             org.exolab.castor.xml.NodeType.Attribute);
182     handler = new org.exolab.castor.xml.XMLFieldHandler()
183     {
184       public java.lang.Object getValue(java.lang.Object object)
185               throws IllegalStateException
186       {
187         Setting target = (Setting) object;
188         if (!target.hasDisplay())
189         {
190           return null;
191         }
192         return (target.getDisplay() ? java.lang.Boolean.TRUE
193                 : java.lang.Boolean.FALSE);
194       }
195
196       public void setValue(java.lang.Object object, java.lang.Object value)
197               throws IllegalStateException, IllegalArgumentException
198       {
199         try
200         {
201           Setting target = (Setting) object;
202           // ignore null values for non optional primitives
203           if (value == null)
204           {
205             return;
206           }
207
208           target.setDisplay(((java.lang.Boolean) value).booleanValue());
209         } catch (java.lang.Exception ex)
210         {
211           throw new IllegalStateException(ex.toString());
212         }
213       }
214
215       public java.lang.Object newInstance(java.lang.Object parent)
216       {
217         return null;
218       }
219     };
220     desc.setHandler(handler);
221     desc.setRequired(true);
222     desc.setMultivalued(false);
223     addFieldDescriptor(desc);
224
225     // -- validation code for: _display
226     fieldValidator = new org.exolab.castor.xml.FieldValidator();
227     fieldValidator.setMinOccurs(1);
228     { // -- local scope
229       org.exolab.castor.xml.validators.BooleanValidator typeValidator;
230       typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
231       fieldValidator.setValidator(typeValidator);
232     }
233     desc.setValidator(fieldValidator);
234     // -- _order
235     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
236             java.lang.Float.TYPE, "_order", "order",
237             org.exolab.castor.xml.NodeType.Attribute);
238     handler = new org.exolab.castor.xml.XMLFieldHandler()
239     {
240       public java.lang.Object getValue(java.lang.Object object)
241               throws IllegalStateException
242       {
243         Setting target = (Setting) object;
244         if (!target.hasOrder())
245         {
246           return null;
247         }
248         return new java.lang.Float(target.getOrder());
249       }
250
251       public void setValue(java.lang.Object object, java.lang.Object value)
252               throws IllegalStateException, IllegalArgumentException
253       {
254         try
255         {
256           Setting target = (Setting) object;
257           // if null, use delete method for optional primitives
258           if (value == null)
259           {
260             target.deleteOrder();
261             return;
262           }
263           target.setOrder(((java.lang.Float) value).floatValue());
264         } catch (java.lang.Exception ex)
265         {
266           throw new IllegalStateException(ex.toString());
267         }
268       }
269
270       public java.lang.Object newInstance(java.lang.Object parent)
271       {
272         return null;
273       }
274     };
275     desc.setHandler(handler);
276     desc.setMultivalued(false);
277     addFieldDescriptor(desc);
278
279     // -- validation code for: _order
280     fieldValidator = new org.exolab.castor.xml.FieldValidator();
281     { // -- local scope
282       org.exolab.castor.xml.validators.FloatValidator typeValidator;
283       typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
284       fieldValidator.setValidator(typeValidator);
285       typeValidator.setMinInclusive((float) -3.4028235E38);
286       typeValidator.setMaxInclusive((float) 3.4028235E38);
287     }
288     desc.setValidator(fieldValidator);
289     // -- _mincolour
290     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
291             java.lang.Integer.TYPE, "_mincolour", "mincolour",
292             org.exolab.castor.xml.NodeType.Attribute);
293     handler = new org.exolab.castor.xml.XMLFieldHandler()
294     {
295       public java.lang.Object getValue(java.lang.Object object)
296               throws IllegalStateException
297       {
298         Setting target = (Setting) object;
299         if (!target.hasMincolour())
300         {
301           return null;
302         }
303         return new java.lang.Integer(target.getMincolour());
304       }
305
306       public void setValue(java.lang.Object object, java.lang.Object value)
307               throws IllegalStateException, IllegalArgumentException
308       {
309         try
310         {
311           Setting target = (Setting) object;
312           // if null, use delete method for optional primitives
313           if (value == null)
314           {
315             target.deleteMincolour();
316             return;
317           }
318           target.setMincolour(((java.lang.Integer) value).intValue());
319         } catch (java.lang.Exception ex)
320         {
321           throw new IllegalStateException(ex.toString());
322         }
323       }
324
325       public java.lang.Object newInstance(java.lang.Object parent)
326       {
327         return null;
328       }
329     };
330     desc.setHandler(handler);
331     desc.setMultivalued(false);
332     addFieldDescriptor(desc);
333
334     // -- validation code for: _mincolour
335     fieldValidator = new org.exolab.castor.xml.FieldValidator();
336     { // -- local scope
337       org.exolab.castor.xml.validators.IntValidator typeValidator;
338       typeValidator = new org.exolab.castor.xml.validators.IntValidator();
339       fieldValidator.setValidator(typeValidator);
340       typeValidator.setMinInclusive(-2147483648);
341       typeValidator.setMaxInclusive(2147483647);
342     }
343     desc.setValidator(fieldValidator);
344     // -- _threshold
345     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
346             java.lang.Float.TYPE, "_threshold", "threshold",
347             org.exolab.castor.xml.NodeType.Attribute);
348     handler = new org.exolab.castor.xml.XMLFieldHandler()
349     {
350       public java.lang.Object getValue(java.lang.Object object)
351               throws IllegalStateException
352       {
353         Setting target = (Setting) object;
354         if (!target.hasThreshold())
355         {
356           return null;
357         }
358         return new java.lang.Float(target.getThreshold());
359       }
360
361       public void setValue(java.lang.Object object, java.lang.Object value)
362               throws IllegalStateException, IllegalArgumentException
363       {
364         try
365         {
366           Setting target = (Setting) object;
367           // if null, use delete method for optional primitives
368           if (value == null)
369           {
370             target.deleteThreshold();
371             return;
372           }
373           target.setThreshold(((java.lang.Float) value).floatValue());
374         } catch (java.lang.Exception ex)
375         {
376           throw new IllegalStateException(ex.toString());
377         }
378       }
379
380       public java.lang.Object newInstance(java.lang.Object parent)
381       {
382         return null;
383       }
384     };
385     desc.setHandler(handler);
386     desc.setMultivalued(false);
387     addFieldDescriptor(desc);
388
389     // -- validation code for: _threshold
390     fieldValidator = new org.exolab.castor.xml.FieldValidator();
391     { // -- local scope
392       org.exolab.castor.xml.validators.FloatValidator typeValidator;
393       typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
394       fieldValidator.setValidator(typeValidator);
395       typeValidator.setMinInclusive((float) -3.4028235E38);
396       typeValidator.setMaxInclusive((float) 3.4028235E38);
397     }
398     desc.setValidator(fieldValidator);
399     // -- _threshstate
400     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
401             java.lang.Integer.TYPE, "_threshstate", "threshstate",
402             org.exolab.castor.xml.NodeType.Attribute);
403     handler = new org.exolab.castor.xml.XMLFieldHandler()
404     {
405       public java.lang.Object getValue(java.lang.Object object)
406               throws IllegalStateException
407       {
408         Setting target = (Setting) object;
409         if (!target.hasThreshstate())
410         {
411           return null;
412         }
413         return new java.lang.Integer(target.getThreshstate());
414       }
415
416       public void setValue(java.lang.Object object, java.lang.Object value)
417               throws IllegalStateException, IllegalArgumentException
418       {
419         try
420         {
421           Setting target = (Setting) object;
422           // if null, use delete method for optional primitives
423           if (value == null)
424           {
425             target.deleteThreshstate();
426             return;
427           }
428           target.setThreshstate(((java.lang.Integer) value).intValue());
429         } catch (java.lang.Exception ex)
430         {
431           throw new IllegalStateException(ex.toString());
432         }
433       }
434
435       public java.lang.Object newInstance(java.lang.Object parent)
436       {
437         return null;
438       }
439     };
440     desc.setHandler(handler);
441     desc.setMultivalued(false);
442     addFieldDescriptor(desc);
443
444     // -- validation code for: _threshstate
445     fieldValidator = new org.exolab.castor.xml.FieldValidator();
446     { // -- local scope
447       org.exolab.castor.xml.validators.IntValidator typeValidator;
448       typeValidator = new org.exolab.castor.xml.validators.IntValidator();
449       fieldValidator.setValidator(typeValidator);
450       typeValidator.setMinInclusive(-2147483648);
451       typeValidator.setMaxInclusive(2147483647);
452     }
453     desc.setValidator(fieldValidator);
454     // -- _max
455     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
456             java.lang.Float.TYPE, "_max", "max",
457             org.exolab.castor.xml.NodeType.Attribute);
458     handler = new org.exolab.castor.xml.XMLFieldHandler()
459     {
460       public java.lang.Object getValue(java.lang.Object object)
461               throws IllegalStateException
462       {
463         Setting target = (Setting) object;
464         if (!target.hasMax())
465         {
466           return null;
467         }
468         return new java.lang.Float(target.getMax());
469       }
470
471       public void setValue(java.lang.Object object, java.lang.Object value)
472               throws IllegalStateException, IllegalArgumentException
473       {
474         try
475         {
476           Setting target = (Setting) object;
477           // if null, use delete method for optional primitives
478           if (value == null)
479           {
480             target.deleteMax();
481             return;
482           }
483           target.setMax(((java.lang.Float) value).floatValue());
484         } catch (java.lang.Exception ex)
485         {
486           throw new IllegalStateException(ex.toString());
487         }
488       }
489
490       public java.lang.Object newInstance(java.lang.Object parent)
491       {
492         return null;
493       }
494     };
495     desc.setHandler(handler);
496     desc.setMultivalued(false);
497     addFieldDescriptor(desc);
498
499     // -- validation code for: _max
500     fieldValidator = new org.exolab.castor.xml.FieldValidator();
501     { // -- local scope
502       org.exolab.castor.xml.validators.FloatValidator typeValidator;
503       typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
504       fieldValidator.setValidator(typeValidator);
505       typeValidator.setMinInclusive((float) -3.4028235E38);
506       typeValidator.setMaxInclusive((float) 3.4028235E38);
507     }
508     desc.setValidator(fieldValidator);
509     // -- _min
510     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
511             java.lang.Float.TYPE, "_min", "min",
512             org.exolab.castor.xml.NodeType.Attribute);
513     handler = new org.exolab.castor.xml.XMLFieldHandler()
514     {
515       public java.lang.Object getValue(java.lang.Object object)
516               throws IllegalStateException
517       {
518         Setting target = (Setting) object;
519         if (!target.hasMin())
520         {
521           return null;
522         }
523         return new java.lang.Float(target.getMin());
524       }
525
526       public void setValue(java.lang.Object object, java.lang.Object value)
527               throws IllegalStateException, IllegalArgumentException
528       {
529         try
530         {
531           Setting target = (Setting) object;
532           // if null, use delete method for optional primitives
533           if (value == null)
534           {
535             target.deleteMin();
536             return;
537           }
538           target.setMin(((java.lang.Float) value).floatValue());
539         } catch (java.lang.Exception ex)
540         {
541           throw new IllegalStateException(ex.toString());
542         }
543       }
544
545       public java.lang.Object newInstance(java.lang.Object parent)
546       {
547         return null;
548       }
549     };
550     desc.setHandler(handler);
551     desc.setMultivalued(false);
552     addFieldDescriptor(desc);
553
554     // -- validation code for: _min
555     fieldValidator = new org.exolab.castor.xml.FieldValidator();
556     { // -- local scope
557       org.exolab.castor.xml.validators.FloatValidator typeValidator;
558       typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
559       fieldValidator.setValidator(typeValidator);
560       typeValidator.setMinInclusive((float) -3.4028235E38);
561       typeValidator.setMaxInclusive((float) 3.4028235E38);
562     }
563     desc.setValidator(fieldValidator);
564     // -- _colourByLabel
565     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
566             java.lang.Boolean.TYPE, "_colourByLabel", "colourByLabel",
567             org.exolab.castor.xml.NodeType.Attribute);
568     handler = new org.exolab.castor.xml.XMLFieldHandler()
569     {
570       public java.lang.Object getValue(java.lang.Object object)
571               throws IllegalStateException
572       {
573         Setting target = (Setting) object;
574         if (!target.hasColourByLabel())
575         {
576           return null;
577         }
578         return (target.getColourByLabel() ? java.lang.Boolean.TRUE
579                 : java.lang.Boolean.FALSE);
580       }
581
582       public void setValue(java.lang.Object object, java.lang.Object value)
583               throws IllegalStateException, IllegalArgumentException
584       {
585         try
586         {
587           Setting target = (Setting) object;
588           // if null, use delete method for optional primitives
589           if (value == null)
590           {
591             target.deleteColourByLabel();
592             return;
593           }
594           target.setColourByLabel(((java.lang.Boolean) value)
595                   .booleanValue());
596         } catch (java.lang.Exception ex)
597         {
598           throw new IllegalStateException(ex.toString());
599         }
600       }
601
602       public java.lang.Object newInstance(java.lang.Object parent)
603       {
604         return null;
605       }
606     };
607     desc.setHandler(handler);
608     desc.setMultivalued(false);
609     addFieldDescriptor(desc);
610
611     // -- validation code for: _colourByLabel
612     fieldValidator = new org.exolab.castor.xml.FieldValidator();
613     { // -- local scope
614       org.exolab.castor.xml.validators.BooleanValidator typeValidator;
615       typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
616       fieldValidator.setValidator(typeValidator);
617     }
618     desc.setValidator(fieldValidator);
619     // -- _autoScale
620     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
621             java.lang.Boolean.TYPE, "_autoScale", "autoScale",
622             org.exolab.castor.xml.NodeType.Attribute);
623     handler = new org.exolab.castor.xml.XMLFieldHandler()
624     {
625       public java.lang.Object getValue(java.lang.Object object)
626               throws IllegalStateException
627       {
628         Setting target = (Setting) object;
629         if (!target.hasAutoScale())
630         {
631           return null;
632         }
633         return (target.getAutoScale() ? java.lang.Boolean.TRUE
634                 : java.lang.Boolean.FALSE);
635       }
636
637       public void setValue(java.lang.Object object, java.lang.Object value)
638               throws IllegalStateException, IllegalArgumentException
639       {
640         try
641         {
642           Setting target = (Setting) object;
643           // if null, use delete method for optional primitives
644           if (value == null)
645           {
646             target.deleteAutoScale();
647             return;
648           }
649           target.setAutoScale(((java.lang.Boolean) value).booleanValue());
650         } catch (java.lang.Exception ex)
651         {
652           throw new IllegalStateException(ex.toString());
653         }
654       }
655
656       public java.lang.Object newInstance(java.lang.Object parent)
657       {
658         return null;
659       }
660     };
661     desc.setHandler(handler);
662     desc.setMultivalued(false);
663     addFieldDescriptor(desc);
664
665     // -- validation code for: _autoScale
666     fieldValidator = new org.exolab.castor.xml.FieldValidator();
667     { // -- local scope
668       org.exolab.castor.xml.validators.BooleanValidator typeValidator;
669       typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
670       fieldValidator.setValidator(typeValidator);
671     }
672     desc.setValidator(fieldValidator);
673     // -- initialize element descriptors
674
675   }
676
677   // -----------/
678   // - Methods -/
679   // -----------/
680
681   /**
682    * Method getAccessMode.
683    * 
684    * @return the access mode specified for this class.
685    */
686   public org.exolab.castor.mapping.AccessMode getAccessMode()
687   {
688     return null;
689   }
690
691   /**
692    * Method getIdentity.
693    * 
694    * @return the identity field, null if this class has no identity.
695    */
696   public org.exolab.castor.mapping.FieldDescriptor getIdentity()
697   {
698     return super.getIdentity();
699   }
700
701   /**
702    * Method getJavaClass.
703    * 
704    * @return the Java class represented by this descriptor.
705    */
706   public java.lang.Class getJavaClass()
707   {
708     return jalview.schemabinding.version2.Setting.class;
709   }
710
711   /**
712    * Method getNameSpacePrefix.
713    * 
714    * @return the namespace prefix to use when marshaling as XML.
715    */
716   public java.lang.String getNameSpacePrefix()
717   {
718     return _nsPrefix;
719   }
720
721   /**
722    * Method getNameSpaceURI.
723    * 
724    * @return the namespace URI used when marshaling and unmarshaling as XML.
725    */
726   public java.lang.String getNameSpaceURI()
727   {
728     return _nsURI;
729   }
730
731   /**
732    * Method getValidator.
733    * 
734    * @return a specific validator for the class described by this
735    *         ClassDescriptor.
736    */
737   public org.exolab.castor.xml.TypeValidator getValidator()
738   {
739     return this;
740   }
741
742   /**
743    * Method getXMLName.
744    * 
745    * @return the XML Name for the Class being described.
746    */
747   public java.lang.String getXMLName()
748   {
749     return _xmlName;
750   }
751
752   /**
753    * Method isElementDefinition.
754    * 
755    * @return true if XML schema definition of this Class is that of a global
756    *         element or element with anonymous type definition.
757    */
758   public boolean isElementDefinition()
759   {
760     return _elementDefinition;
761   }
762
763 }