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.schemabinding.version2;
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 // --------------------------/
43 private java.util.Vector _treeList;
46 * Field _sequenceSetList.
48 private java.util.Vector _sequenceSetList;
57 this._treeList = new java.util.Vector();
58 this._sequenceSetList = new java.util.Vector();
69 * @throws java.lang.IndexOutOfBoundsException
70 * if the index given is outside the bounds of the collection
72 public void addSequenceSet(
73 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
74 throws java.lang.IndexOutOfBoundsException
76 this._sequenceSetList.addElement(vSequenceSet);
84 * @throws java.lang.IndexOutOfBoundsException
85 * if the index given is outside the bounds of the collection
87 public void addSequenceSet(final int index,
88 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
89 throws java.lang.IndexOutOfBoundsException
91 this._sequenceSetList.add(index, vSequenceSet);
98 * @throws java.lang.IndexOutOfBoundsException
99 * if the index given is outside the bounds of the collection
101 public void addTree(final java.lang.String vTree)
102 throws java.lang.IndexOutOfBoundsException
104 this._treeList.addElement(vTree);
112 * @throws java.lang.IndexOutOfBoundsException
113 * if the index given is outside the bounds of the collection
115 public void addTree(final int index, final java.lang.String vTree)
116 throws java.lang.IndexOutOfBoundsException
118 this._treeList.add(index, vTree);
122 * Method enumerateSequenceSet.
124 * @return an Enumeration over all jalview.schemabinding.version2.SequenceSet
127 public java.util.Enumeration enumerateSequenceSet()
129 return this._sequenceSetList.elements();
133 * Method enumerateTree.
135 * @return an Enumeration over all java.lang.String elements
137 public java.util.Enumeration enumerateTree()
139 return this._treeList.elements();
143 * Method getSequenceSet.
146 * @throws java.lang.IndexOutOfBoundsException
147 * if the index given is outside the bounds of the collection
148 * @return the value of the jalview.schemabinding.version2.SequenceSet at the
151 public jalview.schemabinding.version2.SequenceSet getSequenceSet(
152 final int index) throws java.lang.IndexOutOfBoundsException
154 // check bounds for index
155 if (index < 0 || index >= this._sequenceSetList.size())
157 throw new IndexOutOfBoundsException("getSequenceSet: Index value '"
158 + index + "' not in range [0.."
159 + (this._sequenceSetList.size() - 1) + "]");
162 return (jalview.schemabinding.version2.SequenceSet) _sequenceSetList
167 * Method getSequenceSet.Returns the contents of the collection in an Array.
169 * Note: Just in case the collection contents are changing in another thread,
170 * we pass a 0-length Array of the correct type into the API call. This way we
171 * <i>know</i> that the Array returned is of exactly the correct length.
173 * @return this collection as an Array
175 public jalview.schemabinding.version2.SequenceSet[] getSequenceSet()
177 jalview.schemabinding.version2.SequenceSet[] array = new jalview.schemabinding.version2.SequenceSet[0];
178 return (jalview.schemabinding.version2.SequenceSet[]) this._sequenceSetList
183 * Method getSequenceSetCount.
185 * @return the size of this collection
187 public int getSequenceSetCount()
189 return this._sequenceSetList.size();
196 * @throws java.lang.IndexOutOfBoundsException
197 * if the index given is outside the bounds of the collection
198 * @return the value of the java.lang.String at the given index
200 public java.lang.String getTree(final int index)
201 throws java.lang.IndexOutOfBoundsException
203 // check bounds for index
204 if (index < 0 || index >= this._treeList.size())
206 throw new IndexOutOfBoundsException("getTree: Index value '" + index
207 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
210 return (java.lang.String) _treeList.get(index);
214 * Method getTree.Returns the contents of the collection in an Array.
216 * Note: Just in case the collection contents are changing in another thread,
217 * we pass a 0-length Array of the correct type into the API call. This way we
218 * <i>know</i> that the Array returned is of exactly the correct length.
220 * @return this collection as an Array
222 public java.lang.String[] getTree()
224 java.lang.String[] array = new java.lang.String[0];
225 return (java.lang.String[]) this._treeList.toArray(array);
229 * Method getTreeCount.
231 * @return the size of this collection
233 public int getTreeCount()
235 return this._treeList.size();
241 * @return true if this object is valid according to the schema
243 public boolean isValid()
248 } catch (org.exolab.castor.xml.ValidationException vex)
259 * @throws org.exolab.castor.xml.MarshalException
260 * if object is null or if any SAXException is thrown during
262 * @throws org.exolab.castor.xml.ValidationException
263 * if this object is an invalid instance according to the schema
265 public void marshal(final java.io.Writer out)
266 throws org.exolab.castor.xml.MarshalException,
267 org.exolab.castor.xml.ValidationException
269 Marshaller.marshal(this, out);
276 * @throws java.io.IOException
277 * if an IOException occurs during marshaling
278 * @throws org.exolab.castor.xml.ValidationException
279 * if this object is an invalid instance according to the schema
280 * @throws org.exolab.castor.xml.MarshalException
281 * if object is null or if any SAXException is thrown during
284 public void marshal(final org.xml.sax.ContentHandler handler)
285 throws java.io.IOException,
286 org.exolab.castor.xml.MarshalException,
287 org.exolab.castor.xml.ValidationException
289 Marshaller.marshal(this, handler);
294 public void removeAllSequenceSet()
296 this._sequenceSetList.clear();
301 public void removeAllTree()
303 this._treeList.clear();
307 * Method removeSequenceSet.
309 * @param vSequenceSet
310 * @return true if the object was removed from the collection.
312 public boolean removeSequenceSet(
313 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
315 boolean removed = _sequenceSetList.remove(vSequenceSet);
320 * Method removeSequenceSetAt.
323 * @return the element removed from the collection
325 public jalview.schemabinding.version2.SequenceSet removeSequenceSetAt(
328 java.lang.Object obj = this._sequenceSetList.remove(index);
329 return (jalview.schemabinding.version2.SequenceSet) obj;
336 * @return true if the object was removed from the collection.
338 public boolean removeTree(final java.lang.String vTree)
340 boolean removed = _treeList.remove(vTree);
345 * Method removeTreeAt.
348 * @return the element removed from the collection
350 public java.lang.String removeTreeAt(final int index)
352 java.lang.Object obj = this._treeList.remove(index);
353 return (java.lang.String) obj;
360 * @param vSequenceSet
361 * @throws java.lang.IndexOutOfBoundsException
362 * if the index given is outside the bounds of the collection
364 public void setSequenceSet(final int index,
365 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
366 throws java.lang.IndexOutOfBoundsException
368 // check bounds for index
369 if (index < 0 || index >= this._sequenceSetList.size())
371 throw new IndexOutOfBoundsException("setSequenceSet: Index value '"
372 + index + "' not in range [0.."
373 + (this._sequenceSetList.size() - 1) + "]");
376 this._sequenceSetList.set(index, vSequenceSet);
382 * @param vSequenceSetArray
384 public void setSequenceSet(
385 final jalview.schemabinding.version2.SequenceSet[] vSequenceSetArray)
388 _sequenceSetList.clear();
390 for (int i = 0; i < vSequenceSetArray.length; i++)
392 this._sequenceSetList.add(vSequenceSetArray[i]);
401 * @throws java.lang.IndexOutOfBoundsException
402 * if the index given is outside the bounds of the collection
404 public void setTree(final int index, final java.lang.String vTree)
405 throws java.lang.IndexOutOfBoundsException
407 // check bounds for index
408 if (index < 0 || index >= this._treeList.size())
410 throw new IndexOutOfBoundsException("setTree: Index value '" + index
411 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
414 this._treeList.set(index, vTree);
422 public void setTree(final java.lang.String[] vTreeArray)
427 for (int i = 0; i < vTreeArray.length; i++)
429 this._treeList.add(vTreeArray[i]);
437 * @throws org.exolab.castor.xml.MarshalException
438 * if object is null or if any SAXException is thrown during
440 * @throws org.exolab.castor.xml.ValidationException
441 * if this object is an invalid instance according to the schema
442 * @return the unmarshaled jalview.schemabinding.version2.VAMSAS
444 public static jalview.schemabinding.version2.VAMSAS unmarshal(
445 final java.io.Reader reader)
446 throws org.exolab.castor.xml.MarshalException,
447 org.exolab.castor.xml.ValidationException
449 return (jalview.schemabinding.version2.VAMSAS) Unmarshaller.unmarshal(
450 jalview.schemabinding.version2.VAMSAS.class, reader);
456 * @throws org.exolab.castor.xml.ValidationException
457 * if this object is an invalid instance according to the schema
459 public void validate() throws org.exolab.castor.xml.ValidationException
461 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
462 validator.validate(this);