2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
\r
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.schemabinding.version2;
\r
21 // ---------------------------------/
\r
22 // - Imported classes and packages -/
\r
23 // ---------------------------------/
\r
25 import org.exolab.castor.xml.Marshaller;
\r
26 import org.exolab.castor.xml.Unmarshaller;
\r
31 * @version $Revision$ $Date$
\r
33 public class Sequence extends jalview.schemabinding.version2.SequenceType
\r
34 implements java.io.Serializable
\r
37 // --------------------------/
\r
38 // - Class/Member Variables -/
\r
39 // --------------------------/
\r
42 * dataset sequence id for this sequence. Will be created as union of
\r
46 private java.lang.String _dsseqid;
\r
51 private java.util.Vector _DBRefList;
\r
53 // ----------------/
\r
54 // - Constructors -/
\r
55 // ----------------/
\r
60 this._DBRefList = new java.util.Vector();
\r
71 * @throws java.lang.IndexOutOfBoundsException
\r
72 * if the index given is outside the bounds of the collection
\r
74 public void addDBRef(final jalview.schemabinding.version2.DBRef vDBRef)
\r
75 throws java.lang.IndexOutOfBoundsException
\r
77 this._DBRefList.addElement(vDBRef);
\r
85 * @throws java.lang.IndexOutOfBoundsException
\r
86 * if the index given is outside the bounds of the collection
\r
88 public void addDBRef(final int index,
\r
89 final jalview.schemabinding.version2.DBRef vDBRef)
\r
90 throws java.lang.IndexOutOfBoundsException
\r
92 this._DBRefList.add(index, vDBRef);
\r
96 * Method enumerateDBRef.
\r
98 * @return an Enumeration over all jalview.schemabinding.version2.DBRef
\r
101 public java.util.Enumeration enumerateDBRef()
\r
103 return this._DBRefList.elements();
\r
110 * @throws java.lang.IndexOutOfBoundsException
\r
111 * if the index given is outside the bounds of the collection
\r
112 * @return the value of the jalview.schemabinding.version2.DBRef at the given
\r
115 public jalview.schemabinding.version2.DBRef getDBRef(final int index)
\r
116 throws java.lang.IndexOutOfBoundsException
\r
118 // check bounds for index
\r
119 if (index < 0 || index >= this._DBRefList.size())
\r
121 throw new IndexOutOfBoundsException("getDBRef: Index value '" + index
\r
122 + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
\r
125 return (jalview.schemabinding.version2.DBRef) _DBRefList.get(index);
\r
129 * Method getDBRef.Returns the contents of the collection in an Array.
\r
131 * Note: Just in case the collection contents are changing in another thread,
\r
132 * we pass a 0-length Array of the correct type into the API call. This way we
\r
133 * <i>know</i> that the Array returned is of exactly the correct length.
\r
135 * @return this collection as an Array
\r
137 public jalview.schemabinding.version2.DBRef[] getDBRef()
\r
139 jalview.schemabinding.version2.DBRef[] array = new jalview.schemabinding.version2.DBRef[0];
\r
140 return (jalview.schemabinding.version2.DBRef[]) this._DBRefList
\r
145 * Method getDBRefCount.
\r
147 * @return the size of this collection
\r
149 public int getDBRefCount()
\r
151 return this._DBRefList.size();
\r
155 * Returns the value of field 'dsseqid'. The field 'dsseqid' has the following
\r
156 * description: dataset sequence id for this sequence. Will be created as
\r
157 * union of sequences.
\r
160 * @return the value of field 'Dsseqid'.
\r
162 public java.lang.String getDsseqid()
\r
164 return this._dsseqid;
\r
170 * @return true if this object is valid according to the schema
\r
172 public boolean isValid()
\r
177 } catch (org.exolab.castor.xml.ValidationException vex)
\r
188 * @throws org.exolab.castor.xml.MarshalException
\r
189 * if object is null or if any SAXException is thrown during
\r
191 * @throws org.exolab.castor.xml.ValidationException
\r
192 * if this object is an invalid instance according to the
\r
195 public void marshal(final java.io.Writer out)
\r
196 throws org.exolab.castor.xml.MarshalException,
\r
197 org.exolab.castor.xml.ValidationException
\r
199 Marshaller.marshal(this, out);
\r
206 * @throws java.io.IOException
\r
207 * if an IOException occurs during marshaling
\r
208 * @throws org.exolab.castor.xml.ValidationException
\r
209 * if this object is an invalid instance according to the
\r
211 * @throws org.exolab.castor.xml.MarshalException
\r
212 * if object is null or if any SAXException is thrown during
\r
215 public void marshal(final org.xml.sax.ContentHandler handler)
\r
216 throws java.io.IOException,
\r
217 org.exolab.castor.xml.MarshalException,
\r
218 org.exolab.castor.xml.ValidationException
\r
220 Marshaller.marshal(this, handler);
\r
225 public void removeAllDBRef()
\r
227 this._DBRefList.clear();
\r
231 * Method removeDBRef.
\r
234 * @return true if the object was removed from the collection.
\r
236 public boolean removeDBRef(
\r
237 final jalview.schemabinding.version2.DBRef vDBRef)
\r
239 boolean removed = _DBRefList.remove(vDBRef);
\r
244 * Method removeDBRefAt.
\r
247 * @return the element removed from the collection
\r
249 public jalview.schemabinding.version2.DBRef removeDBRefAt(final int index)
\r
251 java.lang.Object obj = this._DBRefList.remove(index);
\r
252 return (jalview.schemabinding.version2.DBRef) obj;
\r
260 * @throws java.lang.IndexOutOfBoundsException
\r
261 * if the index given is outside the bounds of the collection
\r
263 public void setDBRef(final int index,
\r
264 final jalview.schemabinding.version2.DBRef vDBRef)
\r
265 throws java.lang.IndexOutOfBoundsException
\r
267 // check bounds for index
\r
268 if (index < 0 || index >= this._DBRefList.size())
\r
270 throw new IndexOutOfBoundsException("setDBRef: Index value '" + index
\r
271 + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
\r
274 this._DBRefList.set(index, vDBRef);
\r
280 * @param vDBRefArray
\r
282 public void setDBRef(
\r
283 final jalview.schemabinding.version2.DBRef[] vDBRefArray)
\r
286 _DBRefList.clear();
\r
288 for (int i = 0; i < vDBRefArray.length; i++)
\r
290 this._DBRefList.add(vDBRefArray[i]);
\r
295 * Sets the value of field 'dsseqid'. The field 'dsseqid' has the following
\r
296 * description: dataset sequence id for this sequence. Will be created as
\r
297 * union of sequences.
\r
301 * the value of field 'dsseqid'.
\r
303 public void setDsseqid(final java.lang.String dsseqid)
\r
305 this._dsseqid = dsseqid;
\r
309 * Method unmarshal.
\r
312 * @throws org.exolab.castor.xml.MarshalException
\r
313 * if object is null or if any SAXException is thrown during
\r
315 * @throws org.exolab.castor.xml.ValidationException
\r
316 * if this object is an invalid instance according to the
\r
318 * @return the unmarshaled jalview.schemabinding.version2.SequenceType
\r
320 public static jalview.schemabinding.version2.SequenceType unmarshal(
\r
321 final java.io.Reader reader)
\r
322 throws org.exolab.castor.xml.MarshalException,
\r
323 org.exolab.castor.xml.ValidationException
\r
325 return (jalview.schemabinding.version2.SequenceType) Unmarshaller
\r
326 .unmarshal(jalview.schemabinding.version2.Sequence.class,
\r
333 * @throws org.exolab.castor.xml.ValidationException
\r
334 * if this object is an invalid instance according to the
\r
337 public void validate() throws org.exolab.castor.xml.ValidationException
\r
339 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
340 validator.validate(this);
\r