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.Group;
28 * Class GroupDescriptor.
30 * @version $Revision$ $Date$
32 public class GroupDescriptor 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 GroupDescriptor()
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, "_name", "name",
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 Group target = (Group) object;
86 return target.getName();
89 public void setValue(java.lang.Object object, java.lang.Object value)
90 throws IllegalStateException, IllegalArgumentException
94 Group target = (Group) object;
95 target.setName((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: _name
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.Boolean.TYPE, "_display", "display",
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 Group target = (Group) object;
132 if (!target.hasDisplay())
136 return (target.getDisplay() ? java.lang.Boolean.TRUE
137 : java.lang.Boolean.FALSE);
140 public void setValue(java.lang.Object object, java.lang.Object value)
141 throws IllegalStateException, IllegalArgumentException
145 Group target = (Group) object;
146 // ignore null values for non optional primitives
152 target.setDisplay(((java.lang.Boolean) value).booleanValue());
153 } catch (java.lang.Exception ex)
155 throw new IllegalStateException(ex.toString());
159 public java.lang.Object newInstance(java.lang.Object parent)
164 desc.setHandler(handler);
165 desc.setRequired(true);
166 desc.setMultivalued(false);
167 addFieldDescriptor(desc);
169 // -- validation code for: _display
170 fieldValidator = new org.exolab.castor.xml.FieldValidator();
171 fieldValidator.setMinOccurs(1);
173 org.exolab.castor.xml.validators.BooleanValidator typeValidator;
174 typeValidator = new org.exolab.castor.xml.validators.BooleanValidator();
175 fieldValidator.setValidator(typeValidator);
177 desc.setValidator(fieldValidator);
178 // -- initialize element descriptors
187 * Method getAccessMode.
189 * @return the access mode specified for this class.
191 public org.exolab.castor.mapping.AccessMode getAccessMode()
197 * Method getIdentity.
199 * @return the identity field, null if this class has no identity.
201 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
203 return super.getIdentity();
207 * Method getJavaClass.
209 * @return the Java class represented by this descriptor.
211 public java.lang.Class getJavaClass()
213 return jalview.schemabinding.version2.Group.class;
217 * Method getNameSpacePrefix.
219 * @return the namespace prefix to use when marshaling as XML.
221 public java.lang.String getNameSpacePrefix()
227 * Method getNameSpaceURI.
229 * @return the namespace URI used when marshaling and unmarshaling as XML.
231 public java.lang.String getNameSpaceURI()
237 * Method getValidator.
239 * @return a specific validator for the class described by this
242 public org.exolab.castor.xml.TypeValidator getValidator()
250 * @return the XML Name for the Class being described.
252 public java.lang.String getXMLName()
258 * Method isElementDefinition.
260 * @return true if XML schema definition of this Class is that of a global
261 * element or element with anonymous type definition.
263 public boolean isElementDefinition()
265 return _elementDefinition;