e233cccc2bce93375e183177090d188589a17d40
[jalview.git] / src / jalview / schemabinding / version2 / descriptors / SequenceDescriptor.java
1 /*
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
4  * 
5  * This file is part of Jalview.
6  * 
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.
10  *  
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.
15  * 
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  */
18 package jalview.schemabinding.version2.descriptors;
19
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
23
24 import jalview.schemabinding.version2.Sequence;
25
26 /**
27  * Class SequenceDescriptor.
28  * 
29  * @version $Revision$ $Date$
30  */
31 public class SequenceDescriptor extends
32         jalview.schemabinding.version2.descriptors.SequenceTypeDescriptor
33 {
34
35   // --------------------------/
36   // - Class/Member Variables -/
37   // --------------------------/
38
39   /**
40    * Field _elementDefinition.
41    */
42   private boolean _elementDefinition;
43
44   /**
45    * Field _nsPrefix.
46    */
47   private java.lang.String _nsPrefix;
48
49   /**
50    * Field _nsURI.
51    */
52   private java.lang.String _nsURI;
53
54   /**
55    * Field _xmlName.
56    */
57   private java.lang.String _xmlName;
58
59   // ----------------/
60   // - Constructors -/
61   // ----------------/
62
63   public SequenceDescriptor()
64   {
65     super();
66     setExtendsWithoutFlatten(new jalview.schemabinding.version2.descriptors.SequenceTypeDescriptor());
67     _nsURI = "www.vamsas.ac.uk/jalview/version2";
68     _xmlName = "Sequence";
69     _elementDefinition = true;
70
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
77
78     // -- _dsseqid
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()
84     {
85       public java.lang.Object getValue(java.lang.Object object)
86               throws IllegalStateException
87       {
88         Sequence target = (Sequence) object;
89         return target.getDsseqid();
90       }
91
92       public void setValue(java.lang.Object object, java.lang.Object value)
93               throws IllegalStateException, IllegalArgumentException
94       {
95         try
96         {
97           Sequence target = (Sequence) object;
98           target.setDsseqid((java.lang.String) value);
99         } catch (java.lang.Exception ex)
100         {
101           throw new IllegalStateException(ex.toString());
102         }
103       }
104
105       public java.lang.Object newInstance(java.lang.Object parent)
106       {
107         return null;
108       }
109     };
110     desc.setHandler(handler);
111     desc.setMultivalued(false);
112     addFieldDescriptor(desc);
113
114     // -- validation code for: _dsseqid
115     fieldValidator = new org.exolab.castor.xml.FieldValidator();
116     { // -- local scope
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");
121     }
122     desc.setValidator(fieldValidator);
123     // -- initialize element descriptors
124
125     // -- _DBRefList
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()
130     {
131       public java.lang.Object getValue(java.lang.Object object)
132               throws IllegalStateException
133       {
134         Sequence target = (Sequence) object;
135         return target.getDBRef();
136       }
137
138       public void setValue(java.lang.Object object, java.lang.Object value)
139               throws IllegalStateException, IllegalArgumentException
140       {
141         try
142         {
143           Sequence target = (Sequence) object;
144           target.addDBRef((jalview.schemabinding.version2.DBRef) value);
145         } catch (java.lang.Exception ex)
146         {
147           throw new IllegalStateException(ex.toString());
148         }
149       }
150
151       public void resetValue(Object object) throws IllegalStateException,
152               IllegalArgumentException
153       {
154         try
155         {
156           Sequence target = (Sequence) object;
157           target.removeAllDBRef();
158         } catch (java.lang.Exception ex)
159         {
160           throw new IllegalStateException(ex.toString());
161         }
162       }
163
164       public java.lang.Object newInstance(java.lang.Object parent)
165       {
166         return new jalview.schemabinding.version2.DBRef();
167       }
168     };
169     desc.setHandler(handler);
170     desc.setNameSpaceURI("www.vamsas.ac.uk/jalview/version2");
171     desc.setMultivalued(true);
172     addFieldDescriptor(desc);
173
174     // -- validation code for: _DBRefList
175     fieldValidator = new org.exolab.castor.xml.FieldValidator();
176     fieldValidator.setMinOccurs(0);
177     { // -- local scope
178     }
179     desc.setValidator(fieldValidator);
180   }
181
182   // -----------/
183   // - Methods -/
184   // -----------/
185
186   /**
187    * Method getAccessMode.
188    * 
189    * @return the access mode specified for this class.
190    */
191   public org.exolab.castor.mapping.AccessMode getAccessMode()
192   {
193     return null;
194   }
195
196   /**
197    * Method getIdentity.
198    * 
199    * @return the identity field, null if this class has no identity.
200    */
201   public org.exolab.castor.mapping.FieldDescriptor getIdentity()
202   {
203     return super.getIdentity();
204   }
205
206   /**
207    * Method getJavaClass.
208    * 
209    * @return the Java class represented by this descriptor.
210    */
211   public java.lang.Class getJavaClass()
212   {
213     return jalview.schemabinding.version2.Sequence.class;
214   }
215
216   /**
217    * Method getNameSpacePrefix.
218    * 
219    * @return the namespace prefix to use when marshaling as XML.
220    */
221   public java.lang.String getNameSpacePrefix()
222   {
223     return _nsPrefix;
224   }
225
226   /**
227    * Method getNameSpaceURI.
228    * 
229    * @return the namespace URI used when marshaling and unmarshaling as XML.
230    */
231   public java.lang.String getNameSpaceURI()
232   {
233     return _nsURI;
234   }
235
236   /**
237    * Method getValidator.
238    * 
239    * @return a specific validator for the class described by this
240    *         ClassDescriptor.
241    */
242   public org.exolab.castor.xml.TypeValidator getValidator()
243   {
244     return this;
245   }
246
247   /**
248    * Method getXMLName.
249    * 
250    * @return the XML Name for the Class being described.
251    */
252   public java.lang.String getXMLName()
253   {
254     return _xmlName;
255   }
256
257   /**
258    * Method isElementDefinition.
259    * 
260    * @return true if XML schema definition of this Class is that of a global
261    *         element or element with anonymous type definition.
262    */
263   public boolean isElementDefinition()
264   {
265     return _elementDefinition;
266   }
267
268 }