2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.binding;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import jalview.util.MessageManager;
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
35 * @version $Revision$ $Date$
37 public class VAMSAS implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
45 * Field _alignmentList.
47 private java.util.Vector _alignmentList;
52 private java.util.Vector _treeList;
55 * Field _sequenceSetList.
57 private java.util.Vector _sequenceSetList;
66 this._alignmentList = new java.util.Vector();
67 this._treeList = new java.util.Vector();
68 this._sequenceSetList = new java.util.Vector();
79 * @throws java.lang.IndexOutOfBoundsException
80 * if the index given is outside the bounds of the collection
82 public void addAlignment(final Alignment vAlignment)
83 throws java.lang.IndexOutOfBoundsException
85 this._alignmentList.addElement(vAlignment);
93 * @throws java.lang.IndexOutOfBoundsException
94 * if the index given is outside the bounds of the collection
96 public void addAlignment(final int index, final Alignment vAlignment)
97 throws java.lang.IndexOutOfBoundsException
99 this._alignmentList.add(index, vAlignment);
105 * @param vSequenceSet
106 * @throws java.lang.IndexOutOfBoundsException
107 * if the index given is outside the bounds of the collection
109 public void addSequenceSet(final SequenceSet vSequenceSet)
110 throws java.lang.IndexOutOfBoundsException
112 this._sequenceSetList.addElement(vSequenceSet);
119 * @param vSequenceSet
120 * @throws java.lang.IndexOutOfBoundsException
121 * if the index given is outside the bounds of the collection
123 public void addSequenceSet(final int index, final SequenceSet vSequenceSet)
124 throws java.lang.IndexOutOfBoundsException
126 this._sequenceSetList.add(index, vSequenceSet);
133 * @throws java.lang.IndexOutOfBoundsException
134 * if the index given is outside the bounds of the collection
136 public void addTree(final java.lang.String vTree)
137 throws java.lang.IndexOutOfBoundsException
139 this._treeList.addElement(vTree);
147 * @throws java.lang.IndexOutOfBoundsException
148 * if the index given is outside the bounds of the collection
150 public void addTree(final int index, final java.lang.String vTree)
151 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
191 * if the index given is outside the bounds of the collection
192 * @return the value of the Alignment at the given index
194 public Alignment getAlignment(final int index)
195 throws java.lang.IndexOutOfBoundsException
197 // check bounds for index
198 if (index < 0 || index >= this._alignmentList.size())
200 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
202 Integer.valueOf(index).toString(),
203 Integer.valueOf((this._alignmentList.size() - 1)).toString()
207 return (Alignment) _alignmentList.get(index);
211 * Method getAlignment.Returns the contents of the collection in an Array.
213 * Note: Just in case the collection contents are changing in another thread,
214 * we pass a 0-length Array of the correct type into the API call. This way we
215 * <i>know</i> that the Array returned is of exactly the correct length.
217 * @return this collection as an Array
219 public Alignment[] getAlignment()
221 Alignment[] array = new Alignment[0];
222 return (Alignment[]) this._alignmentList.toArray(array);
226 * Method getAlignmentCount.
228 * @return the size of this collection
230 public int getAlignmentCount()
232 return this._alignmentList.size();
236 * Method getSequenceSet.
239 * @throws java.lang.IndexOutOfBoundsException
240 * if the index given is outside the bounds of the collection
241 * @return the value of the SequenceSet at the given index
243 public SequenceSet getSequenceSet(final int index)
244 throws java.lang.IndexOutOfBoundsException
246 // check bounds for index
247 if (index < 0 || index >= this._sequenceSetList.size())
249 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
251 Integer.valueOf(index).toString(),
252 Integer.valueOf((this._sequenceSetList.size() - 1)).toString()
256 return (SequenceSet) _sequenceSetList.get(index);
260 * Method getSequenceSet.Returns the contents of the collection in an Array.
262 * Note: Just in case the collection contents are changing in another thread,
263 * we pass a 0-length Array of the correct type into the API call. This way we
264 * <i>know</i> that the Array returned is of exactly the correct length.
266 * @return this collection as an Array
268 public SequenceSet[] getSequenceSet()
270 SequenceSet[] array = new SequenceSet[0];
271 return (SequenceSet[]) this._sequenceSetList.toArray(array);
275 * Method getSequenceSetCount.
277 * @return the size of this collection
279 public int getSequenceSetCount()
281 return this._sequenceSetList.size();
288 * @throws java.lang.IndexOutOfBoundsException
289 * if the index given is outside the bounds of the collection
290 * @return the value of the java.lang.String at the given index
292 public java.lang.String getTree(final int index)
293 throws java.lang.IndexOutOfBoundsException
295 // check bounds for index
296 if (index < 0 || index >= this._treeList.size())
298 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
300 Integer.valueOf(index).toString(),
301 Integer.valueOf((this._treeList.size() - 1)).toString()
305 return (java.lang.String) _treeList.get(index);
309 * Method getTree.Returns the contents of the collection in an Array.
311 * Note: Just in case the collection contents are changing in another thread,
312 * we pass a 0-length Array of the correct type into the API call. This way we
313 * <i>know</i> that the Array returned is of exactly the correct length.
315 * @return this collection as an Array
317 public java.lang.String[] getTree()
319 java.lang.String[] array = new java.lang.String[0];
320 return (java.lang.String[]) this._treeList.toArray(array);
324 * Method getTreeCount.
326 * @return the size of this collection
328 public int getTreeCount()
330 return this._treeList.size();
336 * @return true if this object is valid according to the schema
338 public boolean isValid()
343 } catch (org.exolab.castor.xml.ValidationException vex)
354 * @throws org.exolab.castor.xml.MarshalException
355 * if object is null or if any SAXException is thrown during
357 * @throws org.exolab.castor.xml.ValidationException
358 * if this object is an invalid instance according to the schema
360 public void marshal(final java.io.Writer out)
361 throws org.exolab.castor.xml.MarshalException,
362 org.exolab.castor.xml.ValidationException
364 Marshaller.marshal(this, out);
371 * @throws java.io.IOException
372 * if an IOException occurs during marshaling
373 * @throws org.exolab.castor.xml.ValidationException
374 * if this object is an invalid instance according to the schema
375 * @throws org.exolab.castor.xml.MarshalException
376 * if object is null or if any SAXException is thrown during
379 public void marshal(final org.xml.sax.ContentHandler handler)
380 throws java.io.IOException,
381 org.exolab.castor.xml.MarshalException,
382 org.exolab.castor.xml.ValidationException
384 Marshaller.marshal(this, handler);
388 * Method removeAlignment.
391 * @return true if the object was removed from the collection.
393 public boolean removeAlignment(final Alignment vAlignment)
395 boolean removed = _alignmentList.remove(vAlignment);
400 * Method removeAlignmentAt.
403 * @return the element removed from the collection
405 public Alignment removeAlignmentAt(final int index)
407 java.lang.Object obj = this._alignmentList.remove(index);
408 return (Alignment) obj;
413 public void removeAllAlignment()
415 this._alignmentList.clear();
420 public void removeAllSequenceSet()
422 this._sequenceSetList.clear();
427 public void removeAllTree()
429 this._treeList.clear();
433 * Method removeSequenceSet.
435 * @param vSequenceSet
436 * @return true if the object was removed from the collection.
438 public boolean removeSequenceSet(final SequenceSet vSequenceSet)
440 boolean removed = _sequenceSetList.remove(vSequenceSet);
445 * Method removeSequenceSetAt.
448 * @return the element removed from the collection
450 public SequenceSet removeSequenceSetAt(final int index)
452 java.lang.Object obj = this._sequenceSetList.remove(index);
453 return (SequenceSet) obj;
460 * @return true if the object was removed from the collection.
462 public boolean removeTree(final java.lang.String vTree)
464 boolean removed = _treeList.remove(vTree);
469 * Method removeTreeAt.
472 * @return the element removed from the collection
474 public java.lang.String removeTreeAt(final int index)
476 java.lang.Object obj = this._treeList.remove(index);
477 return (java.lang.String) obj;
485 * @throws java.lang.IndexOutOfBoundsException
486 * if the index given is outside the bounds of the collection
488 public void setAlignment(final int index, final Alignment vAlignment)
489 throws java.lang.IndexOutOfBoundsException
491 // check bounds for index
492 if (index < 0 || index >= this._alignmentList.size())
494 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
496 Integer.valueOf(index).toString(),
497 Integer.valueOf((this._alignmentList.size() - 1)).toString()
501 this._alignmentList.set(index, vAlignment);
507 * @param vAlignmentArray
509 public void setAlignment(final Alignment[] vAlignmentArray)
512 _alignmentList.clear();
514 for (int i = 0; i < vAlignmentArray.length; i++)
516 this._alignmentList.add(vAlignmentArray[i]);
524 * @param vSequenceSet
525 * @throws java.lang.IndexOutOfBoundsException
526 * if the index given is outside the bounds of the collection
528 public void setSequenceSet(final int index, final SequenceSet vSequenceSet)
529 throws java.lang.IndexOutOfBoundsException
531 // check bounds for index
532 if (index < 0 || index >= this._sequenceSetList.size())
534 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
536 Integer.valueOf(index).toString(),
537 Integer.valueOf((this._sequenceSetList.size() - 1)).toString()
541 this._sequenceSetList.set(index, vSequenceSet);
547 * @param vSequenceSetArray
549 public void setSequenceSet(final SequenceSet[] vSequenceSetArray)
552 _sequenceSetList.clear();
554 for (int i = 0; i < vSequenceSetArray.length; i++)
556 this._sequenceSetList.add(vSequenceSetArray[i]);
565 * @throws java.lang.IndexOutOfBoundsException
566 * if the index given is outside the bounds of the collection
568 public void setTree(final int index, final java.lang.String vTree)
569 throws java.lang.IndexOutOfBoundsException
571 // check bounds for index
572 if (index < 0 || index >= this._treeList.size())
574 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
576 Integer.valueOf(index).toString(),
577 Integer.valueOf((this._treeList.size() - 1)).toString()
581 this._treeList.set(index, vTree);
589 public void setTree(final java.lang.String[] vTreeArray)
594 for (int i = 0; i < vTreeArray.length; i++)
596 this._treeList.add(vTreeArray[i]);
604 * @throws org.exolab.castor.xml.MarshalException
605 * if object is null or if any SAXException is thrown during
607 * @throws org.exolab.castor.xml.ValidationException
608 * if this object is an invalid instance according to the schema
609 * @return the unmarshaled jalview.binding.VAMSAS
611 public static jalview.binding.VAMSAS unmarshal(final java.io.Reader reader)
612 throws org.exolab.castor.xml.MarshalException,
613 org.exolab.castor.xml.ValidationException
615 return (jalview.binding.VAMSAS) Unmarshaller.unmarshal(
616 jalview.binding.VAMSAS.class, reader);
622 * @throws org.exolab.castor.xml.ValidationException
623 * if this object is an invalid instance according to the schema
625 public void validate() throws org.exolab.castor.xml.ValidationException
627 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
628 validator.validate(this);