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.Sequence;
27 * Class SequenceDescriptor.
29 * @version $Revision$ $Date$
31 public class SequenceDescriptor extends
32 jalview.schemabinding.version2.descriptors.SequenceTypeDescriptor
35 // --------------------------/
36 // - Class/Member Variables -/
37 // --------------------------/
40 * Field _elementDefinition.
42 private boolean _elementDefinition;
47 private java.lang.String _nsPrefix;
52 private java.lang.String _nsURI;
57 private java.lang.String _xmlName;
63 public SequenceDescriptor()
66 setExtendsWithoutFlatten(new jalview.schemabinding.version2.descriptors.SequenceTypeDescriptor());
67 _nsURI = "www.vamsas.ac.uk/jalview/version2";
68 _xmlName = "Sequence";
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, "_dsseqid", "dsseqid",
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 Sequence target = (Sequence) object;
89 return target.getDsseqid();
92 public void setValue(java.lang.Object object, java.lang.Object value)
93 throws IllegalStateException, IllegalArgumentException
97 Sequence target = (Sequence) object;
98 target.setDsseqid((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: _dsseqid
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 jalview.schemabinding.version2.DBRef.class, "_DBRefList",
128 "DBRef", org.exolab.castor.xml.NodeType.Element);
129 handler = new org.exolab.castor.xml.XMLFieldHandler()
131 public java.lang.Object getValue(java.lang.Object object)
132 throws IllegalStateException
134 Sequence target = (Sequence) object;
135 return target.getDBRef();
138 public void setValue(java.lang.Object object, java.lang.Object value)
139 throws IllegalStateException, IllegalArgumentException
143 Sequence target = (Sequence) object;
144 target.addDBRef((jalview.schemabinding.version2.DBRef) value);
145 } catch (java.lang.Exception ex)
147 throw new IllegalStateException(ex.toString());
151 public void resetValue(Object object) throws IllegalStateException,
152 IllegalArgumentException
156 Sequence target = (Sequence) object;
157 target.removeAllDBRef();
158 } catch (java.lang.Exception ex)
160 throw new IllegalStateException(ex.toString());
164 public java.lang.Object newInstance(java.lang.Object parent)
166 return new jalview.schemabinding.version2.DBRef();
169 desc.setHandler(handler);
170 desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
171 desc.setMultivalued(true);
172 addFieldDescriptor(desc);
174 // -- validation code for: _DBRefList
175 fieldValidator = new org.exolab.castor.xml.FieldValidator();
176 fieldValidator.setMinOccurs(0);
179 desc.setValidator(fieldValidator);
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.Sequence.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;