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.Setting;
28 * Class SettingDescriptor.
30 * @version $Revision$ $Date$
32 public class SettingDescriptor 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 SettingDescriptor()
67 _nsURI = "www.jalview.org";
69 _elementDefinition = true;
70 org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
71 org.exolab.castor.mapping.FieldHandler handler = null;
72 org.exolab.castor.xml.FieldValidator fieldValidator = null;
73 // -- initialize attribute descriptors
76 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
77 java.lang.String.class, "_type", "type",
78 org.exolab.castor.xml.NodeType.Attribute);
79 desc.setImmutable(true);
80 handler = new org.exolab.castor.xml.XMLFieldHandler()
82 public java.lang.Object getValue(java.lang.Object object)
83 throws IllegalStateException
85 Setting target = (Setting) object;
86 return target.getType();
89 public void setValue(java.lang.Object object, java.lang.Object value)
90 throws IllegalStateException, IllegalArgumentException
94 Setting target = (Setting) object;
95 target.setType((java.lang.String) value);
96 } catch (java.lang.Exception ex)
98 throw new IllegalStateException(ex.toString());
102 public java.lang.Object newInstance(java.lang.Object parent)
107 desc.setHandler(handler);
108 desc.setRequired(true);
109 desc.setMultivalued(false);
110 addFieldDescriptor(desc);
112 // -- validation code for: _type
113 fieldValidator = new org.exolab.castor.xml.FieldValidator();
114 fieldValidator.setMinOccurs(1);
116 org.exolab.castor.xml.validators.StringValidator typeValidator;
117 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
118 fieldValidator.setValidator(typeValidator);
119 typeValidator.setWhiteSpace("preserve");
121 desc.setValidator(fieldValidator);
123 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
124 java.lang.Integer.TYPE, "_colour", "colour",
125 org.exolab.castor.xml.NodeType.Attribute);
126 handler = new org.exolab.castor.xml.XMLFieldHandler()
128 public java.lang.Object getValue(java.lang.Object object)
129 throws IllegalStateException
131 Setting target = (Setting) object;
132 if (!target.hasColour())
136 return new java.lang.Integer(target.getColour());
139 public void setValue(java.lang.Object object, java.lang.Object value)
140 throws IllegalStateException, IllegalArgumentException
144 Setting target = (Setting) object;
145 // ignore null values for non optional primitives
151 target.setColour(((java.lang.Integer) value).intValue());
152 } catch (java.lang.Exception ex)
154 throw new IllegalStateException(ex.toString());
158 public java.lang.Object newInstance(java.lang.Object parent)
163 desc.setHandler(handler);
164 desc.setRequired(true);
165 desc.setMultivalued(false);
166 addFieldDescriptor(desc);
168 // -- validation code for: _colour
169 fieldValidator = new org.exolab.castor.xml.FieldValidator();
170 fieldValidator.setMinOccurs(1);
172 org.exolab.castor.xml.validators.IntValidator typeValidator;
173 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
174 fieldValidator.setValidator(typeValidator);
175 typeValidator.setMinInclusive(-2147483648);
176 typeValidator.setMaxInclusive(2147483647);
178 desc.setValidator(fieldValidator);
180 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
181 java.lang.Boolean.TYPE, "_display", "display",
182 org.exolab.castor.xml.NodeType.Attribute);
183 handler = new org.exolab.castor.xml.XMLFieldHandler()
185 public java.lang.Object getValue(java.lang.Object object)
186 throws IllegalStateException
188 Setting target = (Setting) object;
189 if (!target.hasDisplay())
193 return (target.getDisplay() ? java.lang.Boolean.TRUE
194 : java.lang.Boolean.FALSE);
197 public void setValue(java.lang.Object object, java.lang.Object value)
198 throws IllegalStateException, IllegalArgumentException
202 Setting target = (Setting) object;
203 // ignore null values for non optional primitives
209 target.setDisplay(((java.lang.Boolean) value).booleanValue());
210 } catch (java.lang.Exception ex)
212 throw new IllegalStateException(ex.toString());
216 public java.lang.Object newInstance(java.lang.Object parent)
221 desc.setHandler(handler);
222 desc.setRequired(true);
223 desc.setMultivalued(false);
224 addFieldDescriptor(desc);
226 // -- validation code for: _display
227 fieldValidator = new org.exolab.castor.xml.FieldValidator();
228 fieldValidator.setMinOccurs(1);
230 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
231 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
232 fieldValidator.setValidator(typeValidator);
234 desc.setValidator(fieldValidator);
236 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
237 java.lang.Float.TYPE, "_order", "order",
238 org.exolab.castor.xml.NodeType.Attribute);
239 handler = new org.exolab.castor.xml.XMLFieldHandler()
241 public java.lang.Object getValue(java.lang.Object object)
242 throws IllegalStateException
244 Setting target = (Setting) object;
245 if (!target.hasOrder())
249 return new java.lang.Float(target.getOrder());
252 public void setValue(java.lang.Object object, java.lang.Object value)
253 throws IllegalStateException, IllegalArgumentException
257 Setting target = (Setting) object;
258 // if null, use delete method for optional primitives
261 target.deleteOrder();
264 target.setOrder(((java.lang.Float) value).floatValue());
265 } catch (java.lang.Exception ex)
267 throw new IllegalStateException(ex.toString());
271 public java.lang.Object newInstance(java.lang.Object parent)
276 desc.setHandler(handler);
277 desc.setMultivalued(false);
278 addFieldDescriptor(desc);
280 // -- validation code for: _order
281 fieldValidator = new org.exolab.castor.xml.FieldValidator();
283 org.exolab.castor.xml.validators.FloatValidator typeValidator;
284 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
285 fieldValidator.setValidator(typeValidator);
286 typeValidator.setMinInclusive((float) -3.4028235E38);
287 typeValidator.setMaxInclusive((float) 3.4028235E38);
289 desc.setValidator(fieldValidator);
291 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
292 java.lang.Integer.TYPE, "_mincolour", "mincolour",
293 org.exolab.castor.xml.NodeType.Attribute);
294 handler = new org.exolab.castor.xml.XMLFieldHandler()
296 public java.lang.Object getValue(java.lang.Object object)
297 throws IllegalStateException
299 Setting target = (Setting) object;
300 if (!target.hasMincolour())
304 return new java.lang.Integer(target.getMincolour());
307 public void setValue(java.lang.Object object, java.lang.Object value)
308 throws IllegalStateException, IllegalArgumentException
312 Setting target = (Setting) object;
313 // if null, use delete method for optional primitives
316 target.deleteMincolour();
319 target.setMincolour(((java.lang.Integer) value).intValue());
320 } catch (java.lang.Exception ex)
322 throw new IllegalStateException(ex.toString());
326 public java.lang.Object newInstance(java.lang.Object parent)
331 desc.setHandler(handler);
332 desc.setMultivalued(false);
333 addFieldDescriptor(desc);
335 // -- validation code for: _mincolour
336 fieldValidator = new org.exolab.castor.xml.FieldValidator();
338 org.exolab.castor.xml.validators.IntValidator typeValidator;
339 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
340 fieldValidator.setValidator(typeValidator);
341 typeValidator.setMinInclusive(-2147483648);
342 typeValidator.setMaxInclusive(2147483647);
344 desc.setValidator(fieldValidator);
346 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
347 java.lang.Float.TYPE, "_threshold", "threshold",
348 org.exolab.castor.xml.NodeType.Attribute);
349 handler = new org.exolab.castor.xml.XMLFieldHandler()
351 public java.lang.Object getValue(java.lang.Object object)
352 throws IllegalStateException
354 Setting target = (Setting) object;
355 if (!target.hasThreshold())
359 return new java.lang.Float(target.getThreshold());
362 public void setValue(java.lang.Object object, java.lang.Object value)
363 throws IllegalStateException, IllegalArgumentException
367 Setting target = (Setting) object;
368 // if null, use delete method for optional primitives
371 target.deleteThreshold();
374 target.setThreshold(((java.lang.Float) value).floatValue());
375 } catch (java.lang.Exception ex)
377 throw new IllegalStateException(ex.toString());
381 public java.lang.Object newInstance(java.lang.Object parent)
386 desc.setHandler(handler);
387 desc.setMultivalued(false);
388 addFieldDescriptor(desc);
390 // -- validation code for: _threshold
391 fieldValidator = new org.exolab.castor.xml.FieldValidator();
393 org.exolab.castor.xml.validators.FloatValidator typeValidator;
394 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
395 fieldValidator.setValidator(typeValidator);
396 typeValidator.setMinInclusive((float) -3.4028235E38);
397 typeValidator.setMaxInclusive((float) 3.4028235E38);
399 desc.setValidator(fieldValidator);
401 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
402 java.lang.Integer.TYPE, "_threshstate", "threshstate",
403 org.exolab.castor.xml.NodeType.Attribute);
404 handler = new org.exolab.castor.xml.XMLFieldHandler()
406 public java.lang.Object getValue(java.lang.Object object)
407 throws IllegalStateException
409 Setting target = (Setting) object;
410 if (!target.hasThreshstate())
414 return new java.lang.Integer(target.getThreshstate());
417 public void setValue(java.lang.Object object, java.lang.Object value)
418 throws IllegalStateException, IllegalArgumentException
422 Setting target = (Setting) object;
423 // if null, use delete method for optional primitives
426 target.deleteThreshstate();
429 target.setThreshstate(((java.lang.Integer) value).intValue());
430 } catch (java.lang.Exception ex)
432 throw new IllegalStateException(ex.toString());
436 public java.lang.Object newInstance(java.lang.Object parent)
441 desc.setHandler(handler);
442 desc.setMultivalued(false);
443 addFieldDescriptor(desc);
445 // -- validation code for: _threshstate
446 fieldValidator = new org.exolab.castor.xml.FieldValidator();
448 org.exolab.castor.xml.validators.IntValidator typeValidator;
449 typeValidator = new org.exolab.castor.xml.validators.IntValidator();
450 fieldValidator.setValidator(typeValidator);
451 typeValidator.setMinInclusive(-2147483648);
452 typeValidator.setMaxInclusive(2147483647);
454 desc.setValidator(fieldValidator);
456 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
457 java.lang.Float.TYPE, "_max", "max",
458 org.exolab.castor.xml.NodeType.Attribute);
459 handler = new org.exolab.castor.xml.XMLFieldHandler()
461 public java.lang.Object getValue(java.lang.Object object)
462 throws IllegalStateException
464 Setting target = (Setting) object;
465 if (!target.hasMax())
469 return new java.lang.Float(target.getMax());
472 public void setValue(java.lang.Object object, java.lang.Object value)
473 throws IllegalStateException, IllegalArgumentException
477 Setting target = (Setting) object;
478 // if null, use delete method for optional primitives
484 target.setMax(((java.lang.Float) value).floatValue());
485 } catch (java.lang.Exception ex)
487 throw new IllegalStateException(ex.toString());
491 public java.lang.Object newInstance(java.lang.Object parent)
496 desc.setHandler(handler);
497 desc.setMultivalued(false);
498 addFieldDescriptor(desc);
500 // -- validation code for: _max
501 fieldValidator = new org.exolab.castor.xml.FieldValidator();
503 org.exolab.castor.xml.validators.FloatValidator typeValidator;
504 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
505 fieldValidator.setValidator(typeValidator);
506 typeValidator.setMinInclusive((float) -3.4028235E38);
507 typeValidator.setMaxInclusive((float) 3.4028235E38);
509 desc.setValidator(fieldValidator);
511 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
512 java.lang.Float.TYPE, "_min", "min",
513 org.exolab.castor.xml.NodeType.Attribute);
514 handler = new org.exolab.castor.xml.XMLFieldHandler()
516 public java.lang.Object getValue(java.lang.Object object)
517 throws IllegalStateException
519 Setting target = (Setting) object;
520 if (!target.hasMin())
524 return new java.lang.Float(target.getMin());
527 public void setValue(java.lang.Object object, java.lang.Object value)
528 throws IllegalStateException, IllegalArgumentException
532 Setting target = (Setting) object;
533 // if null, use delete method for optional primitives
539 target.setMin(((java.lang.Float) value).floatValue());
540 } catch (java.lang.Exception ex)
542 throw new IllegalStateException(ex.toString());
546 public java.lang.Object newInstance(java.lang.Object parent)
551 desc.setHandler(handler);
552 desc.setMultivalued(false);
553 addFieldDescriptor(desc);
555 // -- validation code for: _min
556 fieldValidator = new org.exolab.castor.xml.FieldValidator();
558 org.exolab.castor.xml.validators.FloatValidator typeValidator;
559 typeValidator = new org.exolab.castor.xml.validators.FloatValidator();
560 fieldValidator.setValidator(typeValidator);
561 typeValidator.setMinInclusive((float) -3.4028235E38);
562 typeValidator.setMaxInclusive((float) 3.4028235E38);
564 desc.setValidator(fieldValidator);
566 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
567 java.lang.Boolean.TYPE, "_colourByLabel", "colourByLabel",
568 org.exolab.castor.xml.NodeType.Attribute);
569 handler = new org.exolab.castor.xml.XMLFieldHandler()
571 public java.lang.Object getValue(java.lang.Object object)
572 throws IllegalStateException
574 Setting target = (Setting) object;
575 if (!target.hasColourByLabel())
579 return (target.getColourByLabel() ? java.lang.Boolean.TRUE
580 : java.lang.Boolean.FALSE);
583 public void setValue(java.lang.Object object, java.lang.Object value)
584 throws IllegalStateException, IllegalArgumentException
588 Setting target = (Setting) object;
589 // if null, use delete method for optional primitives
592 target.deleteColourByLabel();
595 target.setColourByLabel(((java.lang.Boolean) value)
597 } catch (java.lang.Exception ex)
599 throw new IllegalStateException(ex.toString());
603 public java.lang.Object newInstance(java.lang.Object parent)
608 desc.setHandler(handler);
609 desc.setMultivalued(false);
610 addFieldDescriptor(desc);
612 // -- validation code for: _colourByLabel
613 fieldValidator = new org.exolab.castor.xml.FieldValidator();
615 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
616 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
617 fieldValidator.setValidator(typeValidator);
619 desc.setValidator(fieldValidator);
621 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
622 java.lang.Boolean.TYPE, "_autoScale", "autoScale",
623 org.exolab.castor.xml.NodeType.Attribute);
624 handler = new org.exolab.castor.xml.XMLFieldHandler()
626 public java.lang.Object getValue(java.lang.Object object)
627 throws IllegalStateException
629 Setting target = (Setting) object;
630 if (!target.hasAutoScale())
634 return (target.getAutoScale() ? java.lang.Boolean.TRUE
635 : java.lang.Boolean.FALSE);
638 public void setValue(java.lang.Object object, java.lang.Object value)
639 throws IllegalStateException, IllegalArgumentException
643 Setting target = (Setting) object;
644 // if null, use delete method for optional primitives
647 target.deleteAutoScale();
650 target.setAutoScale(((java.lang.Boolean) value).booleanValue());
651 } catch (java.lang.Exception ex)
653 throw new IllegalStateException(ex.toString());
657 public java.lang.Object newInstance(java.lang.Object parent)
662 desc.setHandler(handler);
663 desc.setMultivalued(false);
664 addFieldDescriptor(desc);
666 // -- validation code for: _autoScale
667 fieldValidator = new org.exolab.castor.xml.FieldValidator();
669 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
670 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
671 fieldValidator.setValidator(typeValidator);
673 desc.setValidator(fieldValidator);
674 // -- initialize element descriptors
683 * Method getAccessMode.
685 * @return the access mode specified for this class.
687 public org.exolab.castor.mapping.AccessMode getAccessMode()
693 * Method getIdentity.
695 * @return the identity field, null if this class has no identity.
697 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
699 return super.getIdentity();
703 * Method getJavaClass.
705 * @return the Java class represented by this descriptor.
707 public java.lang.Class getJavaClass()
709 return jalview.schemabinding.version2.Setting.class;
713 * Method getNameSpacePrefix.
715 * @return the namespace prefix to use when marshaling as XML.
717 public java.lang.String getNameSpacePrefix()
723 * Method getNameSpaceURI.
725 * @return the namespace URI used when marshaling and unmarshaling as XML.
727 public java.lang.String getNameSpaceURI()
733 * Method getValidator.
735 * @return a specific validator for the class described by this
738 public org.exolab.castor.xml.TypeValidator getValidator()
746 * @return the XML Name for the Class being described.
748 public java.lang.String getXMLName()
754 * Method isElementDefinition.
756 * @return true if XML schema definition of this Class is that of a global
757 * element or element with anonymous type definition.
759 public boolean isElementDefinition()
761 return _elementDefinition;