2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
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
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.schemabinding.version2;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import org.exolab.castor.xml.Marshaller;
28 import org.exolab.castor.xml.Unmarshaller;
33 * @version $Revision$ $Date$
35 public class VAMSAS implements java.io.Serializable
38 // --------------------------/
39 // - Class/Member Variables -/
40 // --------------------------/
45 private java.util.Vector _treeList;
48 * Field _sequenceSetList.
50 private java.util.Vector _sequenceSetList;
59 this._treeList = new java.util.Vector();
60 this._sequenceSetList = new java.util.Vector();
71 * @throws java.lang.IndexOutOfBoundsException
72 * if the index given is outside the bounds of the collection
74 public void addSequenceSet(
75 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
76 throws java.lang.IndexOutOfBoundsException
78 this._sequenceSetList.addElement(vSequenceSet);
86 * @throws java.lang.IndexOutOfBoundsException
87 * if the index given is outside the bounds of the collection
89 public void addSequenceSet(final int index,
90 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
91 throws java.lang.IndexOutOfBoundsException
93 this._sequenceSetList.add(index, vSequenceSet);
100 * @throws java.lang.IndexOutOfBoundsException
101 * if the index given is outside the bounds of the collection
103 public void addTree(final java.lang.String vTree)
104 throws java.lang.IndexOutOfBoundsException
106 this._treeList.addElement(vTree);
114 * @throws java.lang.IndexOutOfBoundsException
115 * if the index given is outside the bounds of the collection
117 public void addTree(final int index, final java.lang.String vTree)
118 throws java.lang.IndexOutOfBoundsException
120 this._treeList.add(index, vTree);
124 * Method enumerateSequenceSet.
126 * @return an Enumeration over all jalview.schemabinding.version2.SequenceSet
129 public java.util.Enumeration enumerateSequenceSet()
131 return this._sequenceSetList.elements();
135 * Method enumerateTree.
137 * @return an Enumeration over all java.lang.String elements
139 public java.util.Enumeration enumerateTree()
141 return this._treeList.elements();
145 * Method getSequenceSet.
148 * @throws java.lang.IndexOutOfBoundsException
149 * if the index given is outside the bounds of the collection
150 * @return the value of the jalview.schemabinding.version2.SequenceSet at the
153 public jalview.schemabinding.version2.SequenceSet getSequenceSet(
154 final int index) throws java.lang.IndexOutOfBoundsException
156 // check bounds for index
157 if (index < 0 || index >= this._sequenceSetList.size())
159 throw new IndexOutOfBoundsException("getSequenceSet: Index value '"
160 + index + "' not in range [0.."
161 + (this._sequenceSetList.size() - 1) + "]");
164 return (jalview.schemabinding.version2.SequenceSet) _sequenceSetList
169 * Method getSequenceSet.Returns the contents of the collection in an Array.
171 * Note: Just in case the collection contents are changing in another thread,
172 * we pass a 0-length Array of the correct type into the API call. This way we
173 * <i>know</i> that the Array returned is of exactly the correct length.
175 * @return this collection as an Array
177 public jalview.schemabinding.version2.SequenceSet[] getSequenceSet()
179 jalview.schemabinding.version2.SequenceSet[] array = new jalview.schemabinding.version2.SequenceSet[0];
180 return (jalview.schemabinding.version2.SequenceSet[]) this._sequenceSetList
185 * Method getSequenceSetCount.
187 * @return the size of this collection
189 public int getSequenceSetCount()
191 return this._sequenceSetList.size();
198 * @throws java.lang.IndexOutOfBoundsException
199 * if the index given is outside the bounds of the collection
200 * @return the value of the java.lang.String at the given index
202 public java.lang.String getTree(final int index)
203 throws java.lang.IndexOutOfBoundsException
205 // check bounds for index
206 if (index < 0 || index >= this._treeList.size())
208 throw new IndexOutOfBoundsException("getTree: Index value '" + index
209 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
212 return (java.lang.String) _treeList.get(index);
216 * Method getTree.Returns the contents of the collection in an Array.
218 * Note: Just in case the collection contents are changing in another thread,
219 * we pass a 0-length Array of the correct type into the API call. This way we
220 * <i>know</i> that the Array returned is of exactly the correct length.
222 * @return this collection as an Array
224 public java.lang.String[] getTree()
226 java.lang.String[] array = new java.lang.String[0];
227 return (java.lang.String[]) this._treeList.toArray(array);
231 * Method getTreeCount.
233 * @return the size of this collection
235 public int getTreeCount()
237 return this._treeList.size();
243 * @return true if this object is valid according to the schema
245 public boolean isValid()
250 } catch (org.exolab.castor.xml.ValidationException vex)
261 * @throws org.exolab.castor.xml.MarshalException
262 * if object is null or if any SAXException is thrown during
264 * @throws org.exolab.castor.xml.ValidationException
265 * if this object is an invalid instance according to the schema
267 public void marshal(final java.io.Writer out)
268 throws org.exolab.castor.xml.MarshalException,
269 org.exolab.castor.xml.ValidationException
271 Marshaller.marshal(this, out);
278 * @throws java.io.IOException
279 * if an IOException occurs during marshaling
280 * @throws org.exolab.castor.xml.ValidationException
281 * if this object is an invalid instance according to the schema
282 * @throws org.exolab.castor.xml.MarshalException
283 * if object is null or if any SAXException is thrown during
286 public void marshal(final org.xml.sax.ContentHandler handler)
287 throws java.io.IOException,
288 org.exolab.castor.xml.MarshalException,
289 org.exolab.castor.xml.ValidationException
291 Marshaller.marshal(this, handler);
296 public void removeAllSequenceSet()
298 this._sequenceSetList.clear();
303 public void removeAllTree()
305 this._treeList.clear();
309 * Method removeSequenceSet.
311 * @param vSequenceSet
312 * @return true if the object was removed from the collection.
314 public boolean removeSequenceSet(
315 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
317 boolean removed = _sequenceSetList.remove(vSequenceSet);
322 * Method removeSequenceSetAt.
325 * @return the element removed from the collection
327 public jalview.schemabinding.version2.SequenceSet removeSequenceSetAt(
330 java.lang.Object obj = this._sequenceSetList.remove(index);
331 return (jalview.schemabinding.version2.SequenceSet) obj;
338 * @return true if the object was removed from the collection.
340 public boolean removeTree(final java.lang.String vTree)
342 boolean removed = _treeList.remove(vTree);
347 * Method removeTreeAt.
350 * @return the element removed from the collection
352 public java.lang.String removeTreeAt(final int index)
354 java.lang.Object obj = this._treeList.remove(index);
355 return (java.lang.String) obj;
362 * @param vSequenceSet
363 * @throws java.lang.IndexOutOfBoundsException
364 * if the index given is outside the bounds of the collection
366 public void setSequenceSet(final int index,
367 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
368 throws java.lang.IndexOutOfBoundsException
370 // check bounds for index
371 if (index < 0 || index >= this._sequenceSetList.size())
373 throw new IndexOutOfBoundsException("setSequenceSet: Index value '"
374 + index + "' not in range [0.."
375 + (this._sequenceSetList.size() - 1) + "]");
378 this._sequenceSetList.set(index, vSequenceSet);
384 * @param vSequenceSetArray
386 public void setSequenceSet(
387 final jalview.schemabinding.version2.SequenceSet[] vSequenceSetArray)
390 _sequenceSetList.clear();
392 for (int i = 0; i < vSequenceSetArray.length; i++)
394 this._sequenceSetList.add(vSequenceSetArray[i]);
403 * @throws java.lang.IndexOutOfBoundsException
404 * if the index given is outside the bounds of the collection
406 public void setTree(final int index, final java.lang.String vTree)
407 throws java.lang.IndexOutOfBoundsException
409 // check bounds for index
410 if (index < 0 || index >= this._treeList.size())
412 throw new IndexOutOfBoundsException("setTree: Index value '" + index
413 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
416 this._treeList.set(index, vTree);
424 public void setTree(final java.lang.String[] vTreeArray)
429 for (int i = 0; i < vTreeArray.length; i++)
431 this._treeList.add(vTreeArray[i]);
439 * @throws org.exolab.castor.xml.MarshalException
440 * if object is null or if any SAXException is thrown during
442 * @throws org.exolab.castor.xml.ValidationException
443 * if this object is an invalid instance according to the schema
444 * @return the unmarshaled jalview.schemabinding.version2.VAMSAS
446 public static jalview.schemabinding.version2.VAMSAS unmarshal(
447 final java.io.Reader reader)
448 throws org.exolab.castor.xml.MarshalException,
449 org.exolab.castor.xml.ValidationException
451 return (jalview.schemabinding.version2.VAMSAS) Unmarshaller.unmarshal(
452 jalview.schemabinding.version2.VAMSAS.class, reader);
458 * @throws org.exolab.castor.xml.ValidationException
459 * if this object is an invalid instance according to the schema
461 public void validate() throws org.exolab.castor.xml.ValidationException
463 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
464 validator.validate(this);