2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, 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.binding;
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 VAMSAS implements java.io.Serializable
35 // --------------------------/
36 // - Class/Member Variables -/
37 // --------------------------/
40 * Field _alignmentList.
42 private java.util.Vector _alignmentList;
47 private java.util.Vector _treeList;
50 * Field _sequenceSetList.
52 private java.util.Vector _sequenceSetList;
61 this._alignmentList = new java.util.Vector();
62 this._treeList = new java.util.Vector();
63 this._sequenceSetList = new java.util.Vector();
74 * @throws java.lang.IndexOutOfBoundsException
75 * if the index given is outside the bounds of the collection
77 public void addAlignment(final Alignment vAlignment)
78 throws java.lang.IndexOutOfBoundsException
80 this._alignmentList.addElement(vAlignment);
88 * @throws java.lang.IndexOutOfBoundsException
89 * if the index given is outside the bounds of the collection
91 public void addAlignment(final int index, final Alignment vAlignment)
92 throws java.lang.IndexOutOfBoundsException
94 this._alignmentList.add(index, vAlignment);
100 * @param vSequenceSet
101 * @throws java.lang.IndexOutOfBoundsException
102 * if the index given is outside the bounds of the collection
104 public void addSequenceSet(final SequenceSet vSequenceSet)
105 throws java.lang.IndexOutOfBoundsException
107 this._sequenceSetList.addElement(vSequenceSet);
114 * @param vSequenceSet
115 * @throws java.lang.IndexOutOfBoundsException
116 * if the index given is outside the bounds of the collection
118 public void addSequenceSet(final int index, final SequenceSet vSequenceSet)
119 throws java.lang.IndexOutOfBoundsException
121 this._sequenceSetList.add(index, vSequenceSet);
128 * @throws java.lang.IndexOutOfBoundsException
129 * if the index given is outside the bounds of the collection
131 public void addTree(final java.lang.String vTree)
132 throws java.lang.IndexOutOfBoundsException
134 this._treeList.addElement(vTree);
142 * @throws java.lang.IndexOutOfBoundsException
143 * if the index given is outside the bounds of the collection
145 public void addTree(final int index, final java.lang.String vTree)
146 throws java.lang.IndexOutOfBoundsException
148 this._treeList.add(index, vTree);
152 * Method enumerateAlignment.
154 * @return an Enumeration over all Alignment elements
156 public java.util.Enumeration enumerateAlignment()
158 return this._alignmentList.elements();
162 * Method enumerateSequenceSet.
164 * @return an Enumeration over all SequenceSet elements
166 public java.util.Enumeration enumerateSequenceSet()
168 return this._sequenceSetList.elements();
172 * Method enumerateTree.
174 * @return an Enumeration over all java.lang.String elements
176 public java.util.Enumeration enumerateTree()
178 return this._treeList.elements();
182 * Method getAlignment.
185 * @throws java.lang.IndexOutOfBoundsException
186 * if the index given is outside the bounds of the collection
187 * @return the value of the Alignment at the given index
189 public Alignment getAlignment(final int index)
190 throws java.lang.IndexOutOfBoundsException
192 // check bounds for index
193 if (index < 0 || index >= this._alignmentList.size())
195 throw new IndexOutOfBoundsException("getAlignment: Index value '"
196 + index + "' not in range [0.."
197 + (this._alignmentList.size() - 1) + "]");
200 return (Alignment) _alignmentList.get(index);
204 * Method getAlignment.Returns the contents of the collection in an Array.
206 * Note: Just in case the collection contents are changing in another thread,
207 * we pass a 0-length Array of the correct type into the API call. This way we
208 * <i>know</i> that the Array returned is of exactly the correct length.
210 * @return this collection as an Array
212 public Alignment[] getAlignment()
214 Alignment[] array = new Alignment[0];
215 return (Alignment[]) this._alignmentList.toArray(array);
219 * Method getAlignmentCount.
221 * @return the size of this collection
223 public int getAlignmentCount()
225 return this._alignmentList.size();
229 * Method getSequenceSet.
232 * @throws java.lang.IndexOutOfBoundsException
233 * if the index given is outside the bounds of the collection
234 * @return the value of the SequenceSet at the given index
236 public SequenceSet getSequenceSet(final int index)
237 throws java.lang.IndexOutOfBoundsException
239 // check bounds for index
240 if (index < 0 || index >= this._sequenceSetList.size())
242 throw new IndexOutOfBoundsException("getSequenceSet: Index value '"
243 + index + "' not in range [0.."
244 + (this._sequenceSetList.size() - 1) + "]");
247 return (SequenceSet) _sequenceSetList.get(index);
251 * Method getSequenceSet.Returns the contents of the collection in an Array.
253 * Note: Just in case the collection contents are changing in another thread,
254 * we pass a 0-length Array of the correct type into the API call. This way we
255 * <i>know</i> that the Array returned is of exactly the correct length.
257 * @return this collection as an Array
259 public SequenceSet[] getSequenceSet()
261 SequenceSet[] array = new SequenceSet[0];
262 return (SequenceSet[]) this._sequenceSetList.toArray(array);
266 * Method getSequenceSetCount.
268 * @return the size of this collection
270 public int getSequenceSetCount()
272 return this._sequenceSetList.size();
279 * @throws java.lang.IndexOutOfBoundsException
280 * if the index given is outside the bounds of the collection
281 * @return the value of the java.lang.String at the given index
283 public java.lang.String getTree(final int index)
284 throws java.lang.IndexOutOfBoundsException
286 // check bounds for index
287 if (index < 0 || index >= this._treeList.size())
289 throw new IndexOutOfBoundsException("getTree: Index value '" + index
290 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
293 return (java.lang.String) _treeList.get(index);
297 * Method getTree.Returns the contents of the collection in an Array.
299 * Note: Just in case the collection contents are changing in another thread,
300 * we pass a 0-length Array of the correct type into the API call. This way we
301 * <i>know</i> that the Array returned is of exactly the correct length.
303 * @return this collection as an Array
305 public java.lang.String[] getTree()
307 java.lang.String[] array = new java.lang.String[0];
308 return (java.lang.String[]) this._treeList.toArray(array);
312 * Method getTreeCount.
314 * @return the size of this collection
316 public int getTreeCount()
318 return this._treeList.size();
324 * @return true if this object is valid according to the schema
326 public boolean isValid()
331 } catch (org.exolab.castor.xml.ValidationException vex)
342 * @throws org.exolab.castor.xml.MarshalException
343 * if object is null or if any SAXException is thrown during
345 * @throws org.exolab.castor.xml.ValidationException
346 * if this object is an invalid instance according to the schema
348 public void marshal(final java.io.Writer out)
349 throws org.exolab.castor.xml.MarshalException,
350 org.exolab.castor.xml.ValidationException
352 Marshaller.marshal(this, out);
359 * @throws java.io.IOException
360 * if an IOException occurs during marshaling
361 * @throws org.exolab.castor.xml.ValidationException
362 * if this object is an invalid instance according to the schema
363 * @throws org.exolab.castor.xml.MarshalException
364 * if object is null or if any SAXException is thrown during
367 public void marshal(final org.xml.sax.ContentHandler handler)
368 throws java.io.IOException,
369 org.exolab.castor.xml.MarshalException,
370 org.exolab.castor.xml.ValidationException
372 Marshaller.marshal(this, handler);
376 * Method removeAlignment.
379 * @return true if the object was removed from the collection.
381 public boolean removeAlignment(final Alignment vAlignment)
383 boolean removed = _alignmentList.remove(vAlignment);
388 * Method removeAlignmentAt.
391 * @return the element removed from the collection
393 public Alignment removeAlignmentAt(final int index)
395 java.lang.Object obj = this._alignmentList.remove(index);
396 return (Alignment) obj;
401 public void removeAllAlignment()
403 this._alignmentList.clear();
408 public void removeAllSequenceSet()
410 this._sequenceSetList.clear();
415 public void removeAllTree()
417 this._treeList.clear();
421 * Method removeSequenceSet.
423 * @param vSequenceSet
424 * @return true if the object was removed from the collection.
426 public boolean removeSequenceSet(final SequenceSet vSequenceSet)
428 boolean removed = _sequenceSetList.remove(vSequenceSet);
433 * Method removeSequenceSetAt.
436 * @return the element removed from the collection
438 public SequenceSet removeSequenceSetAt(final int index)
440 java.lang.Object obj = this._sequenceSetList.remove(index);
441 return (SequenceSet) obj;
448 * @return true if the object was removed from the collection.
450 public boolean removeTree(final java.lang.String vTree)
452 boolean removed = _treeList.remove(vTree);
457 * Method removeTreeAt.
460 * @return the element removed from the collection
462 public java.lang.String removeTreeAt(final int index)
464 java.lang.Object obj = this._treeList.remove(index);
465 return (java.lang.String) obj;
473 * @throws java.lang.IndexOutOfBoundsException
474 * if the index given is outside the bounds of the collection
476 public void setAlignment(final int index, final Alignment vAlignment)
477 throws java.lang.IndexOutOfBoundsException
479 // check bounds for index
480 if (index < 0 || index >= this._alignmentList.size())
482 throw new IndexOutOfBoundsException("setAlignment: Index value '"
483 + index + "' not in range [0.."
484 + (this._alignmentList.size() - 1) + "]");
487 this._alignmentList.set(index, vAlignment);
493 * @param vAlignmentArray
495 public void setAlignment(final Alignment[] vAlignmentArray)
498 _alignmentList.clear();
500 for (int i = 0; i < vAlignmentArray.length; i++)
502 this._alignmentList.add(vAlignmentArray[i]);
510 * @param vSequenceSet
511 * @throws java.lang.IndexOutOfBoundsException
512 * if the index given is outside the bounds of the collection
514 public void setSequenceSet(final int index, final SequenceSet vSequenceSet)
515 throws java.lang.IndexOutOfBoundsException
517 // check bounds for index
518 if (index < 0 || index >= this._sequenceSetList.size())
520 throw new IndexOutOfBoundsException("setSequenceSet: Index value '"
521 + index + "' not in range [0.."
522 + (this._sequenceSetList.size() - 1) + "]");
525 this._sequenceSetList.set(index, vSequenceSet);
531 * @param vSequenceSetArray
533 public void setSequenceSet(final SequenceSet[] vSequenceSetArray)
536 _sequenceSetList.clear();
538 for (int i = 0; i < vSequenceSetArray.length; i++)
540 this._sequenceSetList.add(vSequenceSetArray[i]);
549 * @throws java.lang.IndexOutOfBoundsException
550 * if the index given is outside the bounds of the collection
552 public void setTree(final int index, final java.lang.String vTree)
553 throws java.lang.IndexOutOfBoundsException
555 // check bounds for index
556 if (index < 0 || index >= this._treeList.size())
558 throw new IndexOutOfBoundsException("setTree: Index value '" + index
559 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
562 this._treeList.set(index, vTree);
570 public void setTree(final java.lang.String[] vTreeArray)
575 for (int i = 0; i < vTreeArray.length; i++)
577 this._treeList.add(vTreeArray[i]);
585 * @throws org.exolab.castor.xml.MarshalException
586 * if object is null or if any SAXException is thrown during
588 * @throws org.exolab.castor.xml.ValidationException
589 * if this object is an invalid instance according to the schema
590 * @return the unmarshaled jalview.binding.VAMSAS
592 public static jalview.binding.VAMSAS unmarshal(final java.io.Reader reader)
593 throws org.exolab.castor.xml.MarshalException,
594 org.exolab.castor.xml.ValidationException
596 return (jalview.binding.VAMSAS) Unmarshaller.unmarshal(
597 jalview.binding.VAMSAS.class, reader);
603 * @throws org.exolab.castor.xml.ValidationException
604 * if this object is an invalid instance according to the schema
606 public void validate() throws org.exolab.castor.xml.ValidationException
608 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
609 validator.validate(this);