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.Setting;
27 * Class SettingDescriptor.
29 * @version $Revision$ $Date$
31 public class SettingDescriptor 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 SettingDescriptor()
66 _nsURI = "www.jalview.org";
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, "_type", "type",
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 Setting target = (Setting) object;
85 return target.getType();
88 public void setValue(java.lang.Object object, java.lang.Object value)
89 throws IllegalStateException, IllegalArgumentException
93 Setting target = (Setting) object;
94 target.setType((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.setRequired(true);
108 desc.setMultivalued(false);
109 addFieldDescriptor(desc);
111 // -- validation code for: _type
112 fieldValidator = new org.exolab.castor.xml.FieldValidator();
113 fieldValidator.setMinOccurs(1);
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.Integer.TYPE, "_colour", "colour",
124 org.exolab.castor.xml.NodeType.Attribute);
125 handler = new org.exolab.castor.xml.XMLFieldHandler()
127 public java.lang.Object getValue(java.lang.Object object)
128 throws IllegalStateException
130 Setting target = (Setting) object;
131 if (!target.hasColour())
135 return new java.lang.Integer(target.getColour());
138 public void setValue(java.lang.Object object, java.lang.Object value)
139 throws IllegalStateException, IllegalArgumentException
143 Setting target = (Setting) object;
144 // ignore null values for non optional primitives
150 target.setColour(((java.lang.Integer) value).intValue());
151 } catch (java.lang.Exception ex)
153 throw new IllegalStateException(ex.toString());
157 public java.lang.Object newInstance(java.lang.Object parent)
162 desc.setHandler(handler);
163 desc.setRequired(true);
164 desc.setMultivalued(false);
165 addFieldDescriptor(desc);
167 // -- validation code for: _colour
168 fieldValidator = new org.exolab.castor.xml.FieldValidator();
169 fieldValidator.setMinOccurs(1);
171 org.exolab.castor.xml.validators.IntValidator typeValidator;
172 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
173 fieldValidator.setValidator(typeValidator);
174 typeValidator.setMinInclusive(-2147483648);
175 typeValidator.setMaxInclusive(2147483647);
177 desc.setValidator(fieldValidator);
179 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
180 java.lang.Boolean.TYPE, "_display", "display",
181 org.exolab.castor.xml.NodeType.Attribute);
182 handler = new org.exolab.castor.xml.XMLFieldHandler()
184 public java.lang.Object getValue(java.lang.Object object)
185 throws IllegalStateException
187 Setting target = (Setting) object;
188 if (!target.hasDisplay())
192 return (target.getDisplay() ? java.lang.Boolean.TRUE
193 : java.lang.Boolean.FALSE);
196 public void setValue(java.lang.Object object, java.lang.Object value)
197 throws IllegalStateException, IllegalArgumentException
201 Setting target = (Setting) object;
202 // ignore null values for non optional primitives
208 target.setDisplay(((java.lang.Boolean) value).booleanValue());
209 } catch (java.lang.Exception ex)
211 throw new IllegalStateException(ex.toString());
215 public java.lang.Object newInstance(java.lang.Object parent)
220 desc.setHandler(handler);
221 desc.setRequired(true);
222 desc.setMultivalued(false);
223 addFieldDescriptor(desc);
225 // -- validation code for: _display
226 fieldValidator = new org.exolab.castor.xml.FieldValidator();
227 fieldValidator.setMinOccurs(1);
229 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
230 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
231 fieldValidator.setValidator(typeValidator);
233 desc.setValidator(fieldValidator);
235 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
236 java.lang.Float.TYPE, "_order", "order",
237 org.exolab.castor.xml.NodeType.Attribute);
238 handler = new org.exolab.castor.xml.XMLFieldHandler()
240 public java.lang.Object getValue(java.lang.Object object)
241 throws IllegalStateException
243 Setting target = (Setting) object;
244 if (!target.hasOrder())
248 return new java.lang.Float(target.getOrder());
251 public void setValue(java.lang.Object object, java.lang.Object value)
252 throws IllegalStateException, IllegalArgumentException
256 Setting target = (Setting) object;
257 // if null, use delete method for optional primitives
260 target.deleteOrder();
263 target.setOrder(((java.lang.Float) value).floatValue());
264 } catch (java.lang.Exception ex)
266 throw new IllegalStateException(ex.toString());
270 public java.lang.Object newInstance(java.lang.Object parent)
275 desc.setHandler(handler);
276 desc.setMultivalued(false);
277 addFieldDescriptor(desc);
279 // -- validation code for: _order
280 fieldValidator = new org.exolab.castor.xml.FieldValidator();
282 org.exolab.castor.xml.validators.FloatValidator typeValidator;
283 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
284 fieldValidator.setValidator(typeValidator);
285 typeValidator.setMinInclusive((float) -3.4028235E38);
286 typeValidator.setMaxInclusive((float) 3.4028235E38);
288 desc.setValidator(fieldValidator);
290 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
291 java.lang.Integer.TYPE, "_mincolour", "mincolour",
292 org.exolab.castor.xml.NodeType.Attribute);
293 handler = new org.exolab.castor.xml.XMLFieldHandler()
295 public java.lang.Object getValue(java.lang.Object object)
296 throws IllegalStateException
298 Setting target = (Setting) object;
299 if (!target.hasMincolour())
303 return new java.lang.Integer(target.getMincolour());
306 public void setValue(java.lang.Object object, java.lang.Object value)
307 throws IllegalStateException, IllegalArgumentException
311 Setting target = (Setting) object;
312 // if null, use delete method for optional primitives
315 target.deleteMincolour();
318 target.setMincolour(((java.lang.Integer) value).intValue());
319 } catch (java.lang.Exception ex)
321 throw new IllegalStateException(ex.toString());
325 public java.lang.Object newInstance(java.lang.Object parent)
330 desc.setHandler(handler);
331 desc.setMultivalued(false);
332 addFieldDescriptor(desc);
334 // -- validation code for: _mincolour
335 fieldValidator = new org.exolab.castor.xml.FieldValidator();
337 org.exolab.castor.xml.validators.IntValidator typeValidator;
338 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
339 fieldValidator.setValidator(typeValidator);
340 typeValidator.setMinInclusive(-2147483648);
341 typeValidator.setMaxInclusive(2147483647);
343 desc.setValidator(fieldValidator);
345 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
346 java.lang.Float.TYPE, "_threshold", "threshold",
347 org.exolab.castor.xml.NodeType.Attribute);
348 handler = new org.exolab.castor.xml.XMLFieldHandler()
350 public java.lang.Object getValue(java.lang.Object object)
351 throws IllegalStateException
353 Setting target = (Setting) object;
354 if (!target.hasThreshold())
358 return new java.lang.Float(target.getThreshold());
361 public void setValue(java.lang.Object object, java.lang.Object value)
362 throws IllegalStateException, IllegalArgumentException
366 Setting target = (Setting) object;
367 // if null, use delete method for optional primitives
370 target.deleteThreshold();
373 target.setThreshold(((java.lang.Float) value).floatValue());
374 } catch (java.lang.Exception ex)
376 throw new IllegalStateException(ex.toString());
380 public java.lang.Object newInstance(java.lang.Object parent)
385 desc.setHandler(handler);
386 desc.setMultivalued(false);
387 addFieldDescriptor(desc);
389 // -- validation code for: _threshold
390 fieldValidator = new org.exolab.castor.xml.FieldValidator();
392 org.exolab.castor.xml.validators.FloatValidator typeValidator;
393 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
394 fieldValidator.setValidator(typeValidator);
395 typeValidator.setMinInclusive((float) -3.4028235E38);
396 typeValidator.setMaxInclusive((float) 3.4028235E38);
398 desc.setValidator(fieldValidator);
400 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
401 java.lang.Integer.TYPE, "_threshstate", "threshstate",
402 org.exolab.castor.xml.NodeType.Attribute);
403 handler = new org.exolab.castor.xml.XMLFieldHandler()
405 public java.lang.Object getValue(java.lang.Object object)
406 throws IllegalStateException
408 Setting target = (Setting) object;
409 if (!target.hasThreshstate())
413 return new java.lang.Integer(target.getThreshstate());
416 public void setValue(java.lang.Object object, java.lang.Object value)
417 throws IllegalStateException, IllegalArgumentException
421 Setting target = (Setting) object;
422 // if null, use delete method for optional primitives
425 target.deleteThreshstate();
428 target.setThreshstate(((java.lang.Integer) value).intValue());
429 } catch (java.lang.Exception ex)
431 throw new IllegalStateException(ex.toString());
435 public java.lang.Object newInstance(java.lang.Object parent)
440 desc.setHandler(handler);
441 desc.setMultivalued(false);
442 addFieldDescriptor(desc);
444 // -- validation code for: _threshstate
445 fieldValidator = new org.exolab.castor.xml.FieldValidator();
447 org.exolab.castor.xml.validators.IntValidator typeValidator;
448 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
449 fieldValidator.setValidator(typeValidator);
450 typeValidator.setMinInclusive(-2147483648);
451 typeValidator.setMaxInclusive(2147483647);
453 desc.setValidator(fieldValidator);
455 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
456 java.lang.Float.TYPE, "_max", "max",
457 org.exolab.castor.xml.NodeType.Attribute);
458 handler = new org.exolab.castor.xml.XMLFieldHandler()
460 public java.lang.Object getValue(java.lang.Object object)
461 throws IllegalStateException
463 Setting target = (Setting) object;
464 if (!target.hasMax())
468 return new java.lang.Float(target.getMax());
471 public void setValue(java.lang.Object object, java.lang.Object value)
472 throws IllegalStateException, IllegalArgumentException
476 Setting target = (Setting) object;
477 // if null, use delete method for optional primitives
483 target.setMax(((java.lang.Float) value).floatValue());
484 } catch (java.lang.Exception ex)
486 throw new IllegalStateException(ex.toString());
490 public java.lang.Object newInstance(java.lang.Object parent)
495 desc.setHandler(handler);
496 desc.setMultivalued(false);
497 addFieldDescriptor(desc);
499 // -- validation code for: _max
500 fieldValidator = new org.exolab.castor.xml.FieldValidator();
502 org.exolab.castor.xml.validators.FloatValidator typeValidator;
503 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
504 fieldValidator.setValidator(typeValidator);
505 typeValidator.setMinInclusive((float) -3.4028235E38);
506 typeValidator.setMaxInclusive((float) 3.4028235E38);
508 desc.setValidator(fieldValidator);
510 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
511 java.lang.Float.TYPE, "_min", "min",
512 org.exolab.castor.xml.NodeType.Attribute);
513 handler = new org.exolab.castor.xml.XMLFieldHandler()
515 public java.lang.Object getValue(java.lang.Object object)
516 throws IllegalStateException
518 Setting target = (Setting) object;
519 if (!target.hasMin())
523 return new java.lang.Float(target.getMin());
526 public void setValue(java.lang.Object object, java.lang.Object value)
527 throws IllegalStateException, IllegalArgumentException
531 Setting target = (Setting) object;
532 // if null, use delete method for optional primitives
538 target.setMin(((java.lang.Float) value).floatValue());
539 } catch (java.lang.Exception ex)
541 throw new IllegalStateException(ex.toString());
545 public java.lang.Object newInstance(java.lang.Object parent)
550 desc.setHandler(handler);
551 desc.setMultivalued(false);
552 addFieldDescriptor(desc);
554 // -- validation code for: _min
555 fieldValidator = new org.exolab.castor.xml.FieldValidator();
557 org.exolab.castor.xml.validators.FloatValidator typeValidator;
558 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
559 fieldValidator.setValidator(typeValidator);
560 typeValidator.setMinInclusive((float) -3.4028235E38);
561 typeValidator.setMaxInclusive((float) 3.4028235E38);
563 desc.setValidator(fieldValidator);
565 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
566 java.lang.Boolean.TYPE, "_colourByLabel", "colourByLabel",
567 org.exolab.castor.xml.NodeType.Attribute);
568 handler = new org.exolab.castor.xml.XMLFieldHandler()
570 public java.lang.Object getValue(java.lang.Object object)
571 throws IllegalStateException
573 Setting target = (Setting) object;
574 if (!target.hasColourByLabel())
578 return (target.getColourByLabel() ? java.lang.Boolean.TRUE
579 : java.lang.Boolean.FALSE);
582 public void setValue(java.lang.Object object, java.lang.Object value)
583 throws IllegalStateException, IllegalArgumentException
587 Setting target = (Setting) object;
588 // if null, use delete method for optional primitives
591 target.deleteColourByLabel();
594 target.setColourByLabel(((java.lang.Boolean) value)
596 } catch (java.lang.Exception ex)
598 throw new IllegalStateException(ex.toString());
602 public java.lang.Object newInstance(java.lang.Object parent)
607 desc.setHandler(handler);
608 desc.setMultivalued(false);
609 addFieldDescriptor(desc);
611 // -- validation code for: _colourByLabel
612 fieldValidator = new org.exolab.castor.xml.FieldValidator();
614 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
615 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
616 fieldValidator.setValidator(typeValidator);
618 desc.setValidator(fieldValidator);
620 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
621 java.lang.Boolean.TYPE, "_autoScale", "autoScale",
622 org.exolab.castor.xml.NodeType.Attribute);
623 handler = new org.exolab.castor.xml.XMLFieldHandler()
625 public java.lang.Object getValue(java.lang.Object object)
626 throws IllegalStateException
628 Setting target = (Setting) object;
629 if (!target.hasAutoScale())
633 return (target.getAutoScale() ? java.lang.Boolean.TRUE
634 : java.lang.Boolean.FALSE);
637 public void setValue(java.lang.Object object, java.lang.Object value)
638 throws IllegalStateException, IllegalArgumentException
642 Setting target = (Setting) object;
643 // if null, use delete method for optional primitives
646 target.deleteAutoScale();
649 target.setAutoScale(((java.lang.Boolean) value).booleanValue());
650 } catch (java.lang.Exception ex)
652 throw new IllegalStateException(ex.toString());
656 public java.lang.Object newInstance(java.lang.Object parent)
661 desc.setHandler(handler);
662 desc.setMultivalued(false);
663 addFieldDescriptor(desc);
665 // -- validation code for: _autoScale
666 fieldValidator = new org.exolab.castor.xml.FieldValidator();
668 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
669 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
670 fieldValidator.setValidator(typeValidator);
672 desc.setValidator(fieldValidator);
673 // -- initialize element descriptors
682 * Method getAccessMode.
684 * @return the access mode specified for this class.
686 public org.exolab.castor.mapping.AccessMode getAccessMode()
692 * Method getIdentity.
694 * @return the identity field, null if this class has no identity.
696 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
698 return super.getIdentity();
702 * Method getJavaClass.
704 * @return the Java class represented by this descriptor.
706 public java.lang.Class getJavaClass()
708 return jalview.schemabinding.version2.Setting.class;
712 * Method getNameSpacePrefix.
714 * @return the namespace prefix to use when marshaling as XML.
716 public java.lang.String getNameSpacePrefix()
722 * Method getNameSpaceURI.
724 * @return the namespace URI used when marshaling and unmarshaling as XML.
726 public java.lang.String getNameSpaceURI()
732 * Method getValidator.
734 * @return a specific validator for the class described by this
737 public org.exolab.castor.xml.TypeValidator getValidator()
745 * @return the XML Name for the Class being described.
747 public java.lang.String getXMLName()
753 * Method isElementDefinition.
755 * @return true if XML schema definition of this Class is that of a global
756 * element or element with anonymous type definition.
758 public boolean isElementDefinition()
760 return _elementDefinition;