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