2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.schemabinding.version2;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import org.exolab.castor.xml.Marshaller;
28 import org.exolab.castor.xml.Unmarshaller;
33 * @version $Revision$ $Date$
35 public class Sequence extends jalview.schemabinding.version2.SequenceType
36 implements java.io.Serializable
39 // --------------------------/
40 // - Class/Member Variables -/
41 // --------------------------/
44 * dataset sequence id for this sequence. Will be created as union of
48 private java.lang.String _dsseqid;
53 private java.util.Vector _DBRefList;
62 this._DBRefList = new java.util.Vector();
73 * @throws java.lang.IndexOutOfBoundsException
74 * if the index given is outside the bounds of the collection
76 public void addDBRef(final jalview.schemabinding.version2.DBRef vDBRef)
77 throws java.lang.IndexOutOfBoundsException
79 this._DBRefList.addElement(vDBRef);
87 * @throws java.lang.IndexOutOfBoundsException
88 * if the index given is outside the bounds of the collection
90 public void addDBRef(final int index,
91 final jalview.schemabinding.version2.DBRef vDBRef)
92 throws java.lang.IndexOutOfBoundsException
94 this._DBRefList.add(index, vDBRef);
98 * Method enumerateDBRef.
100 * @return an Enumeration over all jalview.schemabinding.version2.DBRef
103 public java.util.Enumeration enumerateDBRef()
105 return this._DBRefList.elements();
112 * @throws java.lang.IndexOutOfBoundsException
113 * if the index given is outside the bounds of the collection
114 * @return the value of the jalview.schemabinding.version2.DBRef at the given
117 public jalview.schemabinding.version2.DBRef getDBRef(final int index)
118 throws java.lang.IndexOutOfBoundsException
120 // check bounds for index
121 if (index < 0 || index >= this._DBRefList.size())
123 throw new IndexOutOfBoundsException("getDBRef: Index value '" + index
124 + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
127 return (jalview.schemabinding.version2.DBRef) _DBRefList.get(index);
131 * Method getDBRef.Returns the contents of the collection in an Array.
133 * Note: Just in case the collection contents are changing in another thread,
134 * we pass a 0-length Array of the correct type into the API call. This way we
135 * <i>know</i> that the Array returned is of exactly the correct length.
137 * @return this collection as an Array
139 public jalview.schemabinding.version2.DBRef[] getDBRef()
141 jalview.schemabinding.version2.DBRef[] array = new jalview.schemabinding.version2.DBRef[0];
142 return (jalview.schemabinding.version2.DBRef[]) this._DBRefList
147 * Method getDBRefCount.
149 * @return the size of this collection
151 public int getDBRefCount()
153 return this._DBRefList.size();
157 * Returns the value of field 'dsseqid'. The field 'dsseqid' has the following
158 * description: dataset sequence id for this sequence. Will be created as
159 * union of sequences.
162 * @return the value of field 'Dsseqid'.
164 public java.lang.String getDsseqid()
166 return this._dsseqid;
172 * @return true if this object is valid according to the schema
174 public boolean isValid()
179 } catch (org.exolab.castor.xml.ValidationException vex)
190 * @throws org.exolab.castor.xml.MarshalException
191 * if object is null or if any SAXException is thrown during
193 * @throws org.exolab.castor.xml.ValidationException
194 * if this object is an invalid instance according to the schema
196 public void marshal(final java.io.Writer out)
197 throws org.exolab.castor.xml.MarshalException,
198 org.exolab.castor.xml.ValidationException
200 Marshaller.marshal(this, out);
207 * @throws java.io.IOException
208 * if an IOException occurs during marshaling
209 * @throws org.exolab.castor.xml.ValidationException
210 * if this object is an invalid instance according to the schema
211 * @throws org.exolab.castor.xml.MarshalException
212 * if object is null or if any SAXException is thrown during
215 public void marshal(final org.xml.sax.ContentHandler handler)
216 throws java.io.IOException,
217 org.exolab.castor.xml.MarshalException,
218 org.exolab.castor.xml.ValidationException
220 Marshaller.marshal(this, handler);
225 public void removeAllDBRef()
227 this._DBRefList.clear();
231 * Method removeDBRef.
234 * @return true if the object was removed from the collection.
236 public boolean removeDBRef(
237 final jalview.schemabinding.version2.DBRef vDBRef)
239 boolean removed = _DBRefList.remove(vDBRef);
244 * Method removeDBRefAt.
247 * @return the element removed from the collection
249 public jalview.schemabinding.version2.DBRef removeDBRefAt(final int index)
251 java.lang.Object obj = this._DBRefList.remove(index);
252 return (jalview.schemabinding.version2.DBRef) obj;
260 * @throws java.lang.IndexOutOfBoundsException
261 * if the index given is outside the bounds of the collection
263 public void setDBRef(final int index,
264 final jalview.schemabinding.version2.DBRef vDBRef)
265 throws java.lang.IndexOutOfBoundsException
267 // check bounds for index
268 if (index < 0 || index >= this._DBRefList.size())
270 throw new IndexOutOfBoundsException("setDBRef: Index value '" + index
271 + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
274 this._DBRefList.set(index, vDBRef);
282 public void setDBRef(
283 final jalview.schemabinding.version2.DBRef[] vDBRefArray)
288 for (int i = 0; i < vDBRefArray.length; i++)
290 this._DBRefList.add(vDBRefArray[i]);
295 * Sets the value of field 'dsseqid'. The field 'dsseqid' has the following
296 * description: dataset sequence id for this sequence. Will be created as
297 * union of sequences.
301 * the value of field 'dsseqid'.
303 public void setDsseqid(final java.lang.String dsseqid)
305 this._dsseqid = dsseqid;
312 * @throws org.exolab.castor.xml.MarshalException
313 * if object is null or if any SAXException is thrown during
315 * @throws org.exolab.castor.xml.ValidationException
316 * if this object is an invalid instance according to the schema
317 * @return the unmarshaled jalview.schemabinding.version2.SequenceType
319 public static jalview.schemabinding.version2.SequenceType unmarshal(
320 final java.io.Reader reader)
321 throws org.exolab.castor.xml.MarshalException,
322 org.exolab.castor.xml.ValidationException
324 return (jalview.schemabinding.version2.SequenceType) Unmarshaller
325 .unmarshal(jalview.schemabinding.version2.Sequence.class,
332 * @throws org.exolab.castor.xml.ValidationException
333 * if this object is an invalid instance according to the schema
335 public void validate() throws org.exolab.castor.xml.ValidationException
337 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
338 validator.validate(this);