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.Colour;
27 * Class ColourDescriptor.
29 * @version $Revision$ $Date$
31 public class ColourDescriptor 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 ColourDescriptor()
67 _elementDefinition = true;
68 org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
69 org.exolab.castor.mapping.FieldHandler handler = null;
70 org.exolab.castor.xml.FieldValidator fieldValidator = null;
71 // -- initialize attribute descriptors
74 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
75 java.lang.String.class, "_name", "Name",
76 org.exolab.castor.xml.NodeType.Attribute);
77 desc.setImmutable(true);
78 handler = new org.exolab.castor.xml.XMLFieldHandler()
80 public java.lang.Object getValue(java.lang.Object object)
81 throws IllegalStateException
83 Colour target = (Colour) object;
84 return target.getName();
87 public void setValue(java.lang.Object object, java.lang.Object value)
88 throws IllegalStateException, IllegalArgumentException
92 Colour target = (Colour) object;
93 target.setName((java.lang.String) value);
94 } catch (java.lang.Exception ex)
96 throw new IllegalStateException(ex.toString());
100 public java.lang.Object newInstance(java.lang.Object parent)
105 desc.setHandler(handler);
106 desc.setMultivalued(false);
107 addFieldDescriptor(desc);
109 // -- validation code for: _name
110 fieldValidator = new org.exolab.castor.xml.FieldValidator();
112 org.exolab.castor.xml.validators.StringValidator typeValidator;
113 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
114 fieldValidator.setValidator(typeValidator);
115 typeValidator.setWhiteSpace("preserve");
117 desc.setValidator(fieldValidator);
119 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
120 java.lang.String.class, "_RGB", "RGB",
121 org.exolab.castor.xml.NodeType.Attribute);
122 desc.setImmutable(true);
123 handler = new org.exolab.castor.xml.XMLFieldHandler()
125 public java.lang.Object getValue(java.lang.Object object)
126 throws IllegalStateException
128 Colour target = (Colour) object;
129 return target.getRGB();
132 public void setValue(java.lang.Object object, java.lang.Object value)
133 throws IllegalStateException, IllegalArgumentException
137 Colour target = (Colour) object;
138 target.setRGB((java.lang.String) value);
139 } catch (java.lang.Exception ex)
141 throw new IllegalStateException(ex.toString());
145 public java.lang.Object newInstance(java.lang.Object parent)
150 desc.setHandler(handler);
151 desc.setRequired(true);
152 desc.setMultivalued(false);
153 addFieldDescriptor(desc);
155 // -- validation code for: _RGB
156 fieldValidator = new org.exolab.castor.xml.FieldValidator();
157 fieldValidator.setMinOccurs(1);
159 org.exolab.castor.xml.validators.StringValidator typeValidator;
160 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
161 fieldValidator.setValidator(typeValidator);
162 typeValidator.setWhiteSpace("preserve");
164 desc.setValidator(fieldValidator);
166 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
167 java.lang.String.class, "_minRGB", "minRGB",
168 org.exolab.castor.xml.NodeType.Attribute);
169 desc.setImmutable(true);
170 handler = new org.exolab.castor.xml.XMLFieldHandler()
172 public java.lang.Object getValue(java.lang.Object object)
173 throws IllegalStateException
175 Colour target = (Colour) object;
176 return target.getMinRGB();
179 public void setValue(java.lang.Object object, java.lang.Object value)
180 throws IllegalStateException, IllegalArgumentException
184 Colour target = (Colour) object;
185 target.setMinRGB((java.lang.String) value);
186 } catch (java.lang.Exception ex)
188 throw new IllegalStateException(ex.toString());
192 public java.lang.Object newInstance(java.lang.Object parent)
197 desc.setHandler(handler);
198 desc.setMultivalued(false);
199 addFieldDescriptor(desc);
201 // -- validation code for: _minRGB
202 fieldValidator = new org.exolab.castor.xml.FieldValidator();
204 org.exolab.castor.xml.validators.StringValidator typeValidator;
205 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
206 fieldValidator.setValidator(typeValidator);
207 typeValidator.setWhiteSpace("preserve");
209 desc.setValidator(fieldValidator);
211 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
212 java.lang.String.class, "_threshType", "threshType",
213 org.exolab.castor.xml.NodeType.Attribute);
214 desc.setImmutable(true);
215 handler = new org.exolab.castor.xml.XMLFieldHandler()
217 public java.lang.Object getValue(java.lang.Object object)
218 throws IllegalStateException
220 Colour target = (Colour) object;
221 return target.getThreshType();
224 public void setValue(java.lang.Object object, java.lang.Object value)
225 throws IllegalStateException, IllegalArgumentException
229 Colour target = (Colour) object;
230 target.setThreshType((java.lang.String) value);
231 } catch (java.lang.Exception ex)
233 throw new IllegalStateException(ex.toString());
237 public java.lang.Object newInstance(java.lang.Object parent)
242 desc.setHandler(handler);
243 desc.setMultivalued(false);
244 addFieldDescriptor(desc);
246 // -- validation code for: _threshType
247 fieldValidator = new org.exolab.castor.xml.FieldValidator();
249 org.exolab.castor.xml.validators.StringValidator typeValidator;
250 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
251 fieldValidator.setValidator(typeValidator);
252 typeValidator.setWhiteSpace("preserve");
254 desc.setValidator(fieldValidator);
256 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
257 java.lang.Float.TYPE, "_threshold", "threshold",
258 org.exolab.castor.xml.NodeType.Attribute);
259 handler = new org.exolab.castor.xml.XMLFieldHandler()
261 public java.lang.Object getValue(java.lang.Object object)
262 throws IllegalStateException
264 Colour target = (Colour) object;
265 if (!target.hasThreshold())
269 return new java.lang.Float(target.getThreshold());
272 public void setValue(java.lang.Object object, java.lang.Object value)
273 throws IllegalStateException, IllegalArgumentException
277 Colour target = (Colour) object;
278 // if null, use delete method for optional primitives
281 target.deleteThreshold();
284 target.setThreshold(((java.lang.Float) value).floatValue());
285 } catch (java.lang.Exception ex)
287 throw new IllegalStateException(ex.toString());
291 public java.lang.Object newInstance(java.lang.Object parent)
296 desc.setHandler(handler);
297 desc.setMultivalued(false);
298 addFieldDescriptor(desc);
300 // -- validation code for: _threshold
301 fieldValidator = new org.exolab.castor.xml.FieldValidator();
303 org.exolab.castor.xml.validators.FloatValidator typeValidator;
304 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
305 fieldValidator.setValidator(typeValidator);
306 typeValidator.setMinInclusive((float) -3.4028235E38);
307 typeValidator.setMaxInclusive((float) 3.4028235E38);
309 desc.setValidator(fieldValidator);
311 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
312 java.lang.Float.TYPE, "_max", "max",
313 org.exolab.castor.xml.NodeType.Attribute);
314 handler = new org.exolab.castor.xml.XMLFieldHandler()
316 public java.lang.Object getValue(java.lang.Object object)
317 throws IllegalStateException
319 Colour target = (Colour) object;
320 if (!target.hasMax())
324 return new java.lang.Float(target.getMax());
327 public void setValue(java.lang.Object object, java.lang.Object value)
328 throws IllegalStateException, IllegalArgumentException
332 Colour target = (Colour) object;
333 // if null, use delete method for optional primitives
339 target.setMax(((java.lang.Float) value).floatValue());
340 } catch (java.lang.Exception ex)
342 throw new IllegalStateException(ex.toString());
346 public java.lang.Object newInstance(java.lang.Object parent)
351 desc.setHandler(handler);
352 desc.setMultivalued(false);
353 addFieldDescriptor(desc);
355 // -- validation code for: _max
356 fieldValidator = new org.exolab.castor.xml.FieldValidator();
358 org.exolab.castor.xml.validators.FloatValidator typeValidator;
359 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
360 fieldValidator.setValidator(typeValidator);
361 typeValidator.setMinInclusive((float) -3.4028235E38);
362 typeValidator.setMaxInclusive((float) 3.4028235E38);
364 desc.setValidator(fieldValidator);
366 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
367 java.lang.Float.TYPE, "_min", "min",
368 org.exolab.castor.xml.NodeType.Attribute);
369 handler = new org.exolab.castor.xml.XMLFieldHandler()
371 public java.lang.Object getValue(java.lang.Object object)
372 throws IllegalStateException
374 Colour target = (Colour) object;
375 if (!target.hasMin())
379 return new java.lang.Float(target.getMin());
382 public void setValue(java.lang.Object object, java.lang.Object value)
383 throws IllegalStateException, IllegalArgumentException
387 Colour target = (Colour) object;
388 // if null, use delete method for optional primitives
394 target.setMin(((java.lang.Float) value).floatValue());
395 } catch (java.lang.Exception ex)
397 throw new IllegalStateException(ex.toString());
401 public java.lang.Object newInstance(java.lang.Object parent)
406 desc.setHandler(handler);
407 desc.setMultivalued(false);
408 addFieldDescriptor(desc);
410 // -- validation code for: _min
411 fieldValidator = new org.exolab.castor.xml.FieldValidator();
413 org.exolab.castor.xml.validators.FloatValidator typeValidator;
414 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
415 fieldValidator.setValidator(typeValidator);
416 typeValidator.setMinInclusive((float) -3.4028235E38);
417 typeValidator.setMaxInclusive((float) 3.4028235E38);
419 desc.setValidator(fieldValidator);
421 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
422 java.lang.Boolean.TYPE, "_colourByLabel", "colourByLabel",
423 org.exolab.castor.xml.NodeType.Attribute);
424 handler = new org.exolab.castor.xml.XMLFieldHandler()
426 public java.lang.Object getValue(java.lang.Object object)
427 throws IllegalStateException
429 Colour target = (Colour) object;
430 if (!target.hasColourByLabel())
434 return (target.getColourByLabel() ? java.lang.Boolean.TRUE
435 : java.lang.Boolean.FALSE);
438 public void setValue(java.lang.Object object, java.lang.Object value)
439 throws IllegalStateException, IllegalArgumentException
443 Colour target = (Colour) object;
444 // if null, use delete method for optional primitives
447 target.deleteColourByLabel();
450 target.setColourByLabel(((java.lang.Boolean) value)
452 } catch (java.lang.Exception ex)
454 throw new IllegalStateException(ex.toString());
458 public java.lang.Object newInstance(java.lang.Object parent)
463 desc.setHandler(handler);
464 desc.setMultivalued(false);
465 addFieldDescriptor(desc);
467 // -- validation code for: _colourByLabel
468 fieldValidator = new org.exolab.castor.xml.FieldValidator();
470 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
471 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
472 fieldValidator.setValidator(typeValidator);
474 desc.setValidator(fieldValidator);
476 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
477 java.lang.Boolean.TYPE, "_autoScale", "autoScale",
478 org.exolab.castor.xml.NodeType.Attribute);
479 handler = new org.exolab.castor.xml.XMLFieldHandler()
481 public java.lang.Object getValue(java.lang.Object object)
482 throws IllegalStateException
484 Colour target = (Colour) object;
485 if (!target.hasAutoScale())
489 return (target.getAutoScale() ? java.lang.Boolean.TRUE
490 : java.lang.Boolean.FALSE);
493 public void setValue(java.lang.Object object, java.lang.Object value)
494 throws IllegalStateException, IllegalArgumentException
498 Colour target = (Colour) object;
499 // if null, use delete method for optional primitives
502 target.deleteAutoScale();
505 target.setAutoScale(((java.lang.Boolean) value).booleanValue());
506 } catch (java.lang.Exception ex)
508 throw new IllegalStateException(ex.toString());
512 public java.lang.Object newInstance(java.lang.Object parent)
517 desc.setHandler(handler);
518 desc.setMultivalued(false);
519 addFieldDescriptor(desc);
521 // -- validation code for: _autoScale
522 fieldValidator = new org.exolab.castor.xml.FieldValidator();
524 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
525 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
526 fieldValidator.setValidator(typeValidator);
528 desc.setValidator(fieldValidator);
529 // -- initialize element descriptors
538 * Method getAccessMode.
540 * @return the access mode specified for this class.
542 public org.exolab.castor.mapping.AccessMode getAccessMode()
548 * Method getIdentity.
550 * @return the identity field, null if this class has no identity.
552 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
554 return super.getIdentity();
558 * Method getJavaClass.
560 * @return the Java class represented by this descriptor.
562 public java.lang.Class getJavaClass()
564 return jalview.schemabinding.version2.Colour.class;
568 * Method getNameSpacePrefix.
570 * @return the namespace prefix to use when marshaling as XML.
572 public java.lang.String getNameSpacePrefix()
578 * Method getNameSpaceURI.
580 * @return the namespace URI used when marshaling and unmarshaling as XML.
582 public java.lang.String getNameSpaceURI()
588 * Method getValidator.
590 * @return a specific validator for the class described by this
593 public org.exolab.castor.xml.TypeValidator getValidator()
601 * @return the XML Name for the Class being described.
603 public java.lang.String getXMLName()
609 * Method isElementDefinition.
611 * @return true if XML schema definition of this Class is that of a global
612 * element or element with anonymous type definition.
614 public boolean isElementDefinition()
616 return _elementDefinition;