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.AnnotationElement;
27 * Class AnnotationElementDescriptor.
29 * @version $Revision$ $Date$
31 public class AnnotationElementDescriptor 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 AnnotationElementDescriptor()
66 _nsURI = "www.vamsas.ac.uk/jalview/version2";
67 _xmlName = "annotationElement";
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, "_position", "position",
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 AnnotationElement target = (AnnotationElement) object;
87 if (!target.hasPosition())
91 return new java.lang.Integer(target.getPosition());
94 public void setValue(java.lang.Object object, java.lang.Object value)
95 throws IllegalStateException, IllegalArgumentException
99 AnnotationElement target = (AnnotationElement) object;
100 // ignore null values for non optional primitives
106 target.setPosition(((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.setRequired(true);
120 desc.setMultivalued(false);
121 addFieldDescriptor(desc);
123 // -- validation code for: _position
124 fieldValidator = new org.exolab.castor.xml.FieldValidator();
125 fieldValidator.setMinOccurs(1);
127 org.exolab.castor.xml.validators.IntValidator typeValidator;
128 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
129 fieldValidator.setValidator(typeValidator);
130 typeValidator.setMinInclusive(-2147483648);
131 typeValidator.setMaxInclusive(2147483647);
133 desc.setValidator(fieldValidator);
135 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
136 java.lang.Integer.TYPE, "_colour", "colour",
137 org.exolab.castor.xml.NodeType.Attribute);
138 handler = new org.exolab.castor.xml.XMLFieldHandler()
140 public java.lang.Object getValue(java.lang.Object object)
141 throws IllegalStateException
143 AnnotationElement target = (AnnotationElement) object;
144 if (!target.hasColour())
148 return new java.lang.Integer(target.getColour());
151 public void setValue(java.lang.Object object, java.lang.Object value)
152 throws IllegalStateException, IllegalArgumentException
156 AnnotationElement target = (AnnotationElement) object;
157 // if null, use delete method for optional primitives
160 target.deleteColour();
163 target.setColour(((java.lang.Integer) value).intValue());
164 } catch (java.lang.Exception ex)
166 throw new IllegalStateException(ex.toString());
170 public java.lang.Object newInstance(java.lang.Object parent)
175 desc.setHandler(handler);
176 desc.setMultivalued(false);
177 addFieldDescriptor(desc);
179 // -- validation code for: _colour
180 fieldValidator = new org.exolab.castor.xml.FieldValidator();
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);
189 // -- initialize element descriptors
191 // -- _displayCharacter
192 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
193 java.lang.String.class, "_displayCharacter",
194 "displayCharacter", org.exolab.castor.xml.NodeType.Element);
195 desc.setImmutable(true);
196 handler = new org.exolab.castor.xml.XMLFieldHandler()
198 public java.lang.Object getValue(java.lang.Object object)
199 throws IllegalStateException
201 AnnotationElement target = (AnnotationElement) object;
202 return target.getDisplayCharacter();
205 public void setValue(java.lang.Object object, java.lang.Object value)
206 throws IllegalStateException, IllegalArgumentException
210 AnnotationElement target = (AnnotationElement) object;
211 target.setDisplayCharacter((java.lang.String) value);
212 } catch (java.lang.Exception ex)
214 throw new IllegalStateException(ex.toString());
218 public java.lang.Object newInstance(java.lang.Object parent)
223 desc.setHandler(handler);
224 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
225 desc.setMultivalued(false);
226 addFieldDescriptor(desc);
228 // -- validation code for: _displayCharacter
229 fieldValidator = new org.exolab.castor.xml.FieldValidator();
231 org.exolab.castor.xml.validators.StringValidator typeValidator;
232 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
233 fieldValidator.setValidator(typeValidator);
234 typeValidator.setWhiteSpace("preserve");
236 desc.setValidator(fieldValidator);
238 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
239 java.lang.String.class, "_description", "description",
240 org.exolab.castor.xml.NodeType.Element);
241 desc.setImmutable(true);
242 handler = new org.exolab.castor.xml.XMLFieldHandler()
244 public java.lang.Object getValue(java.lang.Object object)
245 throws IllegalStateException
247 AnnotationElement target = (AnnotationElement) object;
248 return target.getDescription();
251 public void setValue(java.lang.Object object, java.lang.Object value)
252 throws IllegalStateException, IllegalArgumentException
256 AnnotationElement target = (AnnotationElement) object;
257 target.setDescription((java.lang.String) value);
258 } catch (java.lang.Exception ex)
260 throw new IllegalStateException(ex.toString());
264 public java.lang.Object newInstance(java.lang.Object parent)
269 desc.setHandler(handler);
270 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
271 desc.setMultivalued(false);
272 addFieldDescriptor(desc);
274 // -- validation code for: _description
275 fieldValidator = new org.exolab.castor.xml.FieldValidator();
277 org.exolab.castor.xml.validators.StringValidator typeValidator;
278 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
279 fieldValidator.setValidator(typeValidator);
280 typeValidator.setWhiteSpace("preserve");
282 desc.setValidator(fieldValidator);
283 // -- _secondaryStructure
284 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
285 java.lang.String.class, "_secondaryStructure",
286 "secondaryStructure", org.exolab.castor.xml.NodeType.Element);
287 desc.setImmutable(true);
288 handler = new org.exolab.castor.xml.XMLFieldHandler()
290 public java.lang.Object getValue(java.lang.Object object)
291 throws IllegalStateException
293 AnnotationElement target = (AnnotationElement) object;
294 return target.getSecondaryStructure();
297 public void setValue(java.lang.Object object, java.lang.Object value)
298 throws IllegalStateException, IllegalArgumentException
302 AnnotationElement target = (AnnotationElement) object;
303 target.setSecondaryStructure((java.lang.String) value);
304 } catch (java.lang.Exception ex)
306 throw new IllegalStateException(ex.toString());
310 public java.lang.Object newInstance(java.lang.Object parent)
315 desc.setHandler(handler);
316 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
317 desc.setMultivalued(false);
318 addFieldDescriptor(desc);
320 // -- validation code for: _secondaryStructure
321 fieldValidator = new org.exolab.castor.xml.FieldValidator();
323 org.exolab.castor.xml.validators.StringValidator typeValidator;
324 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
325 fieldValidator.setValidator(typeValidator);
326 typeValidator.setWhiteSpace("preserve");
327 typeValidator.setLength(1);
329 desc.setValidator(fieldValidator);
331 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
332 java.lang.Float.TYPE, "_value", "value",
333 org.exolab.castor.xml.NodeType.Element);
334 handler = new org.exolab.castor.xml.XMLFieldHandler()
336 public java.lang.Object getValue(java.lang.Object object)
337 throws IllegalStateException
339 AnnotationElement target = (AnnotationElement) object;
340 if (!target.hasValue())
344 return new java.lang.Float(target.getValue());
347 public void setValue(java.lang.Object object, java.lang.Object value)
348 throws IllegalStateException, IllegalArgumentException
352 AnnotationElement target = (AnnotationElement) object;
353 // if null, use delete method for optional primitives
356 target.deleteValue();
359 target.setValue(((java.lang.Float) value).floatValue());
360 } catch (java.lang.Exception ex)
362 throw new IllegalStateException(ex.toString());
366 public java.lang.Object newInstance(java.lang.Object parent)
371 desc.setHandler(handler);
372 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
373 desc.setMultivalued(false);
374 addFieldDescriptor(desc);
376 // -- validation code for: _value
377 fieldValidator = new org.exolab.castor.xml.FieldValidator();
379 org.exolab.castor.xml.validators.FloatValidator typeValidator;
380 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
381 fieldValidator.setValidator(typeValidator);
382 typeValidator.setMinInclusive((float) -3.4028235E38);
383 typeValidator.setMaxInclusive((float) 3.4028235E38);
385 desc.setValidator(fieldValidator);
393 * Method getAccessMode.
395 * @return the access mode specified for this class.
397 public org.exolab.castor.mapping.AccessMode getAccessMode()
403 * Method getIdentity.
405 * @return the identity field, null if this class has no identity.
407 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
409 return super.getIdentity();
413 * Method getJavaClass.
415 * @return the Java class represented by this descriptor.
417 public java.lang.Class getJavaClass()
419 return jalview.schemabinding.version2.AnnotationElement.class;
423 * Method getNameSpacePrefix.
425 * @return the namespace prefix to use when marshaling as XML.
427 public java.lang.String getNameSpacePrefix()
433 * Method getNameSpaceURI.
435 * @return the namespace URI used when marshaling and unmarshaling as XML.
437 public java.lang.String getNameSpaceURI()
443 * Method getValidator.
445 * @return a specific validator for the class described by this
448 public org.exolab.castor.xml.TypeValidator getValidator()
456 * @return the XML Name for the Class being described.
458 public java.lang.String getXMLName()
464 * Method isElementDefinition.
466 * @return true if XML schema definition of this Class is that of a global
467 * element or element with anonymous type definition.
469 public boolean isElementDefinition()
471 return _elementDefinition;