2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
\r
3 * Copyright (C) 2009 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
57 this._treeList = new java.util.Vector();
\r
58 this._sequenceSetList = new java.util.Vector();
\r
69 * @param vSequenceSet
\r
70 * @throws java.lang.IndexOutOfBoundsException if the index
\r
71 * given is outside the bounds of the collection
\r
73 public void addSequenceSet(
\r
74 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
75 throws java.lang.IndexOutOfBoundsException {
\r
76 this._sequenceSetList.addElement(vSequenceSet);
\r
83 * @param vSequenceSet
\r
84 * @throws java.lang.IndexOutOfBoundsException if the index
\r
85 * given is outside the bounds of the collection
\r
87 public void addSequenceSet(
\r
89 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
90 throws java.lang.IndexOutOfBoundsException {
\r
91 this._sequenceSetList.add(index, vSequenceSet);
\r
98 * @throws java.lang.IndexOutOfBoundsException if the index
\r
99 * given is outside the bounds of the collection
\r
101 public void addTree(
\r
102 final java.lang.String vTree)
\r
103 throws java.lang.IndexOutOfBoundsException {
\r
104 this._treeList.addElement(vTree);
\r
112 * @throws java.lang.IndexOutOfBoundsException if the index
\r
113 * given is outside the bounds of the collection
\r
115 public void addTree(
\r
117 final java.lang.String vTree)
\r
118 throws java.lang.IndexOutOfBoundsException {
\r
119 this._treeList.add(index, vTree);
\r
123 * Method enumerateSequenceSet.
\r
125 * @return an Enumeration over all
\r
126 * jalview.schemabinding.version2.SequenceSet elements
\r
128 public java.util.Enumeration enumerateSequenceSet(
\r
130 return this._sequenceSetList.elements();
\r
134 * Method enumerateTree.
\r
136 * @return an Enumeration over all java.lang.String elements
\r
138 public java.util.Enumeration enumerateTree(
\r
140 return this._treeList.elements();
\r
144 * Method getSequenceSet.
\r
147 * @throws java.lang.IndexOutOfBoundsException if the index
\r
148 * given is outside the bounds of the collection
\r
149 * @return the value of the
\r
150 * jalview.schemabinding.version2.SequenceSet at the given index
\r
152 public jalview.schemabinding.version2.SequenceSet getSequenceSet(
\r
154 throws java.lang.IndexOutOfBoundsException {
\r
155 // check bounds for index
\r
156 if (index < 0 || index >= this._sequenceSetList.size()) {
\r
157 throw new IndexOutOfBoundsException("getSequenceSet: Index value '" + index + "' not in range [0.." + (this._sequenceSetList.size() - 1) + "]");
\r
160 return (jalview.schemabinding.version2.SequenceSet) _sequenceSetList.get(index);
\r
164 * Method getSequenceSet.Returns the contents of the collection
\r
165 * in an Array. <p>Note: Just in case the collection contents
\r
166 * are changing in another thread, we pass a 0-length Array of
\r
167 * the correct type into the API call. This way we <i>know</i>
\r
168 * that the Array returned is of exactly the correct length.
\r
170 * @return this collection as an Array
\r
172 public jalview.schemabinding.version2.SequenceSet[] getSequenceSet(
\r
174 jalview.schemabinding.version2.SequenceSet[] array = new jalview.schemabinding.version2.SequenceSet[0];
\r
175 return (jalview.schemabinding.version2.SequenceSet[]) this._sequenceSetList.toArray(array);
\r
179 * Method getSequenceSetCount.
\r
181 * @return the size of this collection
\r
183 public int getSequenceSetCount(
\r
185 return this._sequenceSetList.size();
\r
192 * @throws java.lang.IndexOutOfBoundsException if the index
\r
193 * given is outside the bounds of the collection
\r
194 * @return the value of the java.lang.String at the given index
\r
196 public java.lang.String getTree(
\r
198 throws java.lang.IndexOutOfBoundsException {
\r
199 // check bounds for index
\r
200 if (index < 0 || index >= this._treeList.size()) {
\r
201 throw new IndexOutOfBoundsException("getTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]");
\r
204 return (java.lang.String) _treeList.get(index);
\r
208 * Method getTree.Returns the contents of the collection in an
\r
209 * Array. <p>Note: Just in case the collection contents are
\r
210 * changing in another thread, we pass a 0-length Array of the
\r
211 * correct type into the API call. This way we <i>know</i>
\r
212 * that the Array returned is of exactly the correct length.
\r
214 * @return this collection as an Array
\r
216 public java.lang.String[] getTree(
\r
218 java.lang.String[] array = new java.lang.String[0];
\r
219 return (java.lang.String[]) this._treeList.toArray(array);
\r
223 * Method getTreeCount.
\r
225 * @return the size of this collection
\r
227 public int getTreeCount(
\r
229 return this._treeList.size();
\r
235 * @return true if this object is valid according to the schema
\r
237 public boolean isValid(
\r
241 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
251 * @throws org.exolab.castor.xml.MarshalException if object is
\r
252 * null or if any SAXException is thrown during marshaling
\r
253 * @throws org.exolab.castor.xml.ValidationException if this
\r
254 * object is an invalid instance according to the schema
\r
256 public void marshal(
\r
257 final java.io.Writer out)
\r
258 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
259 Marshaller.marshal(this, out);
\r
266 * @throws java.io.IOException if an IOException occurs during
\r
268 * @throws org.exolab.castor.xml.ValidationException if this
\r
269 * object is an invalid instance according to the schema
\r
270 * @throws org.exolab.castor.xml.MarshalException if object is
\r
271 * null or if any SAXException is thrown during marshaling
\r
273 public void marshal(
\r
274 final org.xml.sax.ContentHandler handler)
\r
275 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
276 Marshaller.marshal(this, handler);
\r
281 public void removeAllSequenceSet(
\r
283 this._sequenceSetList.clear();
\r
288 public void removeAllTree(
\r
290 this._treeList.clear();
\r
294 * Method removeSequenceSet.
\r
296 * @param vSequenceSet
\r
297 * @return true if the object was removed from the collection.
\r
299 public boolean removeSequenceSet(
\r
300 final jalview.schemabinding.version2.SequenceSet vSequenceSet) {
\r
301 boolean removed = _sequenceSetList.remove(vSequenceSet);
\r
306 * Method removeSequenceSetAt.
\r
309 * @return the element removed from the collection
\r
311 public jalview.schemabinding.version2.SequenceSet removeSequenceSetAt(
\r
313 java.lang.Object obj = this._sequenceSetList.remove(index);
\r
314 return (jalview.schemabinding.version2.SequenceSet) obj;
\r
318 * Method removeTree.
\r
321 * @return true if the object was removed from the collection.
\r
323 public boolean removeTree(
\r
324 final java.lang.String vTree) {
\r
325 boolean removed = _treeList.remove(vTree);
\r
330 * Method removeTreeAt.
\r
333 * @return the element removed from the collection
\r
335 public java.lang.String removeTreeAt(
\r
337 java.lang.Object obj = this._treeList.remove(index);
\r
338 return (java.lang.String) obj;
\r
345 * @param vSequenceSet
\r
346 * @throws java.lang.IndexOutOfBoundsException if the index
\r
347 * given is outside the bounds of the collection
\r
349 public void setSequenceSet(
\r
351 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
352 throws java.lang.IndexOutOfBoundsException {
\r
353 // check bounds for index
\r
354 if (index < 0 || index >= this._sequenceSetList.size()) {
\r
355 throw new IndexOutOfBoundsException("setSequenceSet: Index value '" + index + "' not in range [0.." + (this._sequenceSetList.size() - 1) + "]");
\r
358 this._sequenceSetList.set(index, vSequenceSet);
\r
364 * @param vSequenceSetArray
\r
366 public void setSequenceSet(
\r
367 final jalview.schemabinding.version2.SequenceSet[] vSequenceSetArray) {
\r
369 _sequenceSetList.clear();
\r
371 for (int i = 0; i < vSequenceSetArray.length; i++) {
\r
372 this._sequenceSetList.add(vSequenceSetArray[i]);
\r
381 * @throws java.lang.IndexOutOfBoundsException if the index
\r
382 * given is outside the bounds of the collection
\r
384 public void setTree(
\r
386 final java.lang.String vTree)
\r
387 throws java.lang.IndexOutOfBoundsException {
\r
388 // check bounds for index
\r
389 if (index < 0 || index >= this._treeList.size()) {
\r
390 throw new IndexOutOfBoundsException("setTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]");
\r
393 this._treeList.set(index, vTree);
\r
399 * @param vTreeArray
\r
401 public void setTree(
\r
402 final java.lang.String[] vTreeArray) {
\r
406 for (int i = 0; i < vTreeArray.length; i++) {
\r
407 this._treeList.add(vTreeArray[i]);
\r
412 * Method unmarshal.
\r
415 * @throws org.exolab.castor.xml.MarshalException if object is
\r
416 * null or if any SAXException is thrown during marshaling
\r
417 * @throws org.exolab.castor.xml.ValidationException if this
\r
418 * object is an invalid instance according to the schema
\r
419 * @return the unmarshaled jalview.schemabinding.version2.VAMSAS
\r
421 public static jalview.schemabinding.version2.VAMSAS unmarshal(
\r
422 final java.io.Reader reader)
\r
423 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
424 return (jalview.schemabinding.version2.VAMSAS) Unmarshaller.unmarshal(jalview.schemabinding.version2.VAMSAS.class, reader);
\r
430 * @throws org.exolab.castor.xml.ValidationException if this
\r
431 * object is an invalid instance according to the schema
\r
433 public void validate(
\r
435 throws org.exolab.castor.xml.ValidationException {
\r
436 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
437 validator.validate(this);
\r