2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 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 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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
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();
75 * @throws java.lang.IndexOutOfBoundsException
76 * if the index given is outside the bounds of the collection
78 public void addAlignment(final Alignment vAlignment)
79 throws java.lang.IndexOutOfBoundsException
81 this._alignmentList.addElement(vAlignment);
89 * @throws java.lang.IndexOutOfBoundsException
90 * if the index given is outside the bounds of the collection
92 public void addAlignment(final int index, final Alignment vAlignment)
93 throws java.lang.IndexOutOfBoundsException
95 this._alignmentList.add(index, vAlignment);
101 * @param vSequenceSet
102 * @throws java.lang.IndexOutOfBoundsException
103 * if the index given is outside the bounds of the collection
105 public void addSequenceSet(final SequenceSet vSequenceSet)
106 throws java.lang.IndexOutOfBoundsException
108 this._sequenceSetList.addElement(vSequenceSet);
115 * @param vSequenceSet
116 * @throws java.lang.IndexOutOfBoundsException
117 * if the index given is outside the bounds of the collection
119 public void addSequenceSet(final int index, final SequenceSet vSequenceSet)
120 throws java.lang.IndexOutOfBoundsException
122 this._sequenceSetList.add(index, vSequenceSet);
129 * @throws java.lang.IndexOutOfBoundsException
130 * if the index given is outside the bounds of the collection
132 public void addTree(final java.lang.String vTree)
133 throws java.lang.IndexOutOfBoundsException
135 this._treeList.addElement(vTree);
143 * @throws java.lang.IndexOutOfBoundsException
144 * if the index given is outside the bounds of the collection
146 public void addTree(final int index, final java.lang.String vTree)
147 throws java.lang.IndexOutOfBoundsException
149 this._treeList.add(index, vTree);
153 * Method enumerateAlignment.
155 * @return an Enumeration over all Alignment elements
157 public java.util.Enumeration enumerateAlignment()
159 return this._alignmentList.elements();
163 * Method enumerateSequenceSet.
165 * @return an Enumeration over all SequenceSet elements
167 public java.util.Enumeration enumerateSequenceSet()
169 return this._sequenceSetList.elements();
173 * Method enumerateTree.
175 * @return an Enumeration over all java.lang.String elements
177 public java.util.Enumeration enumerateTree()
179 return this._treeList.elements();
183 * Method getAlignment.
186 * @throws java.lang.IndexOutOfBoundsException
187 * if the index given is outside the bounds of the collection
188 * @return the value of the Alignment at the given index
190 public Alignment getAlignment(final int index)
191 throws java.lang.IndexOutOfBoundsException
193 // check bounds for index
194 if (index < 0 || index >= this._alignmentList.size())
196 throw new IndexOutOfBoundsException("getAlignment: Index value '"
197 + index + "' not in range [0.."
198 + (this._alignmentList.size() - 1) + "]");
201 return (Alignment) _alignmentList.get(index);
205 * Method getAlignment.Returns the contents of the collection in an Array.
207 * Note: Just in case the collection contents are changing in another thread,
208 * we pass a 0-length Array of the correct type into the API call. This way we
209 * <i>know</i> that the Array returned is of exactly the correct length.
211 * @return this collection as an Array
213 public Alignment[] getAlignment()
215 Alignment[] array = new Alignment[0];
216 return (Alignment[]) this._alignmentList.toArray(array);
220 * Method getAlignmentCount.
222 * @return the size of this collection
224 public int getAlignmentCount()
226 return this._alignmentList.size();
230 * Method getSequenceSet.
233 * @throws java.lang.IndexOutOfBoundsException
234 * if the index given is outside the bounds of the collection
235 * @return the value of the SequenceSet at the given index
237 public SequenceSet getSequenceSet(final int index)
238 throws java.lang.IndexOutOfBoundsException
240 // check bounds for index
241 if (index < 0 || index >= this._sequenceSetList.size())
243 throw new IndexOutOfBoundsException("getSequenceSet: Index value '"
244 + index + "' not in range [0.."
245 + (this._sequenceSetList.size() - 1) + "]");
248 return (SequenceSet) _sequenceSetList.get(index);
252 * Method getSequenceSet.Returns the contents of the collection in an Array.
254 * Note: Just in case the collection contents are changing in another thread,
255 * we pass a 0-length Array of the correct type into the API call. This way we
256 * <i>know</i> that the Array returned is of exactly the correct length.
258 * @return this collection as an Array
260 public SequenceSet[] getSequenceSet()
262 SequenceSet[] array = new SequenceSet[0];
263 return (SequenceSet[]) this._sequenceSetList.toArray(array);
267 * Method getSequenceSetCount.
269 * @return the size of this collection
271 public int getSequenceSetCount()
273 return this._sequenceSetList.size();
280 * @throws java.lang.IndexOutOfBoundsException
281 * if the index given is outside the bounds of the collection
282 * @return the value of the java.lang.String at the given index
284 public java.lang.String getTree(final int index)
285 throws java.lang.IndexOutOfBoundsException
287 // check bounds for index
288 if (index < 0 || index >= this._treeList.size())
290 throw new IndexOutOfBoundsException("getTree: Index value '" + index
291 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
294 return (java.lang.String) _treeList.get(index);
298 * Method getTree.Returns the contents of the collection in an Array.
300 * Note: Just in case the collection contents are changing in another thread,
301 * we pass a 0-length Array of the correct type into the API call. This way we
302 * <i>know</i> that the Array returned is of exactly the correct length.
304 * @return this collection as an Array
306 public java.lang.String[] getTree()
308 java.lang.String[] array = new java.lang.String[0];
309 return (java.lang.String[]) this._treeList.toArray(array);
313 * Method getTreeCount.
315 * @return the size of this collection
317 public int getTreeCount()
319 return this._treeList.size();
325 * @return true if this object is valid according to the schema
327 public boolean isValid()
332 } catch (org.exolab.castor.xml.ValidationException vex)
343 * @throws org.exolab.castor.xml.MarshalException
344 * if object is null or if any SAXException is thrown during
346 * @throws org.exolab.castor.xml.ValidationException
347 * if this object is an invalid instance according to the schema
349 public void marshal(final java.io.Writer out)
350 throws org.exolab.castor.xml.MarshalException,
351 org.exolab.castor.xml.ValidationException
353 Marshaller.marshal(this, out);
360 * @throws java.io.IOException
361 * if an IOException occurs during marshaling
362 * @throws org.exolab.castor.xml.ValidationException
363 * if this object is an invalid instance according to the schema
364 * @throws org.exolab.castor.xml.MarshalException
365 * if object is null or if any SAXException is thrown during
368 public void marshal(final org.xml.sax.ContentHandler handler)
369 throws java.io.IOException,
370 org.exolab.castor.xml.MarshalException,
371 org.exolab.castor.xml.ValidationException
373 Marshaller.marshal(this, handler);
377 * Method removeAlignment.
380 * @return true if the object was removed from the collection.
382 public boolean removeAlignment(final Alignment vAlignment)
384 boolean removed = _alignmentList.remove(vAlignment);
389 * Method removeAlignmentAt.
392 * @return the element removed from the collection
394 public Alignment removeAlignmentAt(final int index)
396 java.lang.Object obj = this._alignmentList.remove(index);
397 return (Alignment) obj;
402 public void removeAllAlignment()
404 this._alignmentList.clear();
409 public void removeAllSequenceSet()
411 this._sequenceSetList.clear();
416 public void removeAllTree()
418 this._treeList.clear();
422 * Method removeSequenceSet.
424 * @param vSequenceSet
425 * @return true if the object was removed from the collection.
427 public boolean removeSequenceSet(final SequenceSet vSequenceSet)
429 boolean removed = _sequenceSetList.remove(vSequenceSet);
434 * Method removeSequenceSetAt.
437 * @return the element removed from the collection
439 public SequenceSet removeSequenceSetAt(final int index)
441 java.lang.Object obj = this._sequenceSetList.remove(index);
442 return (SequenceSet) obj;
449 * @return true if the object was removed from the collection.
451 public boolean removeTree(final java.lang.String vTree)
453 boolean removed = _treeList.remove(vTree);
458 * Method removeTreeAt.
461 * @return the element removed from the collection
463 public java.lang.String removeTreeAt(final int index)
465 java.lang.Object obj = this._treeList.remove(index);
466 return (java.lang.String) obj;
474 * @throws java.lang.IndexOutOfBoundsException
475 * if the index given is outside the bounds of the collection
477 public void setAlignment(final int index, final Alignment vAlignment)
478 throws java.lang.IndexOutOfBoundsException
480 // check bounds for index
481 if (index < 0 || index >= this._alignmentList.size())
483 throw new IndexOutOfBoundsException("setAlignment: Index value '"
484 + index + "' not in range [0.."
485 + (this._alignmentList.size() - 1) + "]");
488 this._alignmentList.set(index, vAlignment);
494 * @param vAlignmentArray
496 public void setAlignment(final Alignment[] vAlignmentArray)
499 _alignmentList.clear();
501 for (int i = 0; i < vAlignmentArray.length; i++)
503 this._alignmentList.add(vAlignmentArray[i]);
511 * @param vSequenceSet
512 * @throws java.lang.IndexOutOfBoundsException
513 * if the index given is outside the bounds of the collection
515 public void setSequenceSet(final int index, final SequenceSet vSequenceSet)
516 throws java.lang.IndexOutOfBoundsException
518 // check bounds for index
519 if (index < 0 || index >= this._sequenceSetList.size())
521 throw new IndexOutOfBoundsException("setSequenceSet: Index value '"
522 + index + "' not in range [0.."
523 + (this._sequenceSetList.size() - 1) + "]");
526 this._sequenceSetList.set(index, vSequenceSet);
532 * @param vSequenceSetArray
534 public void setSequenceSet(final SequenceSet[] vSequenceSetArray)
537 _sequenceSetList.clear();
539 for (int i = 0; i < vSequenceSetArray.length; i++)
541 this._sequenceSetList.add(vSequenceSetArray[i]);
550 * @throws java.lang.IndexOutOfBoundsException
551 * if the index given is outside the bounds of the collection
553 public void setTree(final int index, final java.lang.String vTree)
554 throws java.lang.IndexOutOfBoundsException
556 // check bounds for index
557 if (index < 0 || index >= this._treeList.size())
559 throw new IndexOutOfBoundsException("setTree: Index value '" + index
560 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
563 this._treeList.set(index, vTree);
571 public void setTree(final java.lang.String[] vTreeArray)
576 for (int i = 0; i < vTreeArray.length; i++)
578 this._treeList.add(vTreeArray[i]);
586 * @throws org.exolab.castor.xml.MarshalException
587 * if object is null or if any SAXException is thrown during
589 * @throws org.exolab.castor.xml.ValidationException
590 * if this object is an invalid instance according to the schema
591 * @return the unmarshaled jalview.binding.VAMSAS
593 public static jalview.binding.VAMSAS unmarshal(final java.io.Reader reader)
594 throws org.exolab.castor.xml.MarshalException,
595 org.exolab.castor.xml.ValidationException
597 return (jalview.binding.VAMSAS) Unmarshaller.unmarshal(
598 jalview.binding.VAMSAS.class, reader);
604 * @throws org.exolab.castor.xml.ValidationException
605 * if this object is an invalid instance according to the schema
607 public void validate() throws org.exolab.castor.xml.ValidationException
609 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
610 validator.validate(this);