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
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/>.
18 package jalview.schemabinding.version2;
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
30 * @version $Revision$ $Date$
32 public class Sequence extends jalview.schemabinding.version2.SequenceType
33 implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
41 * dataset sequence id for this sequence. Will be created as union of
45 private java.lang.String _dsseqid;
50 private java.util.Vector _DBRefList;
59 this._DBRefList = new java.util.Vector();
70 * @throws java.lang.IndexOutOfBoundsException
71 * if the index given is outside the bounds of the collection
73 public void addDBRef(final jalview.schemabinding.version2.DBRef vDBRef)
74 throws java.lang.IndexOutOfBoundsException
76 this._DBRefList.addElement(vDBRef);
84 * @throws java.lang.IndexOutOfBoundsException
85 * if the index given is outside the bounds of the collection
87 public void addDBRef(final int index,
88 final jalview.schemabinding.version2.DBRef vDBRef)
89 throws java.lang.IndexOutOfBoundsException
91 this._DBRefList.add(index, vDBRef);
95 * Method enumerateDBRef.
97 * @return an Enumeration over all jalview.schemabinding.version2.DBRef
100 public java.util.Enumeration enumerateDBRef()
102 return this._DBRefList.elements();
109 * @throws java.lang.IndexOutOfBoundsException
110 * if the index given is outside the bounds of the collection
111 * @return the value of the jalview.schemabinding.version2.DBRef at the given
114 public jalview.schemabinding.version2.DBRef getDBRef(final int index)
115 throws java.lang.IndexOutOfBoundsException
117 // check bounds for index
118 if (index < 0 || index >= this._DBRefList.size())
120 throw new IndexOutOfBoundsException("getDBRef: Index value '" + index
121 + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
124 return (jalview.schemabinding.version2.DBRef) _DBRefList.get(index);
128 * Method getDBRef.Returns the contents of the collection in an Array.
130 * Note: Just in case the collection contents are changing in another thread,
131 * we pass a 0-length Array of the correct type into the API call. This way we
132 * <i>know</i> that the Array returned is of exactly the correct length.
134 * @return this collection as an Array
136 public jalview.schemabinding.version2.DBRef[] getDBRef()
138 jalview.schemabinding.version2.DBRef[] array = new jalview.schemabinding.version2.DBRef[0];
139 return (jalview.schemabinding.version2.DBRef[]) this._DBRefList
144 * Method getDBRefCount.
146 * @return the size of this collection
148 public int getDBRefCount()
150 return this._DBRefList.size();
154 * Returns the value of field 'dsseqid'. The field 'dsseqid' has the following
155 * description: dataset sequence id for this sequence. Will be created as
156 * union of sequences.
159 * @return the value of field 'Dsseqid'.
161 public java.lang.String getDsseqid()
163 return this._dsseqid;
169 * @return true if this object is valid according to the schema
171 public boolean isValid()
176 } catch (org.exolab.castor.xml.ValidationException vex)
187 * @throws org.exolab.castor.xml.MarshalException
188 * if object is null or if any SAXException is thrown during
190 * @throws org.exolab.castor.xml.ValidationException
191 * if this object is an invalid instance according to the schema
193 public void marshal(final java.io.Writer out)
194 throws org.exolab.castor.xml.MarshalException,
195 org.exolab.castor.xml.ValidationException
197 Marshaller.marshal(this, out);
204 * @throws java.io.IOException
205 * if an IOException occurs during marshaling
206 * @throws org.exolab.castor.xml.ValidationException
207 * if this object is an invalid instance according to the schema
208 * @throws org.exolab.castor.xml.MarshalException
209 * if object is null or if any SAXException is thrown during
212 public void marshal(final org.xml.sax.ContentHandler handler)
213 throws java.io.IOException,
214 org.exolab.castor.xml.MarshalException,
215 org.exolab.castor.xml.ValidationException
217 Marshaller.marshal(this, handler);
222 public void removeAllDBRef()
224 this._DBRefList.clear();
228 * Method removeDBRef.
231 * @return true if the object was removed from the collection.
233 public boolean removeDBRef(
234 final jalview.schemabinding.version2.DBRef vDBRef)
236 boolean removed = _DBRefList.remove(vDBRef);
241 * Method removeDBRefAt.
244 * @return the element removed from the collection
246 public jalview.schemabinding.version2.DBRef removeDBRefAt(final int index)
248 java.lang.Object obj = this._DBRefList.remove(index);
249 return (jalview.schemabinding.version2.DBRef) obj;
257 * @throws java.lang.IndexOutOfBoundsException
258 * if the index given is outside the bounds of the collection
260 public void setDBRef(final int index,
261 final jalview.schemabinding.version2.DBRef vDBRef)
262 throws java.lang.IndexOutOfBoundsException
264 // check bounds for index
265 if (index < 0 || index >= this._DBRefList.size())
267 throw new IndexOutOfBoundsException("setDBRef: Index value '" + index
268 + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
271 this._DBRefList.set(index, vDBRef);
279 public void setDBRef(
280 final jalview.schemabinding.version2.DBRef[] vDBRefArray)
285 for (int i = 0; i < vDBRefArray.length; i++)
287 this._DBRefList.add(vDBRefArray[i]);
292 * Sets the value of field 'dsseqid'. The field 'dsseqid' has the following
293 * description: dataset sequence id for this sequence. Will be created as
294 * union of sequences.
298 * the value of field 'dsseqid'.
300 public void setDsseqid(final java.lang.String dsseqid)
302 this._dsseqid = dsseqid;
309 * @throws org.exolab.castor.xml.MarshalException
310 * if object is null or if any SAXException is thrown during
312 * @throws org.exolab.castor.xml.ValidationException
313 * if this object is an invalid instance according to the schema
314 * @return the unmarshaled jalview.schemabinding.version2.SequenceType
316 public static jalview.schemabinding.version2.SequenceType unmarshal(
317 final java.io.Reader reader)
318 throws org.exolab.castor.xml.MarshalException,
319 org.exolab.castor.xml.ValidationException
321 return (jalview.schemabinding.version2.SequenceType) Unmarshaller
322 .unmarshal(jalview.schemabinding.version2.Sequence.class,
329 * @throws org.exolab.castor.xml.ValidationException
330 * if this object is an invalid instance according to the schema
332 public void validate() throws org.exolab.castor.xml.ValidationException
334 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
335 validator.validate(this);