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.Colour;
28 * Class ColourDescriptor.
30 * @version $Revision$ $Date$
32 public class ColourDescriptor 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 ColourDescriptor()
68 _elementDefinition = true;
69 org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
70 org.exolab.castor.mapping.FieldHandler handler = null;
71 org.exolab.castor.xml.FieldValidator fieldValidator = null;
72 // -- initialize attribute descriptors
75 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
76 java.lang.String.class, "_name", "Name",
77 org.exolab.castor.xml.NodeType.Attribute);
78 desc.setImmutable(true);
79 handler = new org.exolab.castor.xml.XMLFieldHandler()
81 public java.lang.Object getValue(java.lang.Object object)
82 throws IllegalStateException
84 Colour target = (Colour) object;
85 return target.getName();
88 public void setValue(java.lang.Object object, java.lang.Object value)
89 throws IllegalStateException, IllegalArgumentException
93 Colour target = (Colour) object;
94 target.setName((java.lang.String) value);
95 } catch (java.lang.Exception ex)
97 throw new IllegalStateException(ex.toString());
101 public java.lang.Object newInstance(java.lang.Object parent)
106 desc.setHandler(handler);
107 desc.setMultivalued(false);
108 addFieldDescriptor(desc);
110 // -- validation code for: _name
111 fieldValidator = new org.exolab.castor.xml.FieldValidator();
113 org.exolab.castor.xml.validators.StringValidator typeValidator;
114 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
115 fieldValidator.setValidator(typeValidator);
116 typeValidator.setWhiteSpace("preserve");
118 desc.setValidator(fieldValidator);
120 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
121 java.lang.String.class, "_RGB", "RGB",
122 org.exolab.castor.xml.NodeType.Attribute);
123 desc.setImmutable(true);
124 handler = new org.exolab.castor.xml.XMLFieldHandler()
126 public java.lang.Object getValue(java.lang.Object object)
127 throws IllegalStateException
129 Colour target = (Colour) object;
130 return target.getRGB();
133 public void setValue(java.lang.Object object, java.lang.Object value)
134 throws IllegalStateException, IllegalArgumentException
138 Colour target = (Colour) object;
139 target.setRGB((java.lang.String) value);
140 } catch (java.lang.Exception ex)
142 throw new IllegalStateException(ex.toString());
146 public java.lang.Object newInstance(java.lang.Object parent)
151 desc.setHandler(handler);
152 desc.setRequired(true);
153 desc.setMultivalued(false);
154 addFieldDescriptor(desc);
156 // -- validation code for: _RGB
157 fieldValidator = new org.exolab.castor.xml.FieldValidator();
158 fieldValidator.setMinOccurs(1);
160 org.exolab.castor.xml.validators.StringValidator typeValidator;
161 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
162 fieldValidator.setValidator(typeValidator);
163 typeValidator.setWhiteSpace("preserve");
165 desc.setValidator(fieldValidator);
167 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
168 java.lang.String.class, "_minRGB", "minRGB",
169 org.exolab.castor.xml.NodeType.Attribute);
170 desc.setImmutable(true);
171 handler = new org.exolab.castor.xml.XMLFieldHandler()
173 public java.lang.Object getValue(java.lang.Object object)
174 throws IllegalStateException
176 Colour target = (Colour) object;
177 return target.getMinRGB();
180 public void setValue(java.lang.Object object, java.lang.Object value)
181 throws IllegalStateException, IllegalArgumentException
185 Colour target = (Colour) object;
186 target.setMinRGB((java.lang.String) value);
187 } catch (java.lang.Exception ex)
189 throw new IllegalStateException(ex.toString());
193 public java.lang.Object newInstance(java.lang.Object parent)
198 desc.setHandler(handler);
199 desc.setMultivalued(false);
200 addFieldDescriptor(desc);
202 // -- validation code for: _minRGB
203 fieldValidator = new org.exolab.castor.xml.FieldValidator();
205 org.exolab.castor.xml.validators.StringValidator typeValidator;
206 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
207 fieldValidator.setValidator(typeValidator);
208 typeValidator.setWhiteSpace("preserve");
210 desc.setValidator(fieldValidator);
212 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
213 java.lang.String.class, "_threshType", "threshType",
214 org.exolab.castor.xml.NodeType.Attribute);
215 desc.setImmutable(true);
216 handler = new org.exolab.castor.xml.XMLFieldHandler()
218 public java.lang.Object getValue(java.lang.Object object)
219 throws IllegalStateException
221 Colour target = (Colour) object;
222 return target.getThreshType();
225 public void setValue(java.lang.Object object, java.lang.Object value)
226 throws IllegalStateException, IllegalArgumentException
230 Colour target = (Colour) object;
231 target.setThreshType((java.lang.String) value);
232 } catch (java.lang.Exception ex)
234 throw new IllegalStateException(ex.toString());
238 public java.lang.Object newInstance(java.lang.Object parent)
243 desc.setHandler(handler);
244 desc.setMultivalued(false);
245 addFieldDescriptor(desc);
247 // -- validation code for: _threshType
248 fieldValidator = new org.exolab.castor.xml.FieldValidator();
250 org.exolab.castor.xml.validators.StringValidator typeValidator;
251 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
252 fieldValidator.setValidator(typeValidator);
253 typeValidator.setWhiteSpace("preserve");
255 desc.setValidator(fieldValidator);
257 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
258 java.lang.Float.TYPE, "_threshold", "threshold",
259 org.exolab.castor.xml.NodeType.Attribute);
260 handler = new org.exolab.castor.xml.XMLFieldHandler()
262 public java.lang.Object getValue(java.lang.Object object)
263 throws IllegalStateException
265 Colour target = (Colour) object;
266 if (!target.hasThreshold())
270 return new java.lang.Float(target.getThreshold());
273 public void setValue(java.lang.Object object, java.lang.Object value)
274 throws IllegalStateException, IllegalArgumentException
278 Colour target = (Colour) object;
279 // if null, use delete method for optional primitives
282 target.deleteThreshold();
285 target.setThreshold(((java.lang.Float) value).floatValue());
286 } catch (java.lang.Exception ex)
288 throw new IllegalStateException(ex.toString());
292 public java.lang.Object newInstance(java.lang.Object parent)
297 desc.setHandler(handler);
298 desc.setMultivalued(false);
299 addFieldDescriptor(desc);
301 // -- validation code for: _threshold
302 fieldValidator = new org.exolab.castor.xml.FieldValidator();
304 org.exolab.castor.xml.validators.FloatValidator typeValidator;
305 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
306 fieldValidator.setValidator(typeValidator);
307 typeValidator.setMinInclusive((float) -3.4028235E38);
308 typeValidator.setMaxInclusive((float) 3.4028235E38);
310 desc.setValidator(fieldValidator);
312 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
313 java.lang.Float.TYPE, "_max", "max",
314 org.exolab.castor.xml.NodeType.Attribute);
315 handler = new org.exolab.castor.xml.XMLFieldHandler()
317 public java.lang.Object getValue(java.lang.Object object)
318 throws IllegalStateException
320 Colour target = (Colour) object;
321 if (!target.hasMax())
325 return new java.lang.Float(target.getMax());
328 public void setValue(java.lang.Object object, java.lang.Object value)
329 throws IllegalStateException, IllegalArgumentException
333 Colour target = (Colour) object;
334 // if null, use delete method for optional primitives
340 target.setMax(((java.lang.Float) value).floatValue());
341 } catch (java.lang.Exception ex)
343 throw new IllegalStateException(ex.toString());
347 public java.lang.Object newInstance(java.lang.Object parent)
352 desc.setHandler(handler);
353 desc.setMultivalued(false);
354 addFieldDescriptor(desc);
356 // -- validation code for: _max
357 fieldValidator = new org.exolab.castor.xml.FieldValidator();
359 org.exolab.castor.xml.validators.FloatValidator typeValidator;
360 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
361 fieldValidator.setValidator(typeValidator);
362 typeValidator.setMinInclusive((float) -3.4028235E38);
363 typeValidator.setMaxInclusive((float) 3.4028235E38);
365 desc.setValidator(fieldValidator);
367 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
368 java.lang.Float.TYPE, "_min", "min",
369 org.exolab.castor.xml.NodeType.Attribute);
370 handler = new org.exolab.castor.xml.XMLFieldHandler()
372 public java.lang.Object getValue(java.lang.Object object)
373 throws IllegalStateException
375 Colour target = (Colour) object;
376 if (!target.hasMin())
380 return new java.lang.Float(target.getMin());
383 public void setValue(java.lang.Object object, java.lang.Object value)
384 throws IllegalStateException, IllegalArgumentException
388 Colour target = (Colour) object;
389 // if null, use delete method for optional primitives
395 target.setMin(((java.lang.Float) value).floatValue());
396 } catch (java.lang.Exception ex)
398 throw new IllegalStateException(ex.toString());
402 public java.lang.Object newInstance(java.lang.Object parent)
407 desc.setHandler(handler);
408 desc.setMultivalued(false);
409 addFieldDescriptor(desc);
411 // -- validation code for: _min
412 fieldValidator = new org.exolab.castor.xml.FieldValidator();
414 org.exolab.castor.xml.validators.FloatValidator typeValidator;
415 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
416 fieldValidator.setValidator(typeValidator);
417 typeValidator.setMinInclusive((float) -3.4028235E38);
418 typeValidator.setMaxInclusive((float) 3.4028235E38);
420 desc.setValidator(fieldValidator);
422 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
423 java.lang.Boolean.TYPE, "_colourByLabel", "colourByLabel",
424 org.exolab.castor.xml.NodeType.Attribute);
425 handler = new org.exolab.castor.xml.XMLFieldHandler()
427 public java.lang.Object getValue(java.lang.Object object)
428 throws IllegalStateException
430 Colour target = (Colour) object;
431 if (!target.hasColourByLabel())
435 return (target.getColourByLabel() ? java.lang.Boolean.TRUE
436 : java.lang.Boolean.FALSE);
439 public void setValue(java.lang.Object object, java.lang.Object value)
440 throws IllegalStateException, IllegalArgumentException
444 Colour target = (Colour) object;
445 // if null, use delete method for optional primitives
448 target.deleteColourByLabel();
451 target.setColourByLabel(((java.lang.Boolean) value)
453 } catch (java.lang.Exception ex)
455 throw new IllegalStateException(ex.toString());
459 public java.lang.Object newInstance(java.lang.Object parent)
464 desc.setHandler(handler);
465 desc.setMultivalued(false);
466 addFieldDescriptor(desc);
468 // -- validation code for: _colourByLabel
469 fieldValidator = new org.exolab.castor.xml.FieldValidator();
471 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
472 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
473 fieldValidator.setValidator(typeValidator);
475 desc.setValidator(fieldValidator);
477 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
478 java.lang.Boolean.TYPE, "_autoScale", "autoScale",
479 org.exolab.castor.xml.NodeType.Attribute);
480 handler = new org.exolab.castor.xml.XMLFieldHandler()
482 public java.lang.Object getValue(java.lang.Object object)
483 throws IllegalStateException
485 Colour target = (Colour) object;
486 if (!target.hasAutoScale())
490 return (target.getAutoScale() ? java.lang.Boolean.TRUE
491 : java.lang.Boolean.FALSE);
494 public void setValue(java.lang.Object object, java.lang.Object value)
495 throws IllegalStateException, IllegalArgumentException
499 Colour target = (Colour) object;
500 // if null, use delete method for optional primitives
503 target.deleteAutoScale();
506 target.setAutoScale(((java.lang.Boolean) value).booleanValue());
507 } catch (java.lang.Exception ex)
509 throw new IllegalStateException(ex.toString());
513 public java.lang.Object newInstance(java.lang.Object parent)
518 desc.setHandler(handler);
519 desc.setMultivalued(false);
520 addFieldDescriptor(desc);
522 // -- validation code for: _autoScale
523 fieldValidator = new org.exolab.castor.xml.FieldValidator();
525 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
526 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
527 fieldValidator.setValidator(typeValidator);
529 desc.setValidator(fieldValidator);
530 // -- initialize element descriptors
539 * Method getAccessMode.
541 * @return the access mode specified for this class.
543 public org.exolab.castor.mapping.AccessMode getAccessMode()
549 * Method getIdentity.
551 * @return the identity field, null if this class has no identity.
553 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
555 return super.getIdentity();
559 * Method getJavaClass.
561 * @return the Java class represented by this descriptor.
563 public java.lang.Class getJavaClass()
565 return jalview.schemabinding.version2.Colour.class;
569 * Method getNameSpacePrefix.
571 * @return the namespace prefix to use when marshaling as XML.
573 public java.lang.String getNameSpacePrefix()
579 * Method getNameSpaceURI.
581 * @return the namespace URI used when marshaling and unmarshaling as XML.
583 public java.lang.String getNameSpaceURI()
589 * Method getValidator.
591 * @return a specific validator for the class described by this
594 public org.exolab.castor.xml.TypeValidator getValidator()
602 * @return the XML Name for the Class being described.
604 public java.lang.String getXMLName()
610 * Method isElementDefinition.
612 * @return true if XML schema definition of this Class is that of a global
613 * element or element with anonymous type definition.
615 public boolean isElementDefinition()
617 return _elementDefinition;