2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.binding;
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 VAMSAS implements java.io.Serializable {
36 //--------------------------/
37 //- Class/Member Variables -/
38 //--------------------------/
41 * Field _alignmentList.
43 private java.util.Vector _alignmentList;
48 private java.util.Vector _treeList;
51 * Field _sequenceSetList.
53 private java.util.Vector _sequenceSetList;
62 this._alignmentList = new java.util.Vector();
63 this._treeList = new java.util.Vector();
64 this._sequenceSetList = new java.util.Vector();
76 * @throws java.lang.IndexOutOfBoundsException if the index
77 * given is outside the bounds of the collection
79 public void addAlignment(
80 final Alignment vAlignment)
81 throws java.lang.IndexOutOfBoundsException {
82 this._alignmentList.addElement(vAlignment);
90 * @throws java.lang.IndexOutOfBoundsException if the index
91 * given is outside the bounds of the collection
93 public void addAlignment(
95 final Alignment vAlignment)
96 throws java.lang.IndexOutOfBoundsException {
97 this._alignmentList.add(index, vAlignment);
103 * @param vSequenceSet
104 * @throws java.lang.IndexOutOfBoundsException if the index
105 * given is outside the bounds of the collection
107 public void addSequenceSet(
108 final SequenceSet vSequenceSet)
109 throws java.lang.IndexOutOfBoundsException {
110 this._sequenceSetList.addElement(vSequenceSet);
117 * @param vSequenceSet
118 * @throws java.lang.IndexOutOfBoundsException if the index
119 * given is outside the bounds of the collection
121 public void addSequenceSet(
123 final SequenceSet vSequenceSet)
124 throws java.lang.IndexOutOfBoundsException {
125 this._sequenceSetList.add(index, vSequenceSet);
132 * @throws java.lang.IndexOutOfBoundsException if the index
133 * given is outside the bounds of the collection
136 final java.lang.String vTree)
137 throws java.lang.IndexOutOfBoundsException {
138 this._treeList.addElement(vTree);
146 * @throws java.lang.IndexOutOfBoundsException if the index
147 * given is outside the bounds of the collection
151 final java.lang.String vTree)
152 throws java.lang.IndexOutOfBoundsException {
153 this._treeList.add(index, vTree);
157 * Method enumerateAlignment.
159 * @return an Enumeration over all Alignment elements
161 public java.util.Enumeration enumerateAlignment(
163 return this._alignmentList.elements();
167 * Method enumerateSequenceSet.
169 * @return an Enumeration over all SequenceSet elements
171 public java.util.Enumeration enumerateSequenceSet(
173 return this._sequenceSetList.elements();
177 * Method enumerateTree.
179 * @return an Enumeration over all java.lang.String elements
181 public java.util.Enumeration enumerateTree(
183 return this._treeList.elements();
187 * Method getAlignment.
190 * @throws java.lang.IndexOutOfBoundsException if the index
191 * given is outside the bounds of the collection
192 * @return the value of the Alignment at the given index
194 public Alignment getAlignment(
196 throws java.lang.IndexOutOfBoundsException {
197 // check bounds for index
198 if (index < 0 || index >= this._alignmentList.size()) {
199 throw new IndexOutOfBoundsException("getAlignment: Index value '" + index + "' not in range [0.." + (this._alignmentList.size() - 1) + "]");
202 return (Alignment) _alignmentList.get(index);
206 * Method getAlignment.Returns the contents of the collection
207 * in an Array. <p>Note: Just in case the collection contents
208 * are changing in another thread, we pass a 0-length Array of
209 * the correct type into the API call. This way we <i>know</i>
210 * that the Array returned is of exactly the correct length.
212 * @return this collection as an Array
214 public Alignment[] getAlignment(
216 Alignment[] array = new Alignment[0];
217 return (Alignment[]) this._alignmentList.toArray(array);
221 * Method getAlignmentCount.
223 * @return the size of this collection
225 public int getAlignmentCount(
227 return this._alignmentList.size();
231 * Method getSequenceSet.
234 * @throws java.lang.IndexOutOfBoundsException if the index
235 * given is outside the bounds of the collection
236 * @return the value of the SequenceSet at the given index
238 public SequenceSet getSequenceSet(
240 throws java.lang.IndexOutOfBoundsException {
241 // check bounds for index
242 if (index < 0 || index >= this._sequenceSetList.size()) {
243 throw new IndexOutOfBoundsException("getSequenceSet: Index value '" + index + "' not in range [0.." + (this._sequenceSetList.size() - 1) + "]");
246 return (SequenceSet) _sequenceSetList.get(index);
250 * Method getSequenceSet.Returns the contents of the collection
251 * in an Array. <p>Note: Just in case the collection contents
252 * are changing in another thread, we pass a 0-length Array of
253 * the correct type into the API call. This way we <i>know</i>
254 * that the Array returned is of exactly the correct length.
256 * @return this collection as an Array
258 public SequenceSet[] getSequenceSet(
260 SequenceSet[] array = new SequenceSet[0];
261 return (SequenceSet[]) this._sequenceSetList.toArray(array);
265 * Method getSequenceSetCount.
267 * @return the size of this collection
269 public int getSequenceSetCount(
271 return this._sequenceSetList.size();
278 * @throws java.lang.IndexOutOfBoundsException if the index
279 * given is outside the bounds of the collection
280 * @return the value of the java.lang.String at the given index
282 public java.lang.String getTree(
284 throws java.lang.IndexOutOfBoundsException {
285 // check bounds for index
286 if (index < 0 || index >= this._treeList.size()) {
287 throw new IndexOutOfBoundsException("getTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]");
290 return (java.lang.String) _treeList.get(index);
294 * Method getTree.Returns the contents of the collection in an
295 * Array. <p>Note: Just in case the collection contents are
296 * changing in another thread, we pass a 0-length Array of the
297 * correct type into the API call. This way we <i>know</i>
298 * that the Array returned is of exactly the correct length.
300 * @return this collection as an Array
302 public java.lang.String[] getTree(
304 java.lang.String[] array = new java.lang.String[0];
305 return (java.lang.String[]) this._treeList.toArray(array);
309 * Method getTreeCount.
311 * @return the size of this collection
313 public int getTreeCount(
315 return this._treeList.size();
321 * @return true if this object is valid according to the schema
323 public boolean isValid(
327 } catch (org.exolab.castor.xml.ValidationException vex) {
337 * @throws org.exolab.castor.xml.MarshalException if object is
338 * null or if any SAXException is thrown during marshaling
339 * @throws org.exolab.castor.xml.ValidationException if this
340 * object is an invalid instance according to the schema
343 final java.io.Writer out)
344 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
345 Marshaller.marshal(this, out);
352 * @throws java.io.IOException if an IOException occurs during
354 * @throws org.exolab.castor.xml.ValidationException if this
355 * object is an invalid instance according to the schema
356 * @throws org.exolab.castor.xml.MarshalException if object is
357 * null or if any SAXException is thrown during marshaling
360 final org.xml.sax.ContentHandler handler)
361 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
362 Marshaller.marshal(this, handler);
366 * Method removeAlignment.
369 * @return true if the object was removed from the collection.
371 public boolean removeAlignment(
372 final Alignment vAlignment) {
373 boolean removed = _alignmentList.remove(vAlignment);
378 * Method removeAlignmentAt.
381 * @return the element removed from the collection
383 public Alignment removeAlignmentAt(
385 java.lang.Object obj = this._alignmentList.remove(index);
386 return (Alignment) obj;
391 public void removeAllAlignment(
393 this._alignmentList.clear();
398 public void removeAllSequenceSet(
400 this._sequenceSetList.clear();
405 public void removeAllTree(
407 this._treeList.clear();
411 * Method removeSequenceSet.
413 * @param vSequenceSet
414 * @return true if the object was removed from the collection.
416 public boolean removeSequenceSet(
417 final SequenceSet vSequenceSet) {
418 boolean removed = _sequenceSetList.remove(vSequenceSet);
423 * Method removeSequenceSetAt.
426 * @return the element removed from the collection
428 public SequenceSet removeSequenceSetAt(
430 java.lang.Object obj = this._sequenceSetList.remove(index);
431 return (SequenceSet) obj;
438 * @return true if the object was removed from the collection.
440 public boolean removeTree(
441 final java.lang.String vTree) {
442 boolean removed = _treeList.remove(vTree);
447 * Method removeTreeAt.
450 * @return the element removed from the collection
452 public java.lang.String removeTreeAt(
454 java.lang.Object obj = this._treeList.remove(index);
455 return (java.lang.String) obj;
463 * @throws java.lang.IndexOutOfBoundsException if the index
464 * given is outside the bounds of the collection
466 public void setAlignment(
468 final Alignment vAlignment)
469 throws java.lang.IndexOutOfBoundsException {
470 // check bounds for index
471 if (index < 0 || index >= this._alignmentList.size()) {
472 throw new IndexOutOfBoundsException("setAlignment: Index value '" + index + "' not in range [0.." + (this._alignmentList.size() - 1) + "]");
475 this._alignmentList.set(index, vAlignment);
481 * @param vAlignmentArray
483 public void setAlignment(
484 final Alignment[] vAlignmentArray) {
486 _alignmentList.clear();
488 for (int i = 0; i < vAlignmentArray.length; i++) {
489 this._alignmentList.add(vAlignmentArray[i]);
497 * @param vSequenceSet
498 * @throws java.lang.IndexOutOfBoundsException if the index
499 * given is outside the bounds of the collection
501 public void setSequenceSet(
503 final SequenceSet vSequenceSet)
504 throws java.lang.IndexOutOfBoundsException {
505 // check bounds for index
506 if (index < 0 || index >= this._sequenceSetList.size()) {
507 throw new IndexOutOfBoundsException("setSequenceSet: Index value '" + index + "' not in range [0.." + (this._sequenceSetList.size() - 1) + "]");
510 this._sequenceSetList.set(index, vSequenceSet);
516 * @param vSequenceSetArray
518 public void setSequenceSet(
519 final SequenceSet[] vSequenceSetArray) {
521 _sequenceSetList.clear();
523 for (int i = 0; i < vSequenceSetArray.length; i++) {
524 this._sequenceSetList.add(vSequenceSetArray[i]);
533 * @throws java.lang.IndexOutOfBoundsException if the index
534 * given is outside the bounds of the collection
538 final java.lang.String vTree)
539 throws java.lang.IndexOutOfBoundsException {
540 // check bounds for index
541 if (index < 0 || index >= this._treeList.size()) {
542 throw new IndexOutOfBoundsException("setTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]");
545 this._treeList.set(index, vTree);
554 final java.lang.String[] vTreeArray) {
558 for (int i = 0; i < vTreeArray.length; i++) {
559 this._treeList.add(vTreeArray[i]);
567 * @throws org.exolab.castor.xml.MarshalException if object is
568 * null or if any SAXException is thrown during marshaling
569 * @throws org.exolab.castor.xml.ValidationException if this
570 * object is an invalid instance according to the schema
571 * @return the unmarshaled jalview.binding.VAMSAS
573 public static jalview.binding.VAMSAS unmarshal(
574 final java.io.Reader reader)
575 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
576 return (jalview.binding.VAMSAS) Unmarshaller.unmarshal(jalview.binding.VAMSAS.class, reader);
582 * @throws org.exolab.castor.xml.ValidationException if this
583 * object is an invalid instance according to the schema
585 public void validate(
587 throws org.exolab.castor.xml.ValidationException {
588 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
589 validator.validate(this);