2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.schemabinding.version2.descriptors;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import jalview.schemabinding.version2.AnnotationElement;
28 * Class AnnotationElementDescriptor.
30 * @version $Revision$ $Date$
32 public class AnnotationElementDescriptor extends
33 org.exolab.castor.xml.util.XMLClassDescriptorImpl
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
41 * Field _elementDefinition.
43 private boolean _elementDefinition;
48 private java.lang.String _nsPrefix;
53 private java.lang.String _nsURI;
58 private java.lang.String _xmlName;
64 public AnnotationElementDescriptor()
67 _nsURI = "www.vamsas.ac.uk/jalview/version2";
68 _xmlName = "annotationElement";
69 _elementDefinition = true;
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
79 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
80 java.lang.Integer.TYPE, "_position", "position",
81 org.exolab.castor.xml.NodeType.Attribute);
82 handler = new org.exolab.castor.xml.XMLFieldHandler()
84 public java.lang.Object getValue(java.lang.Object object)
85 throws IllegalStateException
87 AnnotationElement target = (AnnotationElement) object;
88 if (!target.hasPosition())
92 return new java.lang.Integer(target.getPosition());
95 public void setValue(java.lang.Object object, java.lang.Object value)
96 throws IllegalStateException, IllegalArgumentException
100 AnnotationElement target = (AnnotationElement) object;
101 // ignore null values for non optional primitives
107 target.setPosition(((java.lang.Integer) value).intValue());
108 } catch (java.lang.Exception ex)
110 throw new IllegalStateException(ex.toString());
114 public java.lang.Object newInstance(java.lang.Object parent)
119 desc.setHandler(handler);
120 desc.setRequired(true);
121 desc.setMultivalued(false);
122 addFieldDescriptor(desc);
124 // -- validation code for: _position
125 fieldValidator = new org.exolab.castor.xml.FieldValidator();
126 fieldValidator.setMinOccurs(1);
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);
134 desc.setValidator(fieldValidator);
136 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
137 java.lang.Integer.TYPE, "_colour", "colour",
138 org.exolab.castor.xml.NodeType.Attribute);
139 handler = new org.exolab.castor.xml.XMLFieldHandler()
141 public java.lang.Object getValue(java.lang.Object object)
142 throws IllegalStateException
144 AnnotationElement target = (AnnotationElement) object;
145 if (!target.hasColour())
149 return new java.lang.Integer(target.getColour());
152 public void setValue(java.lang.Object object, java.lang.Object value)
153 throws IllegalStateException, IllegalArgumentException
157 AnnotationElement target = (AnnotationElement) object;
158 // if null, use delete method for optional primitives
161 target.deleteColour();
164 target.setColour(((java.lang.Integer) value).intValue());
165 } catch (java.lang.Exception ex)
167 throw new IllegalStateException(ex.toString());
171 public java.lang.Object newInstance(java.lang.Object parent)
176 desc.setHandler(handler);
177 desc.setMultivalued(false);
178 addFieldDescriptor(desc);
180 // -- validation code for: _colour
181 fieldValidator = new org.exolab.castor.xml.FieldValidator();
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);
189 desc.setValidator(fieldValidator);
190 // -- initialize element descriptors
192 // -- _displayCharacter
193 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
194 java.lang.String.class, "_displayCharacter",
195 "displayCharacter", org.exolab.castor.xml.NodeType.Element);
196 desc.setImmutable(true);
197 handler = new org.exolab.castor.xml.XMLFieldHandler()
199 public java.lang.Object getValue(java.lang.Object object)
200 throws IllegalStateException
202 AnnotationElement target = (AnnotationElement) object;
203 return target.getDisplayCharacter();
206 public void setValue(java.lang.Object object, java.lang.Object value)
207 throws IllegalStateException, IllegalArgumentException
211 AnnotationElement target = (AnnotationElement) object;
212 target.setDisplayCharacter((java.lang.String) value);
213 } catch (java.lang.Exception ex)
215 throw new IllegalStateException(ex.toString());
219 public java.lang.Object newInstance(java.lang.Object parent)
224 desc.setHandler(handler);
225 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
226 desc.setMultivalued(false);
227 addFieldDescriptor(desc);
229 // -- validation code for: _displayCharacter
230 fieldValidator = new org.exolab.castor.xml.FieldValidator();
232 org.exolab.castor.xml.validators.StringValidator typeValidator;
233 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
234 fieldValidator.setValidator(typeValidator);
235 typeValidator.setWhiteSpace("preserve");
237 desc.setValidator(fieldValidator);
239 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
240 java.lang.String.class, "_description", "description",
241 org.exolab.castor.xml.NodeType.Element);
242 desc.setImmutable(true);
243 handler = new org.exolab.castor.xml.XMLFieldHandler()
245 public java.lang.Object getValue(java.lang.Object object)
246 throws IllegalStateException
248 AnnotationElement target = (AnnotationElement) object;
249 return target.getDescription();
252 public void setValue(java.lang.Object object, java.lang.Object value)
253 throws IllegalStateException, IllegalArgumentException
257 AnnotationElement target = (AnnotationElement) object;
258 target.setDescription((java.lang.String) value);
259 } catch (java.lang.Exception ex)
261 throw new IllegalStateException(ex.toString());
265 public java.lang.Object newInstance(java.lang.Object parent)
270 desc.setHandler(handler);
271 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
272 desc.setMultivalued(false);
273 addFieldDescriptor(desc);
275 // -- validation code for: _description
276 fieldValidator = new org.exolab.castor.xml.FieldValidator();
278 org.exolab.castor.xml.validators.StringValidator typeValidator;
279 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
280 fieldValidator.setValidator(typeValidator);
281 typeValidator.setWhiteSpace("preserve");
283 desc.setValidator(fieldValidator);
284 // -- _secondaryStructure
285 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
286 java.lang.String.class, "_secondaryStructure",
287 "secondaryStructure", org.exolab.castor.xml.NodeType.Element);
288 desc.setImmutable(true);
289 handler = new org.exolab.castor.xml.XMLFieldHandler()
291 public java.lang.Object getValue(java.lang.Object object)
292 throws IllegalStateException
294 AnnotationElement target = (AnnotationElement) object;
295 return target.getSecondaryStructure();
298 public void setValue(java.lang.Object object, java.lang.Object value)
299 throws IllegalStateException, IllegalArgumentException
303 AnnotationElement target = (AnnotationElement) object;
304 target.setSecondaryStructure((java.lang.String) value);
305 } catch (java.lang.Exception ex)
307 throw new IllegalStateException(ex.toString());
311 public java.lang.Object newInstance(java.lang.Object parent)
316 desc.setHandler(handler);
317 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
318 desc.setMultivalued(false);
319 addFieldDescriptor(desc);
321 // -- validation code for: _secondaryStructure
322 fieldValidator = new org.exolab.castor.xml.FieldValidator();
324 org.exolab.castor.xml.validators.StringValidator typeValidator;
325 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
326 fieldValidator.setValidator(typeValidator);
327 typeValidator.setWhiteSpace("preserve");
328 typeValidator.setLength(1);
330 desc.setValidator(fieldValidator);
332 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
333 java.lang.Float.TYPE, "_value", "value",
334 org.exolab.castor.xml.NodeType.Element);
335 handler = new org.exolab.castor.xml.XMLFieldHandler()
337 public java.lang.Object getValue(java.lang.Object object)
338 throws IllegalStateException
340 AnnotationElement target = (AnnotationElement) object;
341 if (!target.hasValue())
345 return new java.lang.Float(target.getValue());
348 public void setValue(java.lang.Object object, java.lang.Object value)
349 throws IllegalStateException, IllegalArgumentException
353 AnnotationElement target = (AnnotationElement) object;
354 // if null, use delete method for optional primitives
357 target.deleteValue();
360 target.setValue(((java.lang.Float) value).floatValue());
361 } catch (java.lang.Exception ex)
363 throw new IllegalStateException(ex.toString());
367 public java.lang.Object newInstance(java.lang.Object parent)
372 desc.setHandler(handler);
373 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
374 desc.setMultivalued(false);
375 addFieldDescriptor(desc);
377 // -- validation code for: _value
378 fieldValidator = new org.exolab.castor.xml.FieldValidator();
380 org.exolab.castor.xml.validators.FloatValidator typeValidator;
381 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
382 fieldValidator.setValidator(typeValidator);
383 typeValidator.setMinInclusive((float) -3.4028235E38);
384 typeValidator.setMaxInclusive((float) 3.4028235E38);
386 desc.setValidator(fieldValidator);
394 * Method getAccessMode.
396 * @return the access mode specified for this class.
398 public org.exolab.castor.mapping.AccessMode getAccessMode()
404 * Method getIdentity.
406 * @return the identity field, null if this class has no identity.
408 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
410 return super.getIdentity();
414 * Method getJavaClass.
416 * @return the Java class represented by this descriptor.
418 public java.lang.Class getJavaClass()
420 return jalview.schemabinding.version2.AnnotationElement.class;
424 * Method getNameSpacePrefix.
426 * @return the namespace prefix to use when marshaling as XML.
428 public java.lang.String getNameSpacePrefix()
434 * Method getNameSpaceURI.
436 * @return the namespace URI used when marshaling and unmarshaling as XML.
438 public java.lang.String getNameSpaceURI()
444 * Method getValidator.
446 * @return a specific validator for the class described by this
449 public org.exolab.castor.xml.TypeValidator getValidator()
457 * @return the XML Name for the Class being described.
459 public java.lang.String getXMLName()
465 * Method isElementDefinition.
467 * @return true if XML schema definition of this Class is that of a global
468 * element or element with anonymous type definition.
470 public boolean isElementDefinition()
472 return _elementDefinition;