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.DBRef;
28 * Class DBRefDescriptor.
30 * @version $Revision$ $Date$
32 public class DBRefDescriptor 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 DBRefDescriptor()
67 _nsURI = "www.vamsas.ac.uk/jalview/version2";
69 _elementDefinition = true;
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, "_source", "source",
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 DBRef target = (DBRef) object;
89 return target.getSource();
92 public void setValue(java.lang.Object object, java.lang.Object value)
93 throws IllegalStateException, IllegalArgumentException
97 DBRef target = (DBRef) object;
98 target.setSource((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: _source
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);
124 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
125 java.lang.String.class, "_version", "version",
126 org.exolab.castor.xml.NodeType.Attribute);
127 desc.setImmutable(true);
128 handler = new org.exolab.castor.xml.XMLFieldHandler()
130 public java.lang.Object getValue(java.lang.Object object)
131 throws IllegalStateException
133 DBRef target = (DBRef) object;
134 return target.getVersion();
137 public void setValue(java.lang.Object object, java.lang.Object value)
138 throws IllegalStateException, IllegalArgumentException
142 DBRef target = (DBRef) object;
143 target.setVersion((java.lang.String) value);
144 } catch (java.lang.Exception ex)
146 throw new IllegalStateException(ex.toString());
150 public java.lang.Object newInstance(java.lang.Object parent)
155 desc.setHandler(handler);
156 desc.setMultivalued(false);
157 addFieldDescriptor(desc);
159 // -- validation code for: _version
160 fieldValidator = new org.exolab.castor.xml.FieldValidator();
162 org.exolab.castor.xml.validators.StringValidator typeValidator;
163 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
164 fieldValidator.setValidator(typeValidator);
165 typeValidator.setWhiteSpace("preserve");
167 desc.setValidator(fieldValidator);
169 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
170 java.lang.String.class, "_accessionId", "accessionId",
171 org.exolab.castor.xml.NodeType.Attribute);
172 desc.setImmutable(true);
173 handler = new org.exolab.castor.xml.XMLFieldHandler()
175 public java.lang.Object getValue(java.lang.Object object)
176 throws IllegalStateException
178 DBRef target = (DBRef) object;
179 return target.getAccessionId();
182 public void setValue(java.lang.Object object, java.lang.Object value)
183 throws IllegalStateException, IllegalArgumentException
187 DBRef target = (DBRef) object;
188 target.setAccessionId((java.lang.String) value);
189 } catch (java.lang.Exception ex)
191 throw new IllegalStateException(ex.toString());
195 public java.lang.Object newInstance(java.lang.Object parent)
200 desc.setHandler(handler);
201 desc.setMultivalued(false);
202 addFieldDescriptor(desc);
204 // -- validation code for: _accessionId
205 fieldValidator = new org.exolab.castor.xml.FieldValidator();
207 org.exolab.castor.xml.validators.StringValidator typeValidator;
208 typeValidator = new org.exolab.castor.xml.validators.StringValidator();
209 fieldValidator.setValidator(typeValidator);
210 typeValidator.setWhiteSpace("preserve");
212 desc.setValidator(fieldValidator);
213 // -- initialize element descriptors
216 desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
217 jalview.schemabinding.version2.Mapping.class, "_mapping",
218 "Mapping", org.exolab.castor.xml.NodeType.Element);
219 handler = new org.exolab.castor.xml.XMLFieldHandler()
221 public java.lang.Object getValue(java.lang.Object object)
222 throws IllegalStateException
224 DBRef target = (DBRef) object;
225 return target.getMapping();
228 public void setValue(java.lang.Object object, java.lang.Object value)
229 throws IllegalStateException, IllegalArgumentException
233 DBRef target = (DBRef) object;
234 target.setMapping((jalview.schemabinding.version2.Mapping) value);
235 } catch (java.lang.Exception ex)
237 throw new IllegalStateException(ex.toString());
241 public java.lang.Object newInstance(java.lang.Object parent)
243 return new jalview.schemabinding.version2.Mapping();
246 desc.setHandler(handler);
247 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
248 desc.setMultivalued(false);
249 addFieldDescriptor(desc);
251 // -- validation code for: _mapping
252 fieldValidator = new org.exolab.castor.xml.FieldValidator();
255 desc.setValidator(fieldValidator);
263 * Method getAccessMode.
265 * @return the access mode specified for this class.
267 public org.exolab.castor.mapping.AccessMode getAccessMode()
273 * Method getIdentity.
275 * @return the identity field, null if this class has no identity.
277 public org.exolab.castor.mapping.FieldDescriptor getIdentity()
279 return super.getIdentity();
283 * Method getJavaClass.
285 * @return the Java class represented by this descriptor.
287 public java.lang.Class getJavaClass()
289 return jalview.schemabinding.version2.DBRef.class;
293 * Method getNameSpacePrefix.
295 * @return the namespace prefix to use when marshaling as XML.
297 public java.lang.String getNameSpacePrefix()
303 * Method getNameSpaceURI.
305 * @return the namespace URI used when marshaling and unmarshaling as XML.
307 public java.lang.String getNameSpaceURI()
313 * Method getValidator.
315 * @return a specific validator for the class described by this
318 public org.exolab.castor.xml.TypeValidator getValidator()
326 * @return the XML Name for the Class being described.
328 public java.lang.String getXMLName()
334 * Method isElementDefinition.
336 * @return true if XML schema definition of this Class is that of a global
337 * element or element with anonymous type definition.
339 public boolean isElementDefinition()
341 return _elementDefinition;