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.Colour;
25 import jalview.schemabinding.version2.JalviewUserColours;
28 * Class JalviewUserColoursDescriptor.
30 * @version $Revision$ $Date$
32 public class JalviewUserColoursDescriptor 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 JalviewUserColoursDescriptor()
67 _nsURI = "www.jalview.org/colours";
68 _xmlName = "JalviewUserColours";
69 _elementDefinition = false;
71 // -- set grouping compositor
72 setCompositorAsSequence();
73 org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
74 org.exolab.castor.mapping.FieldHandler handler = null;
75 org.exolab.castor.xml.FieldValidator fieldValidator = null;
76 // -- initialize attribute descriptors
79 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
80 java.lang.String.class, "_schemeName", "schemeName",
81 org.exolab.castor.xml.NodeType.Attribute);
82 desc.setImmutable(true);
83 handler = new org.exolab.castor.xml.XMLFieldHandler()
85 public java.lang.Object getValue(java.lang.Object object)
86 throws IllegalStateException
88 JalviewUserColours target = (JalviewUserColours) object;
89 return target.getSchemeName();
92 public void setValue(java.lang.Object object, java.lang.Object value)
93 throws IllegalStateException, IllegalArgumentException
97 JalviewUserColours target = (JalviewUserColours) object;
98 target.setSchemeName((java.lang.String) value);
99 } catch (java.lang.Exception ex)
101 throw new IllegalStateException(ex.toString());
105 public java.lang.Object newInstance(java.lang.Object parent)
110 desc.setHandler(handler);
111 desc.setMultivalued(false);
112 addFieldDescriptor(desc);
114 // -- validation code for: _schemeName
115 fieldValidator = new org.exolab.castor.xml.FieldValidator();
117 org.exolab.castor.xml.validators.StringValidator typeValidator;
118 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
119 fieldValidator.setValidator(typeValidator);
120 typeValidator.setWhiteSpace("preserve");
122 desc.setValidator(fieldValidator);
123 // -- initialize element descriptors
126 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
127 java.lang.String.class, "_version", "Version",
128 org.exolab.castor.xml.NodeType.Element);
129 desc.setImmutable(true);
130 handler = new org.exolab.castor.xml.XMLFieldHandler()
132 public java.lang.Object getValue(java.lang.Object object)
133 throws IllegalStateException
135 JalviewUserColours target = (JalviewUserColours) object;
136 return target.getVersion();
139 public void setValue(java.lang.Object object, java.lang.Object value)
140 throws IllegalStateException, IllegalArgumentException
144 JalviewUserColours target = (JalviewUserColours) object;
145 target.setVersion((java.lang.String) value);
146 } catch (java.lang.Exception ex)
148 throw new IllegalStateException(ex.toString());
152 public java.lang.Object newInstance(java.lang.Object parent)
157 desc.setHandler(handler);
158 desc.setMultivalued(false);
159 addFieldDescriptor(desc);
161 // -- validation code for: _version
162 fieldValidator = new org.exolab.castor.xml.FieldValidator();
164 org.exolab.castor.xml.validators.StringValidator typeValidator;
165 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
166 fieldValidator.setValidator(typeValidator);
167 typeValidator.setWhiteSpace("preserve");
169 desc.setValidator(fieldValidator);
171 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
172 Colour.class, "_colourList", "colour",
173 org.exolab.castor.xml.NodeType.Element);
174 handler = new org.exolab.castor.xml.XMLFieldHandler()
176 public java.lang.Object getValue(java.lang.Object object)
177 throws IllegalStateException
179 JalviewUserColours target = (JalviewUserColours) object;
180 return target.getColour();
183 public void setValue(java.lang.Object object, java.lang.Object value)
184 throws IllegalStateException, IllegalArgumentException
188 JalviewUserColours target = (JalviewUserColours) object;
189 target.addColour((Colour) value);
190 } catch (java.lang.Exception ex)
192 throw new IllegalStateException(ex.toString());
196 public void resetValue(Object object) throws IllegalStateException,
197 IllegalArgumentException
201 JalviewUserColours target = (JalviewUserColours) object;
202 target.removeAllColour();
203 } catch (java.lang.Exception ex)
205 throw new IllegalStateException(ex.toString());
209 public java.lang.Object newInstance(java.lang.Object parent)
214 desc.setHandler(handler);
215 desc.setMultivalued(true);
216 addFieldDescriptor(desc);
218 // -- validation code for: _colourList
219 fieldValidator = new org.exolab.castor.xml.FieldValidator();
220 fieldValidator.setMinOccurs(0);
223 desc.setValidator(fieldValidator);
231 * Method getAccessMode.
233 * @return the access mode specified for this class.
235 public org.exolab.castor.mapping.AccessMode getAccessMode()
241 * Method getIdentity.
243 * @return the identity field, null if this class has no identity.
245 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
247 return super.getIdentity();
251 * Method getJavaClass.
253 * @return the Java class represented by this descriptor.
255 public java.lang.Class getJavaClass()
257 return jalview.schemabinding.version2.JalviewUserColours.class;
261 * Method getNameSpacePrefix.
263 * @return the namespace prefix to use when marshaling as XML.
265 public java.lang.String getNameSpacePrefix()
271 * Method getNameSpaceURI.
273 * @return the namespace URI used when marshaling and unmarshaling as XML.
275 public java.lang.String getNameSpaceURI()
281 * Method getValidator.
283 * @return a specific validator for the class described by this
286 public org.exolab.castor.xml.TypeValidator getValidator()
294 * @return the XML Name for the Class being described.
296 public java.lang.String getXMLName()
302 * Method isElementDefinition.
304 * @return true if XML schema definition of this Class is that of a global
305 * element or element with anonymous type definition.
307 public boolean isElementDefinition()
309 return _elementDefinition;