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