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