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.Colour;
30 * Class ColourDescriptor.
32 * @version $Revision$ $Date$
34 public class ColourDescriptor 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 ColourDescriptor()
70 _elementDefinition = true;
71 org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
72 org.exolab.castor.mapping.FieldHandler handler = null;
73 org.exolab.castor.xml.FieldValidator fieldValidator = null;
74 // -- initialize attribute descriptors
77 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
78 java.lang.String.class, "_name", "Name",
79 org.exolab.castor.xml.NodeType.Attribute);
80 desc.setImmutable(true);
81 handler = new org.exolab.castor.xml.XMLFieldHandler()
83 public java.lang.Object getValue(java.lang.Object object)
84 throws IllegalStateException
86 Colour target = (Colour) object;
87 return target.getName();
90 public void setValue(java.lang.Object object, java.lang.Object value)
91 throws IllegalStateException, IllegalArgumentException
95 Colour target = (Colour) object;
96 target.setName((java.lang.String) value);
97 } catch (java.lang.Exception ex)
99 throw new IllegalStateException(ex.toString());
103 public java.lang.Object newInstance(java.lang.Object parent)
108 desc.setHandler(handler);
109 desc.setMultivalued(false);
110 addFieldDescriptor(desc);
112 // -- validation code for: _name
113 fieldValidator = new org.exolab.castor.xml.FieldValidator();
115 org.exolab.castor.xml.validators.StringValidator typeValidator;
116 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
117 fieldValidator.setValidator(typeValidator);
118 typeValidator.setWhiteSpace("preserve");
120 desc.setValidator(fieldValidator);
122 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
123 java.lang.String.class, "_RGB", "RGB",
124 org.exolab.castor.xml.NodeType.Attribute);
125 desc.setImmutable(true);
126 handler = new org.exolab.castor.xml.XMLFieldHandler()
128 public java.lang.Object getValue(java.lang.Object object)
129 throws IllegalStateException
131 Colour target = (Colour) object;
132 return target.getRGB();
135 public void setValue(java.lang.Object object, java.lang.Object value)
136 throws IllegalStateException, IllegalArgumentException
140 Colour target = (Colour) object;
141 target.setRGB((java.lang.String) value);
142 } catch (java.lang.Exception ex)
144 throw new IllegalStateException(ex.toString());
148 public java.lang.Object newInstance(java.lang.Object parent)
153 desc.setHandler(handler);
154 desc.setRequired(true);
155 desc.setMultivalued(false);
156 addFieldDescriptor(desc);
158 // -- validation code for: _RGB
159 fieldValidator = new org.exolab.castor.xml.FieldValidator();
160 fieldValidator.setMinOccurs(1);
162 org.exolab.castor.xml.validators.StringValidator typeValidator;
163 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
164 fieldValidator.setValidator(typeValidator);
165 typeValidator.setWhiteSpace("preserve");
167 desc.setValidator(fieldValidator);
169 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
170 java.lang.String.class, "_minRGB", "minRGB",
171 org.exolab.castor.xml.NodeType.Attribute);
172 desc.setImmutable(true);
173 handler = new org.exolab.castor.xml.XMLFieldHandler()
175 public java.lang.Object getValue(java.lang.Object object)
176 throws IllegalStateException
178 Colour target = (Colour) object;
179 return target.getMinRGB();
182 public void setValue(java.lang.Object object, java.lang.Object value)
183 throws IllegalStateException, IllegalArgumentException
187 Colour target = (Colour) object;
188 target.setMinRGB((java.lang.String) value);
189 } catch (java.lang.Exception ex)
191 throw new IllegalStateException(ex.toString());
195 public java.lang.Object newInstance(java.lang.Object parent)
200 desc.setHandler(handler);
201 desc.setMultivalued(false);
202 addFieldDescriptor(desc);
204 // -- validation code for: _minRGB
205 fieldValidator = new org.exolab.castor.xml.FieldValidator();
207 org.exolab.castor.xml.validators.StringValidator typeValidator;
208 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
209 fieldValidator.setValidator(typeValidator);
210 typeValidator.setWhiteSpace("preserve");
212 desc.setValidator(fieldValidator);
214 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
215 java.lang.String.class, "_threshType", "threshType",
216 org.exolab.castor.xml.NodeType.Attribute);
217 desc.setImmutable(true);
218 handler = new org.exolab.castor.xml.XMLFieldHandler()
220 public java.lang.Object getValue(java.lang.Object object)
221 throws IllegalStateException
223 Colour target = (Colour) object;
224 return target.getThreshType();
227 public void setValue(java.lang.Object object, java.lang.Object value)
228 throws IllegalStateException, IllegalArgumentException
232 Colour target = (Colour) object;
233 target.setThreshType((java.lang.String) value);
234 } catch (java.lang.Exception ex)
236 throw new IllegalStateException(ex.toString());
240 public java.lang.Object newInstance(java.lang.Object parent)
245 desc.setHandler(handler);
246 desc.setMultivalued(false);
247 addFieldDescriptor(desc);
249 // -- validation code for: _threshType
250 fieldValidator = new org.exolab.castor.xml.FieldValidator();
252 org.exolab.castor.xml.validators.StringValidator typeValidator;
253 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
254 fieldValidator.setValidator(typeValidator);
255 typeValidator.setWhiteSpace("preserve");
257 desc.setValidator(fieldValidator);
259 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
260 java.lang.Float.TYPE, "_threshold", "threshold",
261 org.exolab.castor.xml.NodeType.Attribute);
262 handler = new org.exolab.castor.xml.XMLFieldHandler()
264 public java.lang.Object getValue(java.lang.Object object)
265 throws IllegalStateException
267 Colour target = (Colour) object;
268 if (!target.hasThreshold())
272 return new java.lang.Float(target.getThreshold());
275 public void setValue(java.lang.Object object, java.lang.Object value)
276 throws IllegalStateException, IllegalArgumentException
280 Colour target = (Colour) object;
281 // if null, use delete method for optional primitives
284 target.deleteThreshold();
287 target.setThreshold(((java.lang.Float) value).floatValue());
288 } catch (java.lang.Exception ex)
290 throw new IllegalStateException(ex.toString());
294 public java.lang.Object newInstance(java.lang.Object parent)
299 desc.setHandler(handler);
300 desc.setMultivalued(false);
301 addFieldDescriptor(desc);
303 // -- validation code for: _threshold
304 fieldValidator = new org.exolab.castor.xml.FieldValidator();
306 org.exolab.castor.xml.validators.FloatValidator typeValidator;
307 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
308 fieldValidator.setValidator(typeValidator);
309 typeValidator.setMinInclusive((float) -3.4028235E38);
310 typeValidator.setMaxInclusive((float) 3.4028235E38);
312 desc.setValidator(fieldValidator);
314 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
315 java.lang.Float.TYPE, "_max", "max",
316 org.exolab.castor.xml.NodeType.Attribute);
317 handler = new org.exolab.castor.xml.XMLFieldHandler()
319 public java.lang.Object getValue(java.lang.Object object)
320 throws IllegalStateException
322 Colour target = (Colour) object;
323 if (!target.hasMax())
327 return new java.lang.Float(target.getMax());
330 public void setValue(java.lang.Object object, java.lang.Object value)
331 throws IllegalStateException, IllegalArgumentException
335 Colour target = (Colour) object;
336 // if null, use delete method for optional primitives
342 target.setMax(((java.lang.Float) value).floatValue());
343 } catch (java.lang.Exception ex)
345 throw new IllegalStateException(ex.toString());
349 public java.lang.Object newInstance(java.lang.Object parent)
354 desc.setHandler(handler);
355 desc.setMultivalued(false);
356 addFieldDescriptor(desc);
358 // -- validation code for: _max
359 fieldValidator = new org.exolab.castor.xml.FieldValidator();
361 org.exolab.castor.xml.validators.FloatValidator typeValidator;
362 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
363 fieldValidator.setValidator(typeValidator);
364 typeValidator.setMinInclusive((float) -3.4028235E38);
365 typeValidator.setMaxInclusive((float) 3.4028235E38);
367 desc.setValidator(fieldValidator);
369 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
370 java.lang.Float.TYPE, "_min", "min",
371 org.exolab.castor.xml.NodeType.Attribute);
372 handler = new org.exolab.castor.xml.XMLFieldHandler()
374 public java.lang.Object getValue(java.lang.Object object)
375 throws IllegalStateException
377 Colour target = (Colour) object;
378 if (!target.hasMin())
382 return new java.lang.Float(target.getMin());
385 public void setValue(java.lang.Object object, java.lang.Object value)
386 throws IllegalStateException, IllegalArgumentException
390 Colour target = (Colour) object;
391 // if null, use delete method for optional primitives
397 target.setMin(((java.lang.Float) value).floatValue());
398 } catch (java.lang.Exception ex)
400 throw new IllegalStateException(ex.toString());
404 public java.lang.Object newInstance(java.lang.Object parent)
409 desc.setHandler(handler);
410 desc.setMultivalued(false);
411 addFieldDescriptor(desc);
413 // -- validation code for: _min
414 fieldValidator = new org.exolab.castor.xml.FieldValidator();
416 org.exolab.castor.xml.validators.FloatValidator typeValidator;
417 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
418 fieldValidator.setValidator(typeValidator);
419 typeValidator.setMinInclusive((float) -3.4028235E38);
420 typeValidator.setMaxInclusive((float) 3.4028235E38);
422 desc.setValidator(fieldValidator);
424 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
425 java.lang.Boolean.TYPE, "_colourByLabel", "colourByLabel",
426 org.exolab.castor.xml.NodeType.Attribute);
427 handler = new org.exolab.castor.xml.XMLFieldHandler()
429 public java.lang.Object getValue(java.lang.Object object)
430 throws IllegalStateException
432 Colour target = (Colour) object;
433 if (!target.hasColourByLabel())
437 return (target.getColourByLabel() ? java.lang.Boolean.TRUE
438 : java.lang.Boolean.FALSE);
441 public void setValue(java.lang.Object object, java.lang.Object value)
442 throws IllegalStateException, IllegalArgumentException
446 Colour target = (Colour) object;
447 // if null, use delete method for optional primitives
450 target.deleteColourByLabel();
453 target.setColourByLabel(((java.lang.Boolean) value)
455 } catch (java.lang.Exception ex)
457 throw new IllegalStateException(ex.toString());
461 public java.lang.Object newInstance(java.lang.Object parent)
466 desc.setHandler(handler);
467 desc.setMultivalued(false);
468 addFieldDescriptor(desc);
470 // -- validation code for: _colourByLabel
471 fieldValidator = new org.exolab.castor.xml.FieldValidator();
473 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
474 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
475 fieldValidator.setValidator(typeValidator);
477 desc.setValidator(fieldValidator);
479 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
480 java.lang.Boolean.TYPE, "_autoScale", "autoScale",
481 org.exolab.castor.xml.NodeType.Attribute);
482 handler = new org.exolab.castor.xml.XMLFieldHandler()
484 public java.lang.Object getValue(java.lang.Object object)
485 throws IllegalStateException
487 Colour target = (Colour) object;
488 if (!target.hasAutoScale())
492 return (target.getAutoScale() ? java.lang.Boolean.TRUE
493 : java.lang.Boolean.FALSE);
496 public void setValue(java.lang.Object object, java.lang.Object value)
497 throws IllegalStateException, IllegalArgumentException
501 Colour target = (Colour) object;
502 // if null, use delete method for optional primitives
505 target.deleteAutoScale();
508 target.setAutoScale(((java.lang.Boolean) value).booleanValue());
509 } catch (java.lang.Exception ex)
511 throw new IllegalStateException(ex.toString());
515 public java.lang.Object newInstance(java.lang.Object parent)
520 desc.setHandler(handler);
521 desc.setMultivalued(false);
522 addFieldDescriptor(desc);
524 // -- validation code for: _autoScale
525 fieldValidator = new org.exolab.castor.xml.FieldValidator();
527 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
528 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
529 fieldValidator.setValidator(typeValidator);
531 desc.setValidator(fieldValidator);
532 // -- initialize element descriptors
541 * Method getAccessMode.
543 * @return the access mode specified for this class.
545 public org.exolab.castor.mapping.AccessMode getAccessMode()
551 * Method getIdentity.
553 * @return the identity field, null if this class has no identity.
555 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
557 return super.getIdentity();
561 * Method getJavaClass.
563 * @return the Java class represented by this descriptor.
565 public java.lang.Class getJavaClass()
567 return jalview.schemabinding.version2.Colour.class;
571 * Method getNameSpacePrefix.
573 * @return the namespace prefix to use when marshaling as XML.
575 public java.lang.String getNameSpacePrefix()
581 * Method getNameSpaceURI.
583 * @return the namespace URI used when marshaling and unmarshaling as XML.
585 public java.lang.String getNameSpaceURI()
591 * Method getValidator.
593 * @return a specific validator for the class described by this
596 public org.exolab.castor.xml.TypeValidator getValidator()
604 * @return the XML Name for the Class being described.
606 public java.lang.String getXMLName()
612 * Method isElementDefinition.
614 * @return true if XML schema definition of this Class is that of a global
615 * element or element with anonymous type definition.
617 public boolean isElementDefinition()
619 return _elementDefinition;