2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
\r
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.schemabinding.version2;
\r
20 //---------------------------------/
\r
21 //- Imported classes and packages -/
\r
22 //---------------------------------/
\r
24 import org.exolab.castor.xml.Marshaller;
\r
25 import org.exolab.castor.xml.Unmarshaller;
\r
30 * @version $Revision$ $Date$
\r
32 public class Sequence extends jalview.schemabinding.version2.SequenceType
\r
33 implements java.io.Serializable
\r
36 // --------------------------/
\r
37 // - Class/Member Variables -/
\r
38 // --------------------------/
\r
41 * dataset sequence id for this sequence. Will be created as union of
\r
45 private java.lang.String _dsseqid;
\r
50 private java.util.Vector _DBRefList;
\r
52 // ----------------/
\r
53 // - Constructors -/
\r
54 // ----------------/
\r
59 this._DBRefList = new java.util.Vector();
\r
70 * @throws java.lang.IndexOutOfBoundsException
\r
71 * if the index given is outside the bounds of the collection
\r
73 public void addDBRef(final jalview.schemabinding.version2.DBRef vDBRef)
\r
74 throws java.lang.IndexOutOfBoundsException
\r
76 this._DBRefList.addElement(vDBRef);
\r
84 * @throws java.lang.IndexOutOfBoundsException
\r
85 * if the index given is outside the bounds of the collection
\r
87 public void addDBRef(final int index,
\r
88 final jalview.schemabinding.version2.DBRef vDBRef)
\r
89 throws java.lang.IndexOutOfBoundsException
\r
91 this._DBRefList.add(index, vDBRef);
\r
95 * Method enumerateDBRef.
\r
97 * @return an Enumeration over all jalview.schemabinding.version2.DBRef
\r
100 public java.util.Enumeration enumerateDBRef()
\r
102 return this._DBRefList.elements();
\r
109 * @throws java.lang.IndexOutOfBoundsException
\r
110 * if the index given is outside the bounds of the collection
\r
111 * @return the value of the jalview.schemabinding.version2.DBRef at the given
\r
114 public jalview.schemabinding.version2.DBRef getDBRef(final int index)
\r
115 throws java.lang.IndexOutOfBoundsException
\r
117 // check bounds for index
\r
118 if (index < 0 || index >= this._DBRefList.size())
\r
120 throw new IndexOutOfBoundsException("getDBRef: Index value '" + index
\r
121 + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
\r
124 return (jalview.schemabinding.version2.DBRef) _DBRefList.get(index);
\r
128 * Method getDBRef.Returns the contents of the collection in an Array.
\r
130 * Note: Just in case the collection contents are changing in another thread,
\r
131 * we pass a 0-length Array of the correct type into the API call. This way we
\r
132 * <i>know</i> that the Array returned is of exactly the correct length.
\r
134 * @return this collection as an Array
\r
136 public jalview.schemabinding.version2.DBRef[] getDBRef()
\r
138 jalview.schemabinding.version2.DBRef[] array = new jalview.schemabinding.version2.DBRef[0];
\r
139 return (jalview.schemabinding.version2.DBRef[]) this._DBRefList
\r
144 * Method getDBRefCount.
\r
146 * @return the size of this collection
\r
148 public int getDBRefCount()
\r
150 return this._DBRefList.size();
\r
154 * Returns the value of field 'dsseqid'. The field 'dsseqid' has the following
\r
155 * description: dataset sequence id for this sequence. Will be created as
\r
156 * union of sequences.
\r
159 * @return the value of field 'Dsseqid'.
\r
161 public java.lang.String getDsseqid()
\r
163 return this._dsseqid;
\r
169 * @return true if this object is valid according to the schema
\r
171 public boolean isValid()
\r
176 } catch (org.exolab.castor.xml.ValidationException vex)
\r
187 * @throws org.exolab.castor.xml.MarshalException
\r
188 * if object is null or if any SAXException is thrown during
\r
190 * @throws org.exolab.castor.xml.ValidationException
\r
191 * if this object is an invalid instance according to the schema
\r
193 public void marshal(final java.io.Writer out)
\r
194 throws org.exolab.castor.xml.MarshalException,
\r
195 org.exolab.castor.xml.ValidationException
\r
197 Marshaller.marshal(this, out);
\r
204 * @throws java.io.IOException
\r
205 * if an IOException occurs during marshaling
\r
206 * @throws org.exolab.castor.xml.ValidationException
\r
207 * if this object is an invalid instance according to the schema
\r
208 * @throws org.exolab.castor.xml.MarshalException
\r
209 * if object is null or if any SAXException is thrown during
\r
212 public void marshal(final org.xml.sax.ContentHandler handler)
\r
213 throws java.io.IOException,
\r
214 org.exolab.castor.xml.MarshalException,
\r
215 org.exolab.castor.xml.ValidationException
\r
217 Marshaller.marshal(this, handler);
\r
222 public void removeAllDBRef()
\r
224 this._DBRefList.clear();
\r
228 * Method removeDBRef.
\r
231 * @return true if the object was removed from the collection.
\r
233 public boolean removeDBRef(
\r
234 final jalview.schemabinding.version2.DBRef vDBRef)
\r
236 boolean removed = _DBRefList.remove(vDBRef);
\r
241 * Method removeDBRefAt.
\r
244 * @return the element removed from the collection
\r
246 public jalview.schemabinding.version2.DBRef removeDBRefAt(final int index)
\r
248 java.lang.Object obj = this._DBRefList.remove(index);
\r
249 return (jalview.schemabinding.version2.DBRef) obj;
\r
257 * @throws java.lang.IndexOutOfBoundsException
\r
258 * if the index given is outside the bounds of the collection
\r
260 public void setDBRef(final int index,
\r
261 final jalview.schemabinding.version2.DBRef vDBRef)
\r
262 throws java.lang.IndexOutOfBoundsException
\r
264 // check bounds for index
\r
265 if (index < 0 || index >= this._DBRefList.size())
\r
267 throw new IndexOutOfBoundsException("setDBRef: Index value '" + index
\r
268 + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
\r
271 this._DBRefList.set(index, vDBRef);
\r
277 * @param vDBRefArray
\r
279 public void setDBRef(
\r
280 final jalview.schemabinding.version2.DBRef[] vDBRefArray)
\r
283 _DBRefList.clear();
\r
285 for (int i = 0; i < vDBRefArray.length; i++)
\r
287 this._DBRefList.add(vDBRefArray[i]);
\r
292 * Sets the value of field 'dsseqid'. The field 'dsseqid' has the following
\r
293 * description: dataset sequence id for this sequence. Will be created as
\r
294 * union of sequences.
\r
298 * the value of field 'dsseqid'.
\r
300 public void setDsseqid(final java.lang.String dsseqid)
\r
302 this._dsseqid = dsseqid;
\r
306 * Method unmarshal.
\r
309 * @throws org.exolab.castor.xml.MarshalException
\r
310 * if object is null or if any SAXException is thrown during
\r
312 * @throws org.exolab.castor.xml.ValidationException
\r
313 * if this object is an invalid instance according to the schema
\r
314 * @return the unmarshaled jalview.schemabinding.version2.SequenceType
\r
316 public static jalview.schemabinding.version2.SequenceType unmarshal(
\r
317 final java.io.Reader reader)
\r
318 throws org.exolab.castor.xml.MarshalException,
\r
319 org.exolab.castor.xml.ValidationException
\r
321 return (jalview.schemabinding.version2.SequenceType) Unmarshaller
\r
322 .unmarshal(jalview.schemabinding.version2.Sequence.class,
\r
329 * @throws org.exolab.castor.xml.ValidationException
\r
330 * if this object is an invalid instance according to the schema
\r
332 public void validate() throws org.exolab.castor.xml.ValidationException
\r
334 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
335 validator.validate(this);
\r