2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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 jalview.util.MessageManager;
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
35 * @version $Revision$ $Date$
37 public class Sequence extends jalview.schemabinding.version2.SequenceType
38 implements java.io.Serializable
41 // --------------------------/
42 // - Class/Member Variables -/
43 // --------------------------/
46 * dataset sequence id for this sequence. Will be created as union of
50 private java.lang.String _dsseqid;
55 private java.util.Vector _DBRefList;
64 this._DBRefList = new java.util.Vector();
75 * @throws java.lang.IndexOutOfBoundsException
76 * if the index given is outside the bounds of the collection
78 public void addDBRef(final jalview.schemabinding.version2.DBRef vDBRef)
79 throws java.lang.IndexOutOfBoundsException
81 this._DBRefList.addElement(vDBRef);
89 * @throws java.lang.IndexOutOfBoundsException
90 * if the index given is outside the bounds of the collection
92 public void addDBRef(final int index,
93 final jalview.schemabinding.version2.DBRef vDBRef)
94 throws java.lang.IndexOutOfBoundsException
96 this._DBRefList.add(index, vDBRef);
100 * Method enumerateDBRef.
102 * @return an Enumeration over all jalview.schemabinding.version2.DBRef
105 public java.util.Enumeration enumerateDBRef()
107 return this._DBRefList.elements();
114 * @throws java.lang.IndexOutOfBoundsException
115 * if the index given is outside the bounds of the collection
116 * @return the value of the jalview.schemabinding.version2.DBRef at the given
119 public jalview.schemabinding.version2.DBRef getDBRef(final int index)
120 throws java.lang.IndexOutOfBoundsException
122 // check bounds for index
123 if (index < 0 || index >= this._DBRefList.size())
125 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
127 Integer.valueOf(index).toString(),
128 Integer.valueOf((this._DBRefList.size() - 1)).toString()
132 return (jalview.schemabinding.version2.DBRef) _DBRefList.get(index);
136 * Method getDBRef.Returns the contents of the collection in an Array.
138 * Note: Just in case the collection contents are changing in another thread,
139 * we pass a 0-length Array of the correct type into the API call. This way we
140 * <i>know</i> that the Array returned is of exactly the correct length.
142 * @return this collection as an Array
144 public jalview.schemabinding.version2.DBRef[] getDBRef()
146 jalview.schemabinding.version2.DBRef[] array = new jalview.schemabinding.version2.DBRef[0];
147 return (jalview.schemabinding.version2.DBRef[]) this._DBRefList
152 * Method getDBRefCount.
154 * @return the size of this collection
156 public int getDBRefCount()
158 return this._DBRefList.size();
162 * Returns the value of field 'dsseqid'. The field 'dsseqid' has the following
163 * description: dataset sequence id for this sequence. Will be created as
164 * union of sequences.
167 * @return the value of field 'Dsseqid'.
169 public java.lang.String getDsseqid()
171 return this._dsseqid;
177 * @return true if this object is valid according to the schema
179 public boolean isValid()
184 } catch (org.exolab.castor.xml.ValidationException vex)
195 * @throws org.exolab.castor.xml.MarshalException
196 * if object is null or if any SAXException is thrown during
198 * @throws org.exolab.castor.xml.ValidationException
199 * if this object is an invalid instance according to the schema
201 public void marshal(final java.io.Writer out)
202 throws org.exolab.castor.xml.MarshalException,
203 org.exolab.castor.xml.ValidationException
205 Marshaller.marshal(this, out);
212 * @throws java.io.IOException
213 * if an IOException occurs during marshaling
214 * @throws org.exolab.castor.xml.ValidationException
215 * if this object is an invalid instance according to the schema
216 * @throws org.exolab.castor.xml.MarshalException
217 * if object is null or if any SAXException is thrown during
220 public void marshal(final org.xml.sax.ContentHandler handler)
221 throws java.io.IOException,
222 org.exolab.castor.xml.MarshalException,
223 org.exolab.castor.xml.ValidationException
225 Marshaller.marshal(this, handler);
230 public void removeAllDBRef()
232 this._DBRefList.clear();
236 * Method removeDBRef.
239 * @return true if the object was removed from the collection.
241 public boolean removeDBRef(
242 final jalview.schemabinding.version2.DBRef vDBRef)
244 boolean removed = _DBRefList.remove(vDBRef);
249 * Method removeDBRefAt.
252 * @return the element removed from the collection
254 public jalview.schemabinding.version2.DBRef removeDBRefAt(final int index)
256 java.lang.Object obj = this._DBRefList.remove(index);
257 return (jalview.schemabinding.version2.DBRef) obj;
265 * @throws java.lang.IndexOutOfBoundsException
266 * if the index given is outside the bounds of the collection
268 public void setDBRef(final int index,
269 final jalview.schemabinding.version2.DBRef vDBRef)
270 throws java.lang.IndexOutOfBoundsException
272 // check bounds for index
273 if (index < 0 || index >= this._DBRefList.size())
275 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
277 Integer.valueOf(index).toString(),
278 Integer.valueOf((this._DBRefList.size() - 1)).toString()
282 this._DBRefList.set(index, vDBRef);
290 public void setDBRef(
291 final jalview.schemabinding.version2.DBRef[] vDBRefArray)
296 for (int i = 0; i < vDBRefArray.length; i++)
298 this._DBRefList.add(vDBRefArray[i]);
303 * Sets the value of field 'dsseqid'. The field 'dsseqid' has the following
304 * description: dataset sequence id for this sequence. Will be created as
305 * union of sequences.
309 * the value of field 'dsseqid'.
311 public void setDsseqid(final java.lang.String dsseqid)
313 this._dsseqid = dsseqid;
320 * @throws org.exolab.castor.xml.MarshalException
321 * if object is null or if any SAXException is thrown during
323 * @throws org.exolab.castor.xml.ValidationException
324 * if this object is an invalid instance according to the schema
325 * @return the unmarshaled jalview.schemabinding.version2.SequenceType
327 public static jalview.schemabinding.version2.SequenceType unmarshal(
328 final java.io.Reader reader)
329 throws org.exolab.castor.xml.MarshalException,
330 org.exolab.castor.xml.ValidationException
332 return (jalview.schemabinding.version2.SequenceType) Unmarshaller
333 .unmarshal(jalview.schemabinding.version2.Sequence.class,
340 * @throws org.exolab.castor.xml.ValidationException
341 * if this object is an invalid instance according to the schema
343 public void validate() throws org.exolab.castor.xml.ValidationException
345 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
346 validator.validate(this);