2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.schemabinding.version2;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
31 * @version $Revision$ $Date$
33 public class Sequence extends jalview.schemabinding.version2.SequenceType
34 implements java.io.Serializable
37 // --------------------------/
38 // - Class/Member Variables -/
39 // --------------------------/
42 * dataset sequence id for this sequence. Will be created as union of
46 private java.lang.String _dsseqid;
51 private java.util.Vector _DBRefList;
60 this._DBRefList = new java.util.Vector();
71 * @throws java.lang.IndexOutOfBoundsException
72 * if the index given is outside the bounds of the collection
74 public void addDBRef(final jalview.schemabinding.version2.DBRef vDBRef)
75 throws java.lang.IndexOutOfBoundsException
77 this._DBRefList.addElement(vDBRef);
85 * @throws java.lang.IndexOutOfBoundsException
86 * if the index given is outside the bounds of the collection
88 public void addDBRef(final int index,
89 final jalview.schemabinding.version2.DBRef vDBRef)
90 throws java.lang.IndexOutOfBoundsException
92 this._DBRefList.add(index, vDBRef);
96 * Method enumerateDBRef.
98 * @return an Enumeration over all jalview.schemabinding.version2.DBRef
101 public java.util.Enumeration enumerateDBRef()
103 return this._DBRefList.elements();
110 * @throws java.lang.IndexOutOfBoundsException
111 * if the index given is outside the bounds of the collection
112 * @return the value of the jalview.schemabinding.version2.DBRef at the given
115 public jalview.schemabinding.version2.DBRef getDBRef(final int index)
116 throws java.lang.IndexOutOfBoundsException
118 // check bounds for index
119 if (index < 0 || index >= this._DBRefList.size())
121 throw new IndexOutOfBoundsException("getDBRef: Index value '" + index
122 + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
125 return (jalview.schemabinding.version2.DBRef) _DBRefList.get(index);
129 * Method getDBRef.Returns the contents of the collection in an Array.
131 * Note: Just in case the collection contents are changing in another thread,
132 * we pass a 0-length Array of the correct type into the API call. This way we
133 * <i>know</i> that the Array returned is of exactly the correct length.
135 * @return this collection as an Array
137 public jalview.schemabinding.version2.DBRef[] getDBRef()
139 jalview.schemabinding.version2.DBRef[] array = new jalview.schemabinding.version2.DBRef[0];
140 return (jalview.schemabinding.version2.DBRef[]) this._DBRefList
145 * Method getDBRefCount.
147 * @return the size of this collection
149 public int getDBRefCount()
151 return this._DBRefList.size();
155 * Returns the value of field 'dsseqid'. The field 'dsseqid' has the following
156 * description: dataset sequence id for this sequence. Will be created as
157 * union of sequences.
160 * @return the value of field 'Dsseqid'.
162 public java.lang.String getDsseqid()
164 return this._dsseqid;
170 * @return true if this object is valid according to the schema
172 public boolean isValid()
177 } catch (org.exolab.castor.xml.ValidationException vex)
188 * @throws org.exolab.castor.xml.MarshalException
189 * if object is null or if any SAXException is thrown during
191 * @throws org.exolab.castor.xml.ValidationException
192 * if this object is an invalid instance according to the schema
194 public void marshal(final java.io.Writer out)
195 throws org.exolab.castor.xml.MarshalException,
196 org.exolab.castor.xml.ValidationException
198 Marshaller.marshal(this, out);
205 * @throws java.io.IOException
206 * if an IOException occurs during marshaling
207 * @throws org.exolab.castor.xml.ValidationException
208 * if this object is an invalid instance according to the schema
209 * @throws org.exolab.castor.xml.MarshalException
210 * if object is null or if any SAXException is thrown during
213 public void marshal(final org.xml.sax.ContentHandler handler)
214 throws java.io.IOException,
215 org.exolab.castor.xml.MarshalException,
216 org.exolab.castor.xml.ValidationException
218 Marshaller.marshal(this, handler);
223 public void removeAllDBRef()
225 this._DBRefList.clear();
229 * Method removeDBRef.
232 * @return true if the object was removed from the collection.
234 public boolean removeDBRef(
235 final jalview.schemabinding.version2.DBRef vDBRef)
237 boolean removed = _DBRefList.remove(vDBRef);
242 * Method removeDBRefAt.
245 * @return the element removed from the collection
247 public jalview.schemabinding.version2.DBRef removeDBRefAt(final int index)
249 java.lang.Object obj = this._DBRefList.remove(index);
250 return (jalview.schemabinding.version2.DBRef) obj;
258 * @throws java.lang.IndexOutOfBoundsException
259 * if the index given is outside the bounds of the collection
261 public void setDBRef(final int index,
262 final jalview.schemabinding.version2.DBRef vDBRef)
263 throws java.lang.IndexOutOfBoundsException
265 // check bounds for index
266 if (index < 0 || index >= this._DBRefList.size())
268 throw new IndexOutOfBoundsException("setDBRef: Index value '" + index
269 + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
272 this._DBRefList.set(index, vDBRef);
280 public void setDBRef(
281 final jalview.schemabinding.version2.DBRef[] vDBRefArray)
286 for (int i = 0; i < vDBRefArray.length; i++)
288 this._DBRefList.add(vDBRefArray[i]);
293 * Sets the value of field 'dsseqid'. The field 'dsseqid' has the following
294 * description: dataset sequence id for this sequence. Will be created as
295 * union of sequences.
299 * the value of field 'dsseqid'.
301 public void setDsseqid(final java.lang.String dsseqid)
303 this._dsseqid = dsseqid;
310 * @throws org.exolab.castor.xml.MarshalException
311 * if object is null or if any SAXException is thrown during
313 * @throws org.exolab.castor.xml.ValidationException
314 * if this object is an invalid instance according to the schema
315 * @return the unmarshaled jalview.schemabinding.version2.SequenceType
317 public static jalview.schemabinding.version2.SequenceType unmarshal(
318 final java.io.Reader reader)
319 throws org.exolab.castor.xml.MarshalException,
320 org.exolab.castor.xml.ValidationException
322 return (jalview.schemabinding.version2.SequenceType) Unmarshaller
323 .unmarshal(jalview.schemabinding.version2.Sequence.class,
330 * @throws org.exolab.castor.xml.ValidationException
331 * if this object is an invalid instance according to the schema
333 public void validate() throws org.exolab.castor.xml.ValidationException
335 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
336 validator.validate(this);