2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, 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.schemabinding.version2;
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 // --------------------------/
42 private java.util.Vector _treeList;
45 * Field _sequenceSetList.
47 private java.util.Vector _sequenceSetList;
56 this._treeList = new java.util.Vector();
57 this._sequenceSetList = new java.util.Vector();
68 * @throws java.lang.IndexOutOfBoundsException
69 * if the index given is outside the bounds of the collection
71 public void addSequenceSet(
72 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
73 throws java.lang.IndexOutOfBoundsException
75 this._sequenceSetList.addElement(vSequenceSet);
83 * @throws java.lang.IndexOutOfBoundsException
84 * if the index given is outside the bounds of the collection
86 public void addSequenceSet(final int index,
87 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
88 throws java.lang.IndexOutOfBoundsException
90 this._sequenceSetList.add(index, vSequenceSet);
97 * @throws java.lang.IndexOutOfBoundsException
98 * if the index given is outside the bounds of the collection
100 public void addTree(final java.lang.String vTree)
101 throws java.lang.IndexOutOfBoundsException
103 this._treeList.addElement(vTree);
111 * @throws java.lang.IndexOutOfBoundsException
112 * if the index given is outside the bounds of the collection
114 public void addTree(final int index, final java.lang.String vTree)
115 throws java.lang.IndexOutOfBoundsException
117 this._treeList.add(index, vTree);
121 * Method enumerateSequenceSet.
123 * @return an Enumeration over all jalview.schemabinding.version2.SequenceSet
126 public java.util.Enumeration enumerateSequenceSet()
128 return this._sequenceSetList.elements();
132 * Method enumerateTree.
134 * @return an Enumeration over all java.lang.String elements
136 public java.util.Enumeration enumerateTree()
138 return this._treeList.elements();
142 * Method getSequenceSet.
145 * @throws java.lang.IndexOutOfBoundsException
146 * if the index given is outside the bounds of the collection
147 * @return the value of the jalview.schemabinding.version2.SequenceSet at the
150 public jalview.schemabinding.version2.SequenceSet getSequenceSet(
151 final int index) throws java.lang.IndexOutOfBoundsException
153 // check bounds for index
154 if (index < 0 || index >= this._sequenceSetList.size())
156 throw new IndexOutOfBoundsException("getSequenceSet: Index value '"
157 + index + "' not in range [0.."
158 + (this._sequenceSetList.size() - 1) + "]");
161 return (jalview.schemabinding.version2.SequenceSet) _sequenceSetList
166 * Method getSequenceSet.Returns the contents of the collection in an Array.
168 * Note: Just in case the collection contents are changing in another thread,
169 * we pass a 0-length Array of the correct type into the API call. This way we
170 * <i>know</i> that the Array returned is of exactly the correct length.
172 * @return this collection as an Array
174 public jalview.schemabinding.version2.SequenceSet[] getSequenceSet()
176 jalview.schemabinding.version2.SequenceSet[] array = new jalview.schemabinding.version2.SequenceSet[0];
177 return (jalview.schemabinding.version2.SequenceSet[]) this._sequenceSetList
182 * Method getSequenceSetCount.
184 * @return the size of this collection
186 public int getSequenceSetCount()
188 return this._sequenceSetList.size();
195 * @throws java.lang.IndexOutOfBoundsException
196 * if the index given is outside the bounds of the collection
197 * @return the value of the java.lang.String at the given index
199 public java.lang.String getTree(final int index)
200 throws java.lang.IndexOutOfBoundsException
202 // check bounds for index
203 if (index < 0 || index >= this._treeList.size())
205 throw new IndexOutOfBoundsException("getTree: Index value '" + index
206 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
209 return (java.lang.String) _treeList.get(index);
213 * Method getTree.Returns the contents of the collection in an Array.
215 * Note: Just in case the collection contents are changing in another thread,
216 * we pass a 0-length Array of the correct type into the API call. This way we
217 * <i>know</i> that the Array returned is of exactly the correct length.
219 * @return this collection as an Array
221 public java.lang.String[] getTree()
223 java.lang.String[] array = new java.lang.String[0];
224 return (java.lang.String[]) this._treeList.toArray(array);
228 * Method getTreeCount.
230 * @return the size of this collection
232 public int getTreeCount()
234 return this._treeList.size();
240 * @return true if this object is valid according to the schema
242 public boolean isValid()
247 } catch (org.exolab.castor.xml.ValidationException vex)
258 * @throws org.exolab.castor.xml.MarshalException
259 * if object is null or if any SAXException is thrown during
261 * @throws org.exolab.castor.xml.ValidationException
262 * if this object is an invalid instance according to the schema
264 public void marshal(final java.io.Writer out)
265 throws org.exolab.castor.xml.MarshalException,
266 org.exolab.castor.xml.ValidationException
268 Marshaller.marshal(this, out);
275 * @throws java.io.IOException
276 * if an IOException occurs during marshaling
277 * @throws org.exolab.castor.xml.ValidationException
278 * if this object is an invalid instance according to the schema
279 * @throws org.exolab.castor.xml.MarshalException
280 * if object is null or if any SAXException is thrown during
283 public void marshal(final org.xml.sax.ContentHandler handler)
284 throws java.io.IOException,
285 org.exolab.castor.xml.MarshalException,
286 org.exolab.castor.xml.ValidationException
288 Marshaller.marshal(this, handler);
293 public void removeAllSequenceSet()
295 this._sequenceSetList.clear();
300 public void removeAllTree()
302 this._treeList.clear();
306 * Method removeSequenceSet.
308 * @param vSequenceSet
309 * @return true if the object was removed from the collection.
311 public boolean removeSequenceSet(
312 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
314 boolean removed = _sequenceSetList.remove(vSequenceSet);
319 * Method removeSequenceSetAt.
322 * @return the element removed from the collection
324 public jalview.schemabinding.version2.SequenceSet removeSequenceSetAt(
327 java.lang.Object obj = this._sequenceSetList.remove(index);
328 return (jalview.schemabinding.version2.SequenceSet) obj;
335 * @return true if the object was removed from the collection.
337 public boolean removeTree(final java.lang.String vTree)
339 boolean removed = _treeList.remove(vTree);
344 * Method removeTreeAt.
347 * @return the element removed from the collection
349 public java.lang.String removeTreeAt(final int index)
351 java.lang.Object obj = this._treeList.remove(index);
352 return (java.lang.String) obj;
359 * @param vSequenceSet
360 * @throws java.lang.IndexOutOfBoundsException
361 * if the index given is outside the bounds of the collection
363 public void setSequenceSet(final int index,
364 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
365 throws java.lang.IndexOutOfBoundsException
367 // check bounds for index
368 if (index < 0 || index >= this._sequenceSetList.size())
370 throw new IndexOutOfBoundsException("setSequenceSet: Index value '"
371 + index + "' not in range [0.."
372 + (this._sequenceSetList.size() - 1) + "]");
375 this._sequenceSetList.set(index, vSequenceSet);
381 * @param vSequenceSetArray
383 public void setSequenceSet(
384 final jalview.schemabinding.version2.SequenceSet[] vSequenceSetArray)
387 _sequenceSetList.clear();
389 for (int i = 0; i < vSequenceSetArray.length; i++)
391 this._sequenceSetList.add(vSequenceSetArray[i]);
400 * @throws java.lang.IndexOutOfBoundsException
401 * if the index given is outside the bounds of the collection
403 public void setTree(final int index, final java.lang.String vTree)
404 throws java.lang.IndexOutOfBoundsException
406 // check bounds for index
407 if (index < 0 || index >= this._treeList.size())
409 throw new IndexOutOfBoundsException("setTree: Index value '" + index
410 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
413 this._treeList.set(index, vTree);
421 public void setTree(final java.lang.String[] vTreeArray)
426 for (int i = 0; i < vTreeArray.length; i++)
428 this._treeList.add(vTreeArray[i]);
436 * @throws org.exolab.castor.xml.MarshalException
437 * if object is null or if any SAXException is thrown during
439 * @throws org.exolab.castor.xml.ValidationException
440 * if this object is an invalid instance according to the schema
441 * @return the unmarshaled jalview.schemabinding.version2.VAMSAS
443 public static jalview.schemabinding.version2.VAMSAS unmarshal(
444 final java.io.Reader reader)
445 throws org.exolab.castor.xml.MarshalException,
446 org.exolab.castor.xml.ValidationException
448 return (jalview.schemabinding.version2.VAMSAS) Unmarshaller.unmarshal(
449 jalview.schemabinding.version2.VAMSAS.class, reader);
455 * @throws org.exolab.castor.xml.ValidationException
456 * if this object is an invalid instance according to the schema
458 public void validate() throws org.exolab.castor.xml.ValidationException
460 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
461 validator.validate(this);