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