2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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.Setting;
30 * Class SettingDescriptor.
32 * @version $Revision$ $Date$
34 public class SettingDescriptor 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 SettingDescriptor()
69 _nsURI = "www.jalview.org";
71 _elementDefinition = true;
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.String.class, "_type", "type",
80 org.exolab.castor.xml.NodeType.Attribute);
81 desc.setImmutable(true);
82 handler = new org.exolab.castor.xml.XMLFieldHandler()
84 public java.lang.Object getValue(java.lang.Object object)
85 throws IllegalStateException
87 Setting target = (Setting) object;
88 return target.getType();
91 public void setValue(java.lang.Object object, java.lang.Object value)
92 throws IllegalStateException, IllegalArgumentException
96 Setting target = (Setting) object;
97 target.setType((java.lang.String) value);
98 } catch (java.lang.Exception ex)
100 throw new IllegalStateException(ex.toString());
104 public java.lang.Object newInstance(java.lang.Object parent)
109 desc.setHandler(handler);
110 desc.setRequired(true);
111 desc.setMultivalued(false);
112 addFieldDescriptor(desc);
114 // -- validation code for: _type
115 fieldValidator = new org.exolab.castor.xml.FieldValidator();
116 fieldValidator.setMinOccurs(1);
118 org.exolab.castor.xml.validators.StringValidator typeValidator;
119 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
120 fieldValidator.setValidator(typeValidator);
121 typeValidator.setWhiteSpace("preserve");
123 desc.setValidator(fieldValidator);
125 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
126 java.lang.Integer.TYPE, "_colour", "colour",
127 org.exolab.castor.xml.NodeType.Attribute);
128 handler = new org.exolab.castor.xml.XMLFieldHandler()
130 public java.lang.Object getValue(java.lang.Object object)
131 throws IllegalStateException
133 Setting target = (Setting) object;
134 if (!target.hasColour())
138 return new java.lang.Integer(target.getColour());
141 public void setValue(java.lang.Object object, java.lang.Object value)
142 throws IllegalStateException, IllegalArgumentException
146 Setting target = (Setting) object;
147 // ignore null values for non optional primitives
153 target.setColour(((java.lang.Integer) value).intValue());
154 } catch (java.lang.Exception ex)
156 throw new IllegalStateException(ex.toString());
160 public java.lang.Object newInstance(java.lang.Object parent)
165 desc.setHandler(handler);
166 desc.setRequired(true);
167 desc.setMultivalued(false);
168 addFieldDescriptor(desc);
170 // -- validation code for: _colour
171 fieldValidator = new org.exolab.castor.xml.FieldValidator();
172 fieldValidator.setMinOccurs(1);
174 org.exolab.castor.xml.validators.IntValidator typeValidator;
175 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
176 fieldValidator.setValidator(typeValidator);
177 typeValidator.setMinInclusive(-2147483648);
178 typeValidator.setMaxInclusive(2147483647);
180 desc.setValidator(fieldValidator);
182 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
183 java.lang.Boolean.TYPE, "_display", "display",
184 org.exolab.castor.xml.NodeType.Attribute);
185 handler = new org.exolab.castor.xml.XMLFieldHandler()
187 public java.lang.Object getValue(java.lang.Object object)
188 throws IllegalStateException
190 Setting target = (Setting) object;
191 if (!target.hasDisplay())
195 return (target.getDisplay() ? java.lang.Boolean.TRUE
196 : java.lang.Boolean.FALSE);
199 public void setValue(java.lang.Object object, java.lang.Object value)
200 throws IllegalStateException, IllegalArgumentException
204 Setting target = (Setting) object;
205 // ignore null values for non optional primitives
211 target.setDisplay(((java.lang.Boolean) value).booleanValue());
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.setRequired(true);
225 desc.setMultivalued(false);
226 addFieldDescriptor(desc);
228 // -- validation code for: _display
229 fieldValidator = new org.exolab.castor.xml.FieldValidator();
230 fieldValidator.setMinOccurs(1);
232 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
233 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
234 fieldValidator.setValidator(typeValidator);
236 desc.setValidator(fieldValidator);
238 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
239 java.lang.Float.TYPE, "_order", "order",
240 org.exolab.castor.xml.NodeType.Attribute);
241 handler = new org.exolab.castor.xml.XMLFieldHandler()
243 public java.lang.Object getValue(java.lang.Object object)
244 throws IllegalStateException
246 Setting target = (Setting) object;
247 if (!target.hasOrder())
251 return new java.lang.Float(target.getOrder());
254 public void setValue(java.lang.Object object, java.lang.Object value)
255 throws IllegalStateException, IllegalArgumentException
259 Setting target = (Setting) object;
260 // if null, use delete method for optional primitives
263 target.deleteOrder();
266 target.setOrder(((java.lang.Float) value).floatValue());
267 } catch (java.lang.Exception ex)
269 throw new IllegalStateException(ex.toString());
273 public java.lang.Object newInstance(java.lang.Object parent)
278 desc.setHandler(handler);
279 desc.setMultivalued(false);
280 addFieldDescriptor(desc);
282 // -- validation code for: _order
283 fieldValidator = new org.exolab.castor.xml.FieldValidator();
285 org.exolab.castor.xml.validators.FloatValidator typeValidator;
286 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
287 fieldValidator.setValidator(typeValidator);
288 typeValidator.setMinInclusive((float) -3.4028235E38);
289 typeValidator.setMaxInclusive((float) 3.4028235E38);
291 desc.setValidator(fieldValidator);
293 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
294 java.lang.Integer.TYPE, "_mincolour", "mincolour",
295 org.exolab.castor.xml.NodeType.Attribute);
296 handler = new org.exolab.castor.xml.XMLFieldHandler()
298 public java.lang.Object getValue(java.lang.Object object)
299 throws IllegalStateException
301 Setting target = (Setting) object;
302 if (!target.hasMincolour())
306 return new java.lang.Integer(target.getMincolour());
309 public void setValue(java.lang.Object object, java.lang.Object value)
310 throws IllegalStateException, IllegalArgumentException
314 Setting target = (Setting) object;
315 // if null, use delete method for optional primitives
318 target.deleteMincolour();
321 target.setMincolour(((java.lang.Integer) value).intValue());
322 } catch (java.lang.Exception ex)
324 throw new IllegalStateException(ex.toString());
328 public java.lang.Object newInstance(java.lang.Object parent)
333 desc.setHandler(handler);
334 desc.setMultivalued(false);
335 addFieldDescriptor(desc);
337 // -- validation code for: _mincolour
338 fieldValidator = new org.exolab.castor.xml.FieldValidator();
340 org.exolab.castor.xml.validators.IntValidator typeValidator;
341 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
342 fieldValidator.setValidator(typeValidator);
343 typeValidator.setMinInclusive(-2147483648);
344 typeValidator.setMaxInclusive(2147483647);
346 desc.setValidator(fieldValidator);
348 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
349 java.lang.Float.TYPE, "_threshold", "threshold",
350 org.exolab.castor.xml.NodeType.Attribute);
351 handler = new org.exolab.castor.xml.XMLFieldHandler()
353 public java.lang.Object getValue(java.lang.Object object)
354 throws IllegalStateException
356 Setting target = (Setting) object;
357 if (!target.hasThreshold())
361 return new java.lang.Float(target.getThreshold());
364 public void setValue(java.lang.Object object, java.lang.Object value)
365 throws IllegalStateException, IllegalArgumentException
369 Setting target = (Setting) object;
370 // if null, use delete method for optional primitives
373 target.deleteThreshold();
376 target.setThreshold(((java.lang.Float) value).floatValue());
377 } catch (java.lang.Exception ex)
379 throw new IllegalStateException(ex.toString());
383 public java.lang.Object newInstance(java.lang.Object parent)
388 desc.setHandler(handler);
389 desc.setMultivalued(false);
390 addFieldDescriptor(desc);
392 // -- validation code for: _threshold
393 fieldValidator = new org.exolab.castor.xml.FieldValidator();
395 org.exolab.castor.xml.validators.FloatValidator typeValidator;
396 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
397 fieldValidator.setValidator(typeValidator);
398 typeValidator.setMinInclusive((float) -3.4028235E38);
399 typeValidator.setMaxInclusive((float) 3.4028235E38);
401 desc.setValidator(fieldValidator);
403 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
404 java.lang.Integer.TYPE, "_threshstate", "threshstate",
405 org.exolab.castor.xml.NodeType.Attribute);
406 handler = new org.exolab.castor.xml.XMLFieldHandler()
408 public java.lang.Object getValue(java.lang.Object object)
409 throws IllegalStateException
411 Setting target = (Setting) object;
412 if (!target.hasThreshstate())
416 return new java.lang.Integer(target.getThreshstate());
419 public void setValue(java.lang.Object object, java.lang.Object value)
420 throws IllegalStateException, IllegalArgumentException
424 Setting target = (Setting) object;
425 // if null, use delete method for optional primitives
428 target.deleteThreshstate();
431 target.setThreshstate(((java.lang.Integer) value).intValue());
432 } catch (java.lang.Exception ex)
434 throw new IllegalStateException(ex.toString());
438 public java.lang.Object newInstance(java.lang.Object parent)
443 desc.setHandler(handler);
444 desc.setMultivalued(false);
445 addFieldDescriptor(desc);
447 // -- validation code for: _threshstate
448 fieldValidator = new org.exolab.castor.xml.FieldValidator();
450 org.exolab.castor.xml.validators.IntValidator typeValidator;
451 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
452 fieldValidator.setValidator(typeValidator);
453 typeValidator.setMinInclusive(-2147483648);
454 typeValidator.setMaxInclusive(2147483647);
456 desc.setValidator(fieldValidator);
458 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
459 java.lang.Float.TYPE, "_max", "max",
460 org.exolab.castor.xml.NodeType.Attribute);
461 handler = new org.exolab.castor.xml.XMLFieldHandler()
463 public java.lang.Object getValue(java.lang.Object object)
464 throws IllegalStateException
466 Setting target = (Setting) object;
467 if (!target.hasMax())
471 return new java.lang.Float(target.getMax());
474 public void setValue(java.lang.Object object, java.lang.Object value)
475 throws IllegalStateException, IllegalArgumentException
479 Setting target = (Setting) object;
480 // if null, use delete method for optional primitives
486 target.setMax(((java.lang.Float) value).floatValue());
487 } catch (java.lang.Exception ex)
489 throw new IllegalStateException(ex.toString());
493 public java.lang.Object newInstance(java.lang.Object parent)
498 desc.setHandler(handler);
499 desc.setMultivalued(false);
500 addFieldDescriptor(desc);
502 // -- validation code for: _max
503 fieldValidator = new org.exolab.castor.xml.FieldValidator();
505 org.exolab.castor.xml.validators.FloatValidator typeValidator;
506 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
507 fieldValidator.setValidator(typeValidator);
508 typeValidator.setMinInclusive((float) -3.4028235E38);
509 typeValidator.setMaxInclusive((float) 3.4028235E38);
511 desc.setValidator(fieldValidator);
513 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
514 java.lang.Float.TYPE, "_min", "min",
515 org.exolab.castor.xml.NodeType.Attribute);
516 handler = new org.exolab.castor.xml.XMLFieldHandler()
518 public java.lang.Object getValue(java.lang.Object object)
519 throws IllegalStateException
521 Setting target = (Setting) object;
522 if (!target.hasMin())
526 return new java.lang.Float(target.getMin());
529 public void setValue(java.lang.Object object, java.lang.Object value)
530 throws IllegalStateException, IllegalArgumentException
534 Setting target = (Setting) object;
535 // if null, use delete method for optional primitives
541 target.setMin(((java.lang.Float) value).floatValue());
542 } catch (java.lang.Exception ex)
544 throw new IllegalStateException(ex.toString());
548 public java.lang.Object newInstance(java.lang.Object parent)
553 desc.setHandler(handler);
554 desc.setMultivalued(false);
555 addFieldDescriptor(desc);
557 // -- validation code for: _min
558 fieldValidator = new org.exolab.castor.xml.FieldValidator();
560 org.exolab.castor.xml.validators.FloatValidator typeValidator;
561 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
562 fieldValidator.setValidator(typeValidator);
563 typeValidator.setMinInclusive((float) -3.4028235E38);
564 typeValidator.setMaxInclusive((float) 3.4028235E38);
566 desc.setValidator(fieldValidator);
568 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
569 java.lang.Boolean.TYPE, "_colourByLabel", "colourByLabel",
570 org.exolab.castor.xml.NodeType.Attribute);
571 handler = new org.exolab.castor.xml.XMLFieldHandler()
573 public java.lang.Object getValue(java.lang.Object object)
574 throws IllegalStateException
576 Setting target = (Setting) object;
577 if (!target.hasColourByLabel())
581 return (target.getColourByLabel() ? java.lang.Boolean.TRUE
582 : java.lang.Boolean.FALSE);
585 public void setValue(java.lang.Object object, java.lang.Object value)
586 throws IllegalStateException, IllegalArgumentException
590 Setting target = (Setting) object;
591 // if null, use delete method for optional primitives
594 target.deleteColourByLabel();
597 target.setColourByLabel(((java.lang.Boolean) value)
599 } catch (java.lang.Exception ex)
601 throw new IllegalStateException(ex.toString());
605 public java.lang.Object newInstance(java.lang.Object parent)
610 desc.setHandler(handler);
611 desc.setMultivalued(false);
612 addFieldDescriptor(desc);
614 // -- validation code for: _colourByLabel
615 fieldValidator = new org.exolab.castor.xml.FieldValidator();
617 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
618 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
619 fieldValidator.setValidator(typeValidator);
621 desc.setValidator(fieldValidator);
623 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
624 java.lang.Boolean.TYPE, "_autoScale", "autoScale",
625 org.exolab.castor.xml.NodeType.Attribute);
626 handler = new org.exolab.castor.xml.XMLFieldHandler()
628 public java.lang.Object getValue(java.lang.Object object)
629 throws IllegalStateException
631 Setting target = (Setting) object;
632 if (!target.hasAutoScale())
636 return (target.getAutoScale() ? java.lang.Boolean.TRUE
637 : java.lang.Boolean.FALSE);
640 public void setValue(java.lang.Object object, java.lang.Object value)
641 throws IllegalStateException, IllegalArgumentException
645 Setting target = (Setting) object;
646 // if null, use delete method for optional primitives
649 target.deleteAutoScale();
652 target.setAutoScale(((java.lang.Boolean) value).booleanValue());
653 } catch (java.lang.Exception ex)
655 throw new IllegalStateException(ex.toString());
659 public java.lang.Object newInstance(java.lang.Object parent)
664 desc.setHandler(handler);
665 desc.setMultivalued(false);
666 addFieldDescriptor(desc);
668 // -- validation code for: _autoScale
669 fieldValidator = new org.exolab.castor.xml.FieldValidator();
671 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
672 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
673 fieldValidator.setValidator(typeValidator);
675 desc.setValidator(fieldValidator);
676 // -- initialize element descriptors
685 * Method getAccessMode.
687 * @return the access mode specified for this class.
689 public org.exolab.castor.mapping.AccessMode getAccessMode()
695 * Method getIdentity.
697 * @return the identity field, null if this class has no identity.
699 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
701 return super.getIdentity();
705 * Method getJavaClass.
707 * @return the Java class represented by this descriptor.
709 public java.lang.Class getJavaClass()
711 return jalview.schemabinding.version2.Setting.class;
715 * Method getNameSpacePrefix.
717 * @return the namespace prefix to use when marshaling as XML.
719 public java.lang.String getNameSpacePrefix()
725 * Method getNameSpaceURI.
727 * @return the namespace URI used when marshaling and unmarshaling as XML.
729 public java.lang.String getNameSpaceURI()
735 * Method getValidator.
737 * @return a specific validator for the class described by this
740 public org.exolab.castor.xml.TypeValidator getValidator()
748 * @return the XML Name for the Class being described.
750 public java.lang.String getXMLName()
756 * Method isElementDefinition.
758 * @return true if XML schema definition of this Class is that of a global
759 * element or element with anonymous type definition.
761 public boolean isElementDefinition()
763 return _elementDefinition;