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 VAMSAS implements java.io.Serializable
\r
36 // --------------------------/
\r
37 // - Class/Member Variables -/
\r
38 // --------------------------/
\r
43 private java.util.Vector _treeList;
\r
46 * Field _sequenceSetList.
\r
48 private java.util.Vector _sequenceSetList;
\r
50 // ----------------/
\r
51 // - Constructors -/
\r
52 // ----------------/
\r
57 this._treeList = new java.util.Vector();
\r
58 this._sequenceSetList = new java.util.Vector();
\r
68 * @param vSequenceSet
\r
69 * @throws java.lang.IndexOutOfBoundsException
\r
70 * if the index given is outside the bounds of the collection
\r
72 public void addSequenceSet(
\r
73 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
74 throws java.lang.IndexOutOfBoundsException
\r
76 this._sequenceSetList.addElement(vSequenceSet);
\r
83 * @param vSequenceSet
\r
84 * @throws java.lang.IndexOutOfBoundsException
\r
85 * if the index given is outside the bounds of the collection
\r
87 public void addSequenceSet(final int index,
\r
88 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
89 throws java.lang.IndexOutOfBoundsException
\r
91 this._sequenceSetList.add(index, vSequenceSet);
\r
98 * @throws java.lang.IndexOutOfBoundsException
\r
99 * if the index given is outside the bounds of the collection
\r
101 public void addTree(final java.lang.String vTree)
\r
102 throws java.lang.IndexOutOfBoundsException
\r
104 this._treeList.addElement(vTree);
\r
112 * @throws java.lang.IndexOutOfBoundsException
\r
113 * if the index given is outside the bounds of the collection
\r
115 public void addTree(final int index, final java.lang.String vTree)
\r
116 throws java.lang.IndexOutOfBoundsException
\r
118 this._treeList.add(index, vTree);
\r
122 * Method enumerateSequenceSet.
\r
124 * @return an Enumeration over all jalview.schemabinding.version2.SequenceSet
\r
127 public java.util.Enumeration enumerateSequenceSet()
\r
129 return this._sequenceSetList.elements();
\r
133 * Method enumerateTree.
\r
135 * @return an Enumeration over all java.lang.String elements
\r
137 public java.util.Enumeration enumerateTree()
\r
139 return this._treeList.elements();
\r
143 * Method getSequenceSet.
\r
146 * @throws java.lang.IndexOutOfBoundsException
\r
147 * if the index given is outside the bounds of the collection
\r
148 * @return the value of the jalview.schemabinding.version2.SequenceSet at the
\r
151 public jalview.schemabinding.version2.SequenceSet getSequenceSet(
\r
152 final int index) throws java.lang.IndexOutOfBoundsException
\r
154 // check bounds for index
\r
155 if (index < 0 || index >= this._sequenceSetList.size())
\r
157 throw new IndexOutOfBoundsException("getSequenceSet: Index value '"
\r
158 + index + "' not in range [0.."
\r
159 + (this._sequenceSetList.size() - 1) + "]");
\r
162 return (jalview.schemabinding.version2.SequenceSet) _sequenceSetList
\r
167 * Method getSequenceSet.Returns the contents of the collection in an Array.
\r
169 * Note: Just in case the collection contents are changing in another thread,
\r
170 * we pass a 0-length Array of the correct type into the API call. This way we
\r
171 * <i>know</i> that the Array returned is of exactly the correct length.
\r
173 * @return this collection as an Array
\r
175 public jalview.schemabinding.version2.SequenceSet[] getSequenceSet()
\r
177 jalview.schemabinding.version2.SequenceSet[] array = new jalview.schemabinding.version2.SequenceSet[0];
\r
178 return (jalview.schemabinding.version2.SequenceSet[]) this._sequenceSetList
\r
183 * Method getSequenceSetCount.
\r
185 * @return the size of this collection
\r
187 public int getSequenceSetCount()
\r
189 return this._sequenceSetList.size();
\r
196 * @throws java.lang.IndexOutOfBoundsException
\r
197 * if the index given is outside the bounds of the collection
\r
198 * @return the value of the java.lang.String at the given index
\r
200 public java.lang.String getTree(final int index)
\r
201 throws java.lang.IndexOutOfBoundsException
\r
203 // check bounds for index
\r
204 if (index < 0 || index >= this._treeList.size())
\r
206 throw new IndexOutOfBoundsException("getTree: Index value '" + index
\r
207 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
\r
210 return (java.lang.String) _treeList.get(index);
\r
214 * Method getTree.Returns the contents of the collection in an Array.
\r
216 * Note: Just in case the collection contents are changing in another thread,
\r
217 * we pass a 0-length Array of the correct type into the API call. This way we
\r
218 * <i>know</i> that the Array returned is of exactly the correct length.
\r
220 * @return this collection as an Array
\r
222 public java.lang.String[] getTree()
\r
224 java.lang.String[] array = new java.lang.String[0];
\r
225 return (java.lang.String[]) this._treeList.toArray(array);
\r
229 * Method getTreeCount.
\r
231 * @return the size of this collection
\r
233 public int getTreeCount()
\r
235 return this._treeList.size();
\r
241 * @return true if this object is valid according to the schema
\r
243 public boolean isValid()
\r
248 } catch (org.exolab.castor.xml.ValidationException vex)
\r
259 * @throws org.exolab.castor.xml.MarshalException
\r
260 * if object is null or if any SAXException is thrown during
\r
262 * @throws org.exolab.castor.xml.ValidationException
\r
263 * if this object is an invalid instance according to the
\r
266 public void marshal(final java.io.Writer out)
\r
267 throws org.exolab.castor.xml.MarshalException,
\r
268 org.exolab.castor.xml.ValidationException
\r
270 Marshaller.marshal(this, out);
\r
277 * @throws java.io.IOException
\r
278 * if an IOException occurs during marshaling
\r
279 * @throws org.exolab.castor.xml.ValidationException
\r
280 * if this object is an invalid instance according to the
\r
282 * @throws org.exolab.castor.xml.MarshalException
\r
283 * if object is null or if any SAXException is thrown during
\r
286 public void marshal(final org.xml.sax.ContentHandler handler)
\r
287 throws java.io.IOException,
\r
288 org.exolab.castor.xml.MarshalException,
\r
289 org.exolab.castor.xml.ValidationException
\r
291 Marshaller.marshal(this, handler);
\r
296 public void removeAllSequenceSet()
\r
298 this._sequenceSetList.clear();
\r
303 public void removeAllTree()
\r
305 this._treeList.clear();
\r
309 * Method removeSequenceSet.
\r
311 * @param vSequenceSet
\r
312 * @return true if the object was removed from the collection.
\r
314 public boolean removeSequenceSet(
\r
315 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
317 boolean removed = _sequenceSetList.remove(vSequenceSet);
\r
322 * Method removeSequenceSetAt.
\r
325 * @return the element removed from the collection
\r
327 public jalview.schemabinding.version2.SequenceSet removeSequenceSetAt(
\r
330 java.lang.Object obj = this._sequenceSetList.remove(index);
\r
331 return (jalview.schemabinding.version2.SequenceSet) obj;
\r
335 * Method removeTree.
\r
338 * @return true if the object was removed from the collection.
\r
340 public boolean removeTree(final java.lang.String vTree)
\r
342 boolean removed = _treeList.remove(vTree);
\r
347 * Method removeTreeAt.
\r
350 * @return the element removed from the collection
\r
352 public java.lang.String removeTreeAt(final int index)
\r
354 java.lang.Object obj = this._treeList.remove(index);
\r
355 return (java.lang.String) obj;
\r
362 * @param vSequenceSet
\r
363 * @throws java.lang.IndexOutOfBoundsException
\r
364 * if the index given is outside the bounds of the collection
\r
366 public void setSequenceSet(final int index,
\r
367 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
368 throws java.lang.IndexOutOfBoundsException
\r
370 // check bounds for index
\r
371 if (index < 0 || index >= this._sequenceSetList.size())
\r
373 throw new IndexOutOfBoundsException("setSequenceSet: Index value '"
\r
374 + index + "' not in range [0.."
\r
375 + (this._sequenceSetList.size() - 1) + "]");
\r
378 this._sequenceSetList.set(index, vSequenceSet);
\r
384 * @param vSequenceSetArray
\r
386 public void setSequenceSet(
\r
387 final jalview.schemabinding.version2.SequenceSet[] vSequenceSetArray)
\r
390 _sequenceSetList.clear();
\r
392 for (int i = 0; i < vSequenceSetArray.length; i++)
\r
394 this._sequenceSetList.add(vSequenceSetArray[i]);
\r
403 * @throws java.lang.IndexOutOfBoundsException
\r
404 * if the index given is outside the bounds of the collection
\r
406 public void setTree(final int index, final java.lang.String vTree)
\r
407 throws java.lang.IndexOutOfBoundsException
\r
409 // check bounds for index
\r
410 if (index < 0 || index >= this._treeList.size())
\r
412 throw new IndexOutOfBoundsException("setTree: Index value '" + index
\r
413 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
\r
416 this._treeList.set(index, vTree);
\r
422 * @param vTreeArray
\r
424 public void setTree(final java.lang.String[] vTreeArray)
\r
429 for (int i = 0; i < vTreeArray.length; i++)
\r
431 this._treeList.add(vTreeArray[i]);
\r
436 * Method unmarshal.
\r
439 * @throws org.exolab.castor.xml.MarshalException
\r
440 * if object is null or if any SAXException is thrown during
\r
442 * @throws org.exolab.castor.xml.ValidationException
\r
443 * if this object is an invalid instance according to the
\r
445 * @return the unmarshaled jalview.schemabinding.version2.VAMSAS
\r
447 public static jalview.schemabinding.version2.VAMSAS unmarshal(
\r
448 final java.io.Reader reader)
\r
449 throws org.exolab.castor.xml.MarshalException,
\r
450 org.exolab.castor.xml.ValidationException
\r
452 return (jalview.schemabinding.version2.VAMSAS) Unmarshaller.unmarshal(
\r
453 jalview.schemabinding.version2.VAMSAS.class, reader);
\r
459 * @throws org.exolab.castor.xml.ValidationException
\r
460 * if this object is an invalid instance according to the
\r
463 public void validate() throws org.exolab.castor.xml.ValidationException
\r
465 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
466 validator.validate(this);
\r