2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
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
10 * of the License, or (at your option) any later version.
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.
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.
21 package jalview.schemabinding.version2.descriptors;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import jalview.schemabinding.version2.AnnotationElement;
30 * Class AnnotationElementDescriptor.
32 * @version $Revision$ $Date$
34 public class AnnotationElementDescriptor extends
35 org.exolab.castor.xml.util.XMLClassDescriptorImpl
38 // --------------------------/
39 // - Class/Member Variables -/
40 // --------------------------/
43 * Field _elementDefinition.
45 private boolean _elementDefinition;
50 private java.lang.String _nsPrefix;
55 private java.lang.String _nsURI;
60 private java.lang.String _xmlName;
66 public AnnotationElementDescriptor()
69 _nsURI = "www.vamsas.ac.uk/jalview/version2";
70 _xmlName = "annotationElement";
71 _elementDefinition = true;
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
81 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
82 java.lang.Integer.TYPE, "_position", "position",
83 org.exolab.castor.xml.NodeType.Attribute);
84 handler = new org.exolab.castor.xml.XMLFieldHandler()
86 public java.lang.Object getValue(java.lang.Object object)
87 throws IllegalStateException
89 AnnotationElement target = (AnnotationElement) object;
90 if (!target.hasPosition())
94 return new java.lang.Integer(target.getPosition());
97 public void setValue(java.lang.Object object, java.lang.Object value)
98 throws IllegalStateException, IllegalArgumentException
102 AnnotationElement target = (AnnotationElement) object;
103 // ignore null values for non optional primitives
109 target.setPosition(((java.lang.Integer) value).intValue());
110 } catch (java.lang.Exception ex)
112 throw new IllegalStateException(ex.toString());
116 public java.lang.Object newInstance(java.lang.Object parent)
121 desc.setHandler(handler);
122 desc.setRequired(true);
123 desc.setMultivalued(false);
124 addFieldDescriptor(desc);
126 // -- validation code for: _position
127 fieldValidator = new org.exolab.castor.xml.FieldValidator();
128 fieldValidator.setMinOccurs(1);
130 org.exolab.castor.xml.validators.IntValidator typeValidator;
131 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
132 fieldValidator.setValidator(typeValidator);
133 typeValidator.setMinInclusive(-2147483648);
134 typeValidator.setMaxInclusive(2147483647);
136 desc.setValidator(fieldValidator);
138 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
139 java.lang.Integer.TYPE, "_colour", "colour",
140 org.exolab.castor.xml.NodeType.Attribute);
141 handler = new org.exolab.castor.xml.XMLFieldHandler()
143 public java.lang.Object getValue(java.lang.Object object)
144 throws IllegalStateException
146 AnnotationElement target = (AnnotationElement) object;
147 if (!target.hasColour())
151 return new java.lang.Integer(target.getColour());
154 public void setValue(java.lang.Object object, java.lang.Object value)
155 throws IllegalStateException, IllegalArgumentException
159 AnnotationElement target = (AnnotationElement) object;
160 // if null, use delete method for optional primitives
163 target.deleteColour();
166 target.setColour(((java.lang.Integer) value).intValue());
167 } catch (java.lang.Exception ex)
169 throw new IllegalStateException(ex.toString());
173 public java.lang.Object newInstance(java.lang.Object parent)
178 desc.setHandler(handler);
179 desc.setMultivalued(false);
180 addFieldDescriptor(desc);
182 // -- validation code for: _colour
183 fieldValidator = new org.exolab.castor.xml.FieldValidator();
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);
191 desc.setValidator(fieldValidator);
192 // -- initialize element descriptors
194 // -- _displayCharacter
195 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
196 java.lang.String.class, "_displayCharacter",
197 "displayCharacter", org.exolab.castor.xml.NodeType.Element);
198 desc.setImmutable(true);
199 handler = new org.exolab.castor.xml.XMLFieldHandler()
201 public java.lang.Object getValue(java.lang.Object object)
202 throws IllegalStateException
204 AnnotationElement target = (AnnotationElement) object;
205 return target.getDisplayCharacter();
208 public void setValue(java.lang.Object object, java.lang.Object value)
209 throws IllegalStateException, IllegalArgumentException
213 AnnotationElement target = (AnnotationElement) object;
214 target.setDisplayCharacter((java.lang.String) value);
215 } catch (java.lang.Exception ex)
217 throw new IllegalStateException(ex.toString());
221 public java.lang.Object newInstance(java.lang.Object parent)
226 desc.setHandler(handler);
227 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
228 desc.setMultivalued(false);
229 addFieldDescriptor(desc);
231 // -- validation code for: _displayCharacter
232 fieldValidator = new org.exolab.castor.xml.FieldValidator();
234 org.exolab.castor.xml.validators.StringValidator typeValidator;
235 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
236 fieldValidator.setValidator(typeValidator);
237 typeValidator.setWhiteSpace("preserve");
239 desc.setValidator(fieldValidator);
241 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
242 java.lang.String.class, "_description", "description",
243 org.exolab.castor.xml.NodeType.Element);
244 desc.setImmutable(true);
245 handler = new org.exolab.castor.xml.XMLFieldHandler()
247 public java.lang.Object getValue(java.lang.Object object)
248 throws IllegalStateException
250 AnnotationElement target = (AnnotationElement) object;
251 return target.getDescription();
254 public void setValue(java.lang.Object object, java.lang.Object value)
255 throws IllegalStateException, IllegalArgumentException
259 AnnotationElement target = (AnnotationElement) object;
260 target.setDescription((java.lang.String) value);
261 } catch (java.lang.Exception ex)
263 throw new IllegalStateException(ex.toString());
267 public java.lang.Object newInstance(java.lang.Object parent)
272 desc.setHandler(handler);
273 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
274 desc.setMultivalued(false);
275 addFieldDescriptor(desc);
277 // -- validation code for: _description
278 fieldValidator = new org.exolab.castor.xml.FieldValidator();
280 org.exolab.castor.xml.validators.StringValidator typeValidator;
281 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
282 fieldValidator.setValidator(typeValidator);
283 typeValidator.setWhiteSpace("preserve");
285 desc.setValidator(fieldValidator);
286 // -- _secondaryStructure
287 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
288 java.lang.String.class, "_secondaryStructure",
289 "secondaryStructure", org.exolab.castor.xml.NodeType.Element);
290 desc.setImmutable(true);
291 handler = new org.exolab.castor.xml.XMLFieldHandler()
293 public java.lang.Object getValue(java.lang.Object object)
294 throws IllegalStateException
296 AnnotationElement target = (AnnotationElement) object;
297 return target.getSecondaryStructure();
300 public void setValue(java.lang.Object object, java.lang.Object value)
301 throws IllegalStateException, IllegalArgumentException
305 AnnotationElement target = (AnnotationElement) object;
306 target.setSecondaryStructure((java.lang.String) value);
307 } catch (java.lang.Exception ex)
309 throw new IllegalStateException(ex.toString());
313 public java.lang.Object newInstance(java.lang.Object parent)
318 desc.setHandler(handler);
319 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
320 desc.setMultivalued(false);
321 addFieldDescriptor(desc);
323 // -- validation code for: _secondaryStructure
324 fieldValidator = new org.exolab.castor.xml.FieldValidator();
326 org.exolab.castor.xml.validators.StringValidator typeValidator;
327 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
328 fieldValidator.setValidator(typeValidator);
329 typeValidator.setWhiteSpace("preserve");
330 typeValidator.setLength(1);
332 desc.setValidator(fieldValidator);
334 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
335 java.lang.Float.TYPE, "_value", "value",
336 org.exolab.castor.xml.NodeType.Element);
337 handler = new org.exolab.castor.xml.XMLFieldHandler()
339 public java.lang.Object getValue(java.lang.Object object)
340 throws IllegalStateException
342 AnnotationElement target = (AnnotationElement) object;
343 if (!target.hasValue())
347 return new java.lang.Float(target.getValue());
350 public void setValue(java.lang.Object object, java.lang.Object value)
351 throws IllegalStateException, IllegalArgumentException
355 AnnotationElement target = (AnnotationElement) object;
356 // if null, use delete method for optional primitives
359 target.deleteValue();
362 target.setValue(((java.lang.Float) value).floatValue());
363 } catch (java.lang.Exception ex)
365 throw new IllegalStateException(ex.toString());
369 public java.lang.Object newInstance(java.lang.Object parent)
374 desc.setHandler(handler);
375 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
376 desc.setMultivalued(false);
377 addFieldDescriptor(desc);
379 // -- validation code for: _value
380 fieldValidator = new org.exolab.castor.xml.FieldValidator();
382 org.exolab.castor.xml.validators.FloatValidator typeValidator;
383 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
384 fieldValidator.setValidator(typeValidator);
385 typeValidator.setMinInclusive((float) -3.4028235E38);
386 typeValidator.setMaxInclusive((float) 3.4028235E38);
388 desc.setValidator(fieldValidator);
396 * Method getAccessMode.
398 * @return the access mode specified for this class.
400 public org.exolab.castor.mapping.AccessMode getAccessMode()
406 * Method getIdentity.
408 * @return the identity field, null if this class has no identity.
410 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
412 return super.getIdentity();
416 * Method getJavaClass.
418 * @return the Java class represented by this descriptor.
420 public java.lang.Class getJavaClass()
422 return jalview.schemabinding.version2.AnnotationElement.class;
426 * Method getNameSpacePrefix.
428 * @return the namespace prefix to use when marshaling as XML.
430 public java.lang.String getNameSpacePrefix()
436 * Method getNameSpaceURI.
438 * @return the namespace URI used when marshaling and unmarshaling as XML.
440 public java.lang.String getNameSpaceURI()
446 * Method getValidator.
448 * @return a specific validator for the class described by this
451 public org.exolab.castor.xml.TypeValidator getValidator()
459 * @return the XML Name for the Class being described.
461 public java.lang.String getXMLName()
467 * Method isElementDefinition.
469 * @return true if XML schema definition of this Class is that of a global
470 * element or element with anonymous type definition.
472 public boolean isElementDefinition()
474 return _elementDefinition;