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
5 * This file is part of Jalview.
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.
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.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.schemabinding.version2.descriptors;
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
24 import jalview.schemabinding.version2.JSeq;
27 * Class JSeqDescriptor.
29 * @version $Revision$ $Date$
31 public class JSeqDescriptor extends
32 org.exolab.castor.xml.util.XMLClassDescriptorImpl
35 // --------------------------/
36 // - Class/Member Variables -/
37 // --------------------------/
40 * Field _elementDefinition.
42 private boolean _elementDefinition;
47 private java.lang.String _nsPrefix;
52 private java.lang.String _nsURI;
57 private java.lang.String _xmlName;
63 public JSeqDescriptor()
66 _nsURI = "www.jalview.org";
68 _elementDefinition = true;
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
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()
83 public java.lang.Object getValue(java.lang.Object object)
84 throws IllegalStateException
86 JSeq target = (JSeq) object;
87 if (!target.hasColour())
91 return new java.lang.Integer(target.getColour());
94 public void setValue(java.lang.Object object, java.lang.Object value)
95 throws IllegalStateException, IllegalArgumentException
99 JSeq target = (JSeq) object;
100 // if null, use delete method for optional primitives
103 target.deleteColour();
106 target.setColour(((java.lang.Integer) value).intValue());
107 } catch (java.lang.Exception ex)
109 throw new IllegalStateException(ex.toString());
113 public java.lang.Object newInstance(java.lang.Object parent)
118 desc.setHandler(handler);
119 desc.setMultivalued(false);
120 addFieldDescriptor(desc);
122 // -- validation code for: _colour
123 fieldValidator = new org.exolab.castor.xml.FieldValidator();
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);
131 desc.setValidator(fieldValidator);
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()
138 public java.lang.Object getValue(java.lang.Object object)
139 throws IllegalStateException
141 JSeq target = (JSeq) object;
142 if (!target.hasStart())
146 return new java.lang.Integer(target.getStart());
149 public void setValue(java.lang.Object object, java.lang.Object value)
150 throws IllegalStateException, IllegalArgumentException
154 JSeq target = (JSeq) object;
155 // ignore null values for non optional primitives
161 target.setStart(((java.lang.Integer) value).intValue());
162 } catch (java.lang.Exception ex)
164 throw new IllegalStateException(ex.toString());
168 public java.lang.Object newInstance(java.lang.Object parent)
173 desc.setHandler(handler);
174 desc.setRequired(true);
175 desc.setMultivalued(false);
176 addFieldDescriptor(desc);
178 // -- validation code for: _start
179 fieldValidator = new org.exolab.castor.xml.FieldValidator();
180 fieldValidator.setMinOccurs(1);
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);
188 desc.setValidator(fieldValidator);
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()
195 public java.lang.Object getValue(java.lang.Object object)
196 throws IllegalStateException
198 JSeq target = (JSeq) object;
199 if (!target.hasEnd())
203 return new java.lang.Integer(target.getEnd());
206 public void setValue(java.lang.Object object, java.lang.Object value)
207 throws IllegalStateException, IllegalArgumentException
211 JSeq target = (JSeq) object;
212 // ignore null values for non optional primitives
218 target.setEnd(((java.lang.Integer) value).intValue());
219 } catch (java.lang.Exception ex)
221 throw new IllegalStateException(ex.toString());
225 public java.lang.Object newInstance(java.lang.Object parent)
230 desc.setHandler(handler);
231 desc.setRequired(true);
232 desc.setMultivalued(false);
233 addFieldDescriptor(desc);
235 // -- validation code for: _end
236 fieldValidator = new org.exolab.castor.xml.FieldValidator();
237 fieldValidator.setMinOccurs(1);
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);
245 desc.setValidator(fieldValidator);
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()
253 public java.lang.Object getValue(java.lang.Object object)
254 throws IllegalStateException
256 JSeq target = (JSeq) object;
257 return target.getId();
260 public void setValue(java.lang.Object object, java.lang.Object value)
261 throws IllegalStateException, IllegalArgumentException
265 JSeq target = (JSeq) object;
266 target.setId((java.lang.String) value);
267 } catch (java.lang.Exception ex)
269 throw new IllegalStateException(ex.toString());
273 public java.lang.Object newInstance(java.lang.Object parent)
278 desc.setHandler(handler);
279 desc.setRequired(true);
280 desc.setMultivalued(false);
281 addFieldDescriptor(desc);
283 // -- validation code for: _id
284 fieldValidator = new org.exolab.castor.xml.FieldValidator();
285 fieldValidator.setMinOccurs(1);
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");
292 desc.setValidator(fieldValidator);
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()
299 public java.lang.Object getValue(java.lang.Object object)
300 throws IllegalStateException
302 JSeq target = (JSeq) object;
303 if (!target.hasHidden())
307 return (target.getHidden() ? java.lang.Boolean.TRUE
308 : java.lang.Boolean.FALSE);
311 public void setValue(java.lang.Object object, java.lang.Object value)
312 throws IllegalStateException, IllegalArgumentException
316 JSeq target = (JSeq) object;
317 // if null, use delete method for optional primitives
320 target.deleteHidden();
323 target.setHidden(((java.lang.Boolean) value).booleanValue());
324 } catch (java.lang.Exception ex)
326 throw new IllegalStateException(ex.toString());
330 public java.lang.Object newInstance(java.lang.Object parent)
335 desc.setHandler(handler);
336 desc.setMultivalued(false);
337 addFieldDescriptor(desc);
339 // -- validation code for: _hidden
340 fieldValidator = new org.exolab.castor.xml.FieldValidator();
342 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
343 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
344 fieldValidator.setValidator(typeValidator);
346 desc.setValidator(fieldValidator);
347 // -- initialize element descriptors
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()
355 public java.lang.Object getValue(java.lang.Object object)
356 throws IllegalStateException
358 JSeq target = (JSeq) object;
359 return target.getFeatures();
362 public void setValue(java.lang.Object object, java.lang.Object value)
363 throws IllegalStateException, IllegalArgumentException
367 JSeq target = (JSeq) object;
368 target.addFeatures((jalview.schemabinding.version2.Features) value);
369 } catch (java.lang.Exception ex)
371 throw new IllegalStateException(ex.toString());
375 public void resetValue(Object object) throws IllegalStateException,
376 IllegalArgumentException
380 JSeq target = (JSeq) object;
381 target.removeAllFeatures();
382 } catch (java.lang.Exception ex)
384 throw new IllegalStateException(ex.toString());
388 public java.lang.Object newInstance(java.lang.Object parent)
390 return new jalview.schemabinding.version2.Features();
393 desc.setHandler(handler);
394 desc.setNameSpaceURI("www.jalview.org");
395 desc.setMultivalued(true);
396 addFieldDescriptor(desc);
398 // -- validation code for: _featuresList
399 fieldValidator = new org.exolab.castor.xml.FieldValidator();
400 fieldValidator.setMinOccurs(0);
403 desc.setValidator(fieldValidator);
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()
410 public java.lang.Object getValue(java.lang.Object object)
411 throws IllegalStateException
413 JSeq target = (JSeq) object;
414 return target.getPdbids();
417 public void setValue(java.lang.Object object, java.lang.Object value)
418 throws IllegalStateException, IllegalArgumentException
422 JSeq target = (JSeq) object;
423 target.addPdbids((jalview.schemabinding.version2.Pdbids) value);
424 } catch (java.lang.Exception ex)
426 throw new IllegalStateException(ex.toString());
430 public void resetValue(Object object) throws IllegalStateException,
431 IllegalArgumentException
435 JSeq target = (JSeq) object;
436 target.removeAllPdbids();
437 } catch (java.lang.Exception ex)
439 throw new IllegalStateException(ex.toString());
443 public java.lang.Object newInstance(java.lang.Object parent)
445 return new jalview.schemabinding.version2.Pdbids();
448 desc.setHandler(handler);
449 desc.setNameSpaceURI("www.jalview.org");
450 desc.setMultivalued(true);
451 addFieldDescriptor(desc);
453 // -- validation code for: _pdbidsList
454 fieldValidator = new org.exolab.castor.xml.FieldValidator();
455 fieldValidator.setMinOccurs(0);
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()
465 public java.lang.Object getValue(java.lang.Object object)
466 throws IllegalStateException
468 JSeq target = (JSeq) object;
469 return target.getHiddenSequences();
472 public void setValue(java.lang.Object object, java.lang.Object value)
473 throws IllegalStateException, IllegalArgumentException
477 JSeq target = (JSeq) object;
478 // ignore null values for non optional primitives
484 target.addHiddenSequences(((java.lang.Integer) value).intValue());
485 } catch (java.lang.Exception ex)
487 throw new IllegalStateException(ex.toString());
491 public void resetValue(Object object) throws IllegalStateException,
492 IllegalArgumentException
496 JSeq target = (JSeq) object;
497 target.removeAllHiddenSequences();
498 } catch (java.lang.Exception ex)
500 throw new IllegalStateException(ex.toString());
504 public java.lang.Object newInstance(java.lang.Object parent)
509 desc.setHandler(handler);
510 desc.setNameSpaceURI("www.jalview.org");
511 desc.setMultivalued(true);
512 addFieldDescriptor(desc);
514 // -- validation code for: _hiddenSequencesList
515 fieldValidator = new org.exolab.castor.xml.FieldValidator();
516 fieldValidator.setMinOccurs(0);
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);
524 desc.setValidator(fieldValidator);
532 * Method getAccessMode.
534 * @return the access mode specified for this class.
536 public org.exolab.castor.mapping.AccessMode getAccessMode()
542 * Method getIdentity.
544 * @return the identity field, null if this class has no identity.
546 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
548 return super.getIdentity();
552 * Method getJavaClass.
554 * @return the Java class represented by this descriptor.
556 public java.lang.Class getJavaClass()
558 return jalview.schemabinding.version2.JSeq.class;
562 * Method getNameSpacePrefix.
564 * @return the namespace prefix to use when marshaling as XML.
566 public java.lang.String getNameSpacePrefix()
572 * Method getNameSpaceURI.
574 * @return the namespace URI used when marshaling and unmarshaling as XML.
576 public java.lang.String getNameSpaceURI()
582 * Method getValidator.
584 * @return a specific validator for the class described by this
587 public org.exolab.castor.xml.TypeValidator getValidator()
595 * @return the XML Name for the Class being described.
597 public java.lang.String getXMLName()
603 * Method isElementDefinition.
605 * @return true if XML schema definition of this Class is that of a global
606 * element or element with anonymous type definition.
608 public boolean isElementDefinition()
610 return _elementDefinition;