99790567cc17accd90f6abec7790670118e43949
[jalview.git] / src / jalview / schemabinding / version2 / descriptors / StructureStateDescriptor.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.StructureState;
25
26 /**
27  * Class StructureStateDescriptor.
28  * 
29  * @version $Revision$ $Date$
30  */
31 public class StructureStateDescriptor 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 StructureStateDescriptor()
64   {
65     super();
66     _nsURI = "www.jalview.org";
67     _xmlName = "structureState";
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     // -- _content
73     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
74             java.lang.String.class, "_content", "PCDATA",
75             org.exolab.castor.xml.NodeType.Text);
76     desc.setImmutable(true);
77     handler = new org.exolab.castor.xml.XMLFieldHandler()
78     {
79       public java.lang.Object getValue(java.lang.Object object)
80               throws IllegalStateException
81       {
82         StructureState target = (StructureState) object;
83         return target.getContent();
84       }
85
86       public void setValue(java.lang.Object object, java.lang.Object value)
87               throws IllegalStateException, IllegalArgumentException
88       {
89         try
90         {
91           StructureState target = (StructureState) object;
92           target.setContent((java.lang.String) value);
93         } catch (java.lang.Exception ex)
94         {
95           throw new IllegalStateException(ex.toString());
96         }
97       }
98
99       public java.lang.Object newInstance(java.lang.Object parent)
100       {
101         return null;
102       }
103     };
104     desc.setHandler(handler);
105     addFieldDescriptor(desc);
106
107     // -- validation code for: _content
108     fieldValidator = new org.exolab.castor.xml.FieldValidator();
109     { // -- local scope
110       org.exolab.castor.xml.validators.StringValidator typeValidator;
111       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
112       fieldValidator.setValidator(typeValidator);
113       typeValidator.setWhiteSpace("preserve");
114     }
115     desc.setValidator(fieldValidator);
116     // -- initialize attribute descriptors
117
118     // -- _visible
119     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
120             java.lang.Boolean.TYPE, "_visible", "visible",
121             org.exolab.castor.xml.NodeType.Attribute);
122     handler = new org.exolab.castor.xml.XMLFieldHandler()
123     {
124       public java.lang.Object getValue(java.lang.Object object)
125               throws IllegalStateException
126       {
127         StructureState target = (StructureState) object;
128         if (!target.hasVisible())
129         {
130           return null;
131         }
132         return (target.getVisible() ? java.lang.Boolean.TRUE
133                 : java.lang.Boolean.FALSE);
134       }
135
136       public void setValue(java.lang.Object object, java.lang.Object value)
137               throws IllegalStateException, IllegalArgumentException
138       {
139         try
140         {
141           StructureState target = (StructureState) object;
142           // if null, use delete method for optional primitives
143           if (value == null)
144           {
145             target.deleteVisible();
146             return;
147           }
148           target.setVisible(((java.lang.Boolean) value).booleanValue());
149         } catch (java.lang.Exception ex)
150         {
151           throw new IllegalStateException(ex.toString());
152         }
153       }
154
155       public java.lang.Object newInstance(java.lang.Object parent)
156       {
157         return null;
158       }
159     };
160     desc.setHandler(handler);
161     desc.setMultivalued(false);
162     addFieldDescriptor(desc);
163
164     // -- validation code for: _visible
165     fieldValidator = new org.exolab.castor.xml.FieldValidator();
166     { // -- local scope
167       org.exolab.castor.xml.validators.BooleanValidator typeValidator;
168       typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
169       fieldValidator.setValidator(typeValidator);
170     }
171     desc.setValidator(fieldValidator);
172     // -- _viewId
173     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
174             java.lang.String.class, "_viewId", "viewId",
175             org.exolab.castor.xml.NodeType.Attribute);
176     desc.setImmutable(true);
177     handler = new org.exolab.castor.xml.XMLFieldHandler()
178     {
179       public java.lang.Object getValue(java.lang.Object object)
180               throws IllegalStateException
181       {
182         StructureState target = (StructureState) object;
183         return target.getViewId();
184       }
185
186       public void setValue(java.lang.Object object, java.lang.Object value)
187               throws IllegalStateException, IllegalArgumentException
188       {
189         try
190         {
191           StructureState target = (StructureState) object;
192           target.setViewId((java.lang.String) value);
193         } catch (java.lang.Exception ex)
194         {
195           throw new IllegalStateException(ex.toString());
196         }
197       }
198
199       public java.lang.Object newInstance(java.lang.Object parent)
200       {
201         return null;
202       }
203     };
204     desc.setHandler(handler);
205     desc.setMultivalued(false);
206     addFieldDescriptor(desc);
207
208     // -- validation code for: _viewId
209     fieldValidator = new org.exolab.castor.xml.FieldValidator();
210     { // -- local scope
211       org.exolab.castor.xml.validators.StringValidator typeValidator;
212       typeValidator = new org.exolab.castor.xml.validators.StringValidator();
213       fieldValidator.setValidator(typeValidator);
214       typeValidator.setWhiteSpace("preserve");
215     }
216     desc.setValidator(fieldValidator);
217     // -- _alignwithAlignPanel
218     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
219             java.lang.Boolean.TYPE, "_alignwithAlignPanel",
220             "alignwithAlignPanel", org.exolab.castor.xml.NodeType.Attribute);
221     handler = new org.exolab.castor.xml.XMLFieldHandler()
222     {
223       public java.lang.Object getValue(java.lang.Object object)
224               throws IllegalStateException
225       {
226         StructureState target = (StructureState) object;
227         if (!target.hasAlignwithAlignPanel())
228         {
229           return null;
230         }
231         return (target.getAlignwithAlignPanel() ? java.lang.Boolean.TRUE
232                 : java.lang.Boolean.FALSE);
233       }
234
235       public void setValue(java.lang.Object object, java.lang.Object value)
236               throws IllegalStateException, IllegalArgumentException
237       {
238         try
239         {
240           StructureState target = (StructureState) object;
241           // if null, use delete method for optional primitives
242           if (value == null)
243           {
244             target.deleteAlignwithAlignPanel();
245             return;
246           }
247           target.setAlignwithAlignPanel(((java.lang.Boolean) value)
248                   .booleanValue());
249         } catch (java.lang.Exception ex)
250         {
251           throw new IllegalStateException(ex.toString());
252         }
253       }
254
255       public java.lang.Object newInstance(java.lang.Object parent)
256       {
257         return null;
258       }
259     };
260     desc.setHandler(handler);
261     desc.setMultivalued(false);
262     addFieldDescriptor(desc);
263
264     // -- validation code for: _alignwithAlignPanel
265     fieldValidator = new org.exolab.castor.xml.FieldValidator();
266     { // -- local scope
267       org.exolab.castor.xml.validators.BooleanValidator typeValidator;
268       typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
269       fieldValidator.setValidator(typeValidator);
270     }
271     desc.setValidator(fieldValidator);
272     // -- _colourwithAlignPanel
273     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
274             java.lang.Boolean.TYPE, "_colourwithAlignPanel",
275             "colourwithAlignPanel",
276             org.exolab.castor.xml.NodeType.Attribute);
277     handler = new org.exolab.castor.xml.XMLFieldHandler()
278     {
279       public java.lang.Object getValue(java.lang.Object object)
280               throws IllegalStateException
281       {
282         StructureState target = (StructureState) object;
283         if (!target.hasColourwithAlignPanel())
284         {
285           return null;
286         }
287         return (target.getColourwithAlignPanel() ? java.lang.Boolean.TRUE
288                 : java.lang.Boolean.FALSE);
289       }
290
291       public void setValue(java.lang.Object object, java.lang.Object value)
292               throws IllegalStateException, IllegalArgumentException
293       {
294         try
295         {
296           StructureState target = (StructureState) object;
297           // if null, use delete method for optional primitives
298           if (value == null)
299           {
300             target.deleteColourwithAlignPanel();
301             return;
302           }
303           target.setColourwithAlignPanel(((java.lang.Boolean) value)
304                   .booleanValue());
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.setMultivalued(false);
318     addFieldDescriptor(desc);
319
320     // -- validation code for: _colourwithAlignPanel
321     fieldValidator = new org.exolab.castor.xml.FieldValidator();
322     { // -- local scope
323       org.exolab.castor.xml.validators.BooleanValidator typeValidator;
324       typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
325       fieldValidator.setValidator(typeValidator);
326     }
327     desc.setValidator(fieldValidator);
328     // -- _colourByJmol
329     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
330             java.lang.Boolean.TYPE, "_colourByJmol", "colourByJmol",
331             org.exolab.castor.xml.NodeType.Attribute);
332     handler = new org.exolab.castor.xml.XMLFieldHandler()
333     {
334       public java.lang.Object getValue(java.lang.Object object)
335               throws IllegalStateException
336       {
337         StructureState target = (StructureState) object;
338         if (!target.hasColourByJmol())
339         {
340           return null;
341         }
342         return (target.getColourByJmol() ? java.lang.Boolean.TRUE
343                 : java.lang.Boolean.FALSE);
344       }
345
346       public void setValue(java.lang.Object object, java.lang.Object value)
347               throws IllegalStateException, IllegalArgumentException
348       {
349         try
350         {
351           StructureState target = (StructureState) object;
352           // if null, use delete method for optional primitives
353           if (value == null)
354           {
355             target.deleteColourByJmol();
356             return;
357           }
358           target.setColourByJmol(((java.lang.Boolean) value).booleanValue());
359         } catch (java.lang.Exception ex)
360         {
361           throw new IllegalStateException(ex.toString());
362         }
363       }
364
365       public java.lang.Object newInstance(java.lang.Object parent)
366       {
367         return null;
368       }
369     };
370     desc.setHandler(handler);
371     desc.setMultivalued(false);
372     addFieldDescriptor(desc);
373
374     // -- validation code for: _colourByJmol
375     fieldValidator = new org.exolab.castor.xml.FieldValidator();
376     { // -- local scope
377       org.exolab.castor.xml.validators.BooleanValidator typeValidator;
378       typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
379       fieldValidator.setValidator(typeValidator);
380     }
381     desc.setValidator(fieldValidator);
382     // -- _width
383     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
384             java.lang.Integer.TYPE, "_width", "width",
385             org.exolab.castor.xml.NodeType.Attribute);
386     handler = new org.exolab.castor.xml.XMLFieldHandler()
387     {
388       public java.lang.Object getValue(java.lang.Object object)
389               throws IllegalStateException
390       {
391         StructureState target = (StructureState) object;
392         if (!target.hasWidth())
393         {
394           return null;
395         }
396         return new java.lang.Integer(target.getWidth());
397       }
398
399       public void setValue(java.lang.Object object, java.lang.Object value)
400               throws IllegalStateException, IllegalArgumentException
401       {
402         try
403         {
404           StructureState target = (StructureState) object;
405           // if null, use delete method for optional primitives
406           if (value == null)
407           {
408             target.deleteWidth();
409             return;
410           }
411           target.setWidth(((java.lang.Integer) value).intValue());
412         } catch (java.lang.Exception ex)
413         {
414           throw new IllegalStateException(ex.toString());
415         }
416       }
417
418       public java.lang.Object newInstance(java.lang.Object parent)
419       {
420         return null;
421       }
422     };
423     desc.setHandler(handler);
424     desc.setMultivalued(false);
425     addFieldDescriptor(desc);
426
427     // -- validation code for: _width
428     fieldValidator = new org.exolab.castor.xml.FieldValidator();
429     { // -- local scope
430       org.exolab.castor.xml.validators.IntValidator typeValidator;
431       typeValidator = new org.exolab.castor.xml.validators.IntValidator();
432       fieldValidator.setValidator(typeValidator);
433       typeValidator.setMinInclusive(-2147483648);
434       typeValidator.setMaxInclusive(2147483647);
435     }
436     desc.setValidator(fieldValidator);
437     // -- _height
438     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
439             java.lang.Integer.TYPE, "_height", "height",
440             org.exolab.castor.xml.NodeType.Attribute);
441     handler = new org.exolab.castor.xml.XMLFieldHandler()
442     {
443       public java.lang.Object getValue(java.lang.Object object)
444               throws IllegalStateException
445       {
446         StructureState target = (StructureState) object;
447         if (!target.hasHeight())
448         {
449           return null;
450         }
451         return new java.lang.Integer(target.getHeight());
452       }
453
454       public void setValue(java.lang.Object object, java.lang.Object value)
455               throws IllegalStateException, IllegalArgumentException
456       {
457         try
458         {
459           StructureState target = (StructureState) object;
460           // if null, use delete method for optional primitives
461           if (value == null)
462           {
463             target.deleteHeight();
464             return;
465           }
466           target.setHeight(((java.lang.Integer) value).intValue());
467         } catch (java.lang.Exception ex)
468         {
469           throw new IllegalStateException(ex.toString());
470         }
471       }
472
473       public java.lang.Object newInstance(java.lang.Object parent)
474       {
475         return null;
476       }
477     };
478     desc.setHandler(handler);
479     desc.setMultivalued(false);
480     addFieldDescriptor(desc);
481
482     // -- validation code for: _height
483     fieldValidator = new org.exolab.castor.xml.FieldValidator();
484     { // -- local scope
485       org.exolab.castor.xml.validators.IntValidator typeValidator;
486       typeValidator = new org.exolab.castor.xml.validators.IntValidator();
487       fieldValidator.setValidator(typeValidator);
488       typeValidator.setMinInclusive(-2147483648);
489       typeValidator.setMaxInclusive(2147483647);
490     }
491     desc.setValidator(fieldValidator);
492     // -- _xpos
493     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
494             java.lang.Integer.TYPE, "_xpos", "xpos",
495             org.exolab.castor.xml.NodeType.Attribute);
496     handler = new org.exolab.castor.xml.XMLFieldHandler()
497     {
498       public java.lang.Object getValue(java.lang.Object object)
499               throws IllegalStateException
500       {
501         StructureState target = (StructureState) object;
502         if (!target.hasXpos())
503         {
504           return null;
505         }
506         return new java.lang.Integer(target.getXpos());
507       }
508
509       public void setValue(java.lang.Object object, java.lang.Object value)
510               throws IllegalStateException, IllegalArgumentException
511       {
512         try
513         {
514           StructureState target = (StructureState) object;
515           // if null, use delete method for optional primitives
516           if (value == null)
517           {
518             target.deleteXpos();
519             return;
520           }
521           target.setXpos(((java.lang.Integer) value).intValue());
522         } catch (java.lang.Exception ex)
523         {
524           throw new IllegalStateException(ex.toString());
525         }
526       }
527
528       public java.lang.Object newInstance(java.lang.Object parent)
529       {
530         return null;
531       }
532     };
533     desc.setHandler(handler);
534     desc.setMultivalued(false);
535     addFieldDescriptor(desc);
536
537     // -- validation code for: _xpos
538     fieldValidator = new org.exolab.castor.xml.FieldValidator();
539     { // -- local scope
540       org.exolab.castor.xml.validators.IntValidator typeValidator;
541       typeValidator = new org.exolab.castor.xml.validators.IntValidator();
542       fieldValidator.setValidator(typeValidator);
543       typeValidator.setMinInclusive(-2147483648);
544       typeValidator.setMaxInclusive(2147483647);
545     }
546     desc.setValidator(fieldValidator);
547     // -- _ypos
548     desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
549             java.lang.Integer.TYPE, "_ypos", "ypos",
550             org.exolab.castor.xml.NodeType.Attribute);
551     handler = new org.exolab.castor.xml.XMLFieldHandler()
552     {
553       public java.lang.Object getValue(java.lang.Object object)
554               throws IllegalStateException
555       {
556         StructureState target = (StructureState) object;
557         if (!target.hasYpos())
558         {
559           return null;
560         }
561         return new java.lang.Integer(target.getYpos());
562       }
563
564       public void setValue(java.lang.Object object, java.lang.Object value)
565               throws IllegalStateException, IllegalArgumentException
566       {
567         try
568         {
569           StructureState target = (StructureState) object;
570           // if null, use delete method for optional primitives
571           if (value == null)
572           {
573             target.deleteYpos();
574             return;
575           }
576           target.setYpos(((java.lang.Integer) value).intValue());
577         } catch (java.lang.Exception ex)
578         {
579           throw new IllegalStateException(ex.toString());
580         }
581       }
582
583       public java.lang.Object newInstance(java.lang.Object parent)
584       {
585         return null;
586       }
587     };
588     desc.setHandler(handler);
589     desc.setMultivalued(false);
590     addFieldDescriptor(desc);
591
592     // -- validation code for: _ypos
593     fieldValidator = new org.exolab.castor.xml.FieldValidator();
594     { // -- local scope
595       org.exolab.castor.xml.validators.IntValidator typeValidator;
596       typeValidator = new org.exolab.castor.xml.validators.IntValidator();
597       fieldValidator.setValidator(typeValidator);
598       typeValidator.setMinInclusive(-2147483648);
599       typeValidator.setMaxInclusive(2147483647);
600     }
601     desc.setValidator(fieldValidator);
602     // -- initialize element descriptors
603
604   }
605
606   // -----------/
607   // - Methods -/
608   // -----------/
609
610   /**
611    * Method getAccessMode.
612    * 
613    * @return the access mode specified for this class.
614    */
615   public org.exolab.castor.mapping.AccessMode getAccessMode()
616   {
617     return null;
618   }
619
620   /**
621    * Method getIdentity.
622    * 
623    * @return the identity field, null if this class has no identity.
624    */
625   public org.exolab.castor.mapping.FieldDescriptor getIdentity()
626   {
627     return super.getIdentity();
628   }
629
630   /**
631    * Method getJavaClass.
632    * 
633    * @return the Java class represented by this descriptor.
634    */
635   public java.lang.Class getJavaClass()
636   {
637     return jalview.schemabinding.version2.StructureState.class;
638   }
639
640   /**
641    * Method getNameSpacePrefix.
642    * 
643    * @return the namespace prefix to use when marshaling as XML.
644    */
645   public java.lang.String getNameSpacePrefix()
646   {
647     return _nsPrefix;
648   }
649
650   /**
651    * Method getNameSpaceURI.
652    * 
653    * @return the namespace URI used when marshaling and unmarshaling as XML.
654    */
655   public java.lang.String getNameSpaceURI()
656   {
657     return _nsURI;
658   }
659
660   /**
661    * Method getValidator.
662    * 
663    * @return a specific validator for the class described by this
664    *         ClassDescriptor.
665    */
666   public org.exolab.castor.xml.TypeValidator getValidator()
667   {
668     return this;
669   }
670
671   /**
672    * Method getXMLName.
673    * 
674    * @return the XML Name for the Class being described.
675    */
676   public java.lang.String getXMLName()
677   {
678     return _xmlName;
679   }
680
681   /**
682    * Method isElementDefinition.
683    * 
684    * @return true if XML schema definition of this Class is that of a global
685    *         element or element with anonymous type definition.
686    */
687   public boolean isElementDefinition()
688   {
689     return _elementDefinition;
690   }
691
692 }