2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
\r
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.schemabinding.version2;
\r
20 //---------------------------------/
\r
21 //- Imported classes and packages -/
\r
22 //---------------------------------/
\r
24 import org.exolab.castor.xml.Marshaller;
\r
25 import org.exolab.castor.xml.Unmarshaller;
\r
30 * @version $Revision$ $Date$
\r
32 public class VAMSAS implements java.io.Serializable
\r
35 // --------------------------/
\r
36 // - Class/Member Variables -/
\r
37 // --------------------------/
\r
42 private java.util.Vector _treeList;
\r
45 * Field _sequenceSetList.
\r
47 private java.util.Vector _sequenceSetList;
\r
49 // ----------------/
\r
50 // - Constructors -/
\r
51 // ----------------/
\r
56 this._treeList = new java.util.Vector();
\r
57 this._sequenceSetList = new java.util.Vector();
\r
67 * @param vSequenceSet
\r
68 * @throws java.lang.IndexOutOfBoundsException
\r
69 * if the index given is outside the bounds of the collection
\r
71 public void addSequenceSet(
\r
72 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
73 throws java.lang.IndexOutOfBoundsException
\r
75 this._sequenceSetList.addElement(vSequenceSet);
\r
82 * @param vSequenceSet
\r
83 * @throws java.lang.IndexOutOfBoundsException
\r
84 * if the index given is outside the bounds of the collection
\r
86 public void addSequenceSet(final int index,
\r
87 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
88 throws java.lang.IndexOutOfBoundsException
\r
90 this._sequenceSetList.add(index, vSequenceSet);
\r
97 * @throws java.lang.IndexOutOfBoundsException
\r
98 * if the index given is outside the bounds of the collection
\r
100 public void addTree(final java.lang.String vTree)
\r
101 throws java.lang.IndexOutOfBoundsException
\r
103 this._treeList.addElement(vTree);
\r
111 * @throws java.lang.IndexOutOfBoundsException
\r
112 * if the index given is outside the bounds of the collection
\r
114 public void addTree(final int index, final java.lang.String vTree)
\r
115 throws java.lang.IndexOutOfBoundsException
\r
117 this._treeList.add(index, vTree);
\r
121 * Method enumerateSequenceSet.
\r
123 * @return an Enumeration over all jalview.schemabinding.version2.SequenceSet
\r
126 public java.util.Enumeration enumerateSequenceSet()
\r
128 return this._sequenceSetList.elements();
\r
132 * Method enumerateTree.
\r
134 * @return an Enumeration over all java.lang.String elements
\r
136 public java.util.Enumeration enumerateTree()
\r
138 return this._treeList.elements();
\r
142 * Method getSequenceSet.
\r
145 * @throws java.lang.IndexOutOfBoundsException
\r
146 * if the index given is outside the bounds of the collection
\r
147 * @return the value of the jalview.schemabinding.version2.SequenceSet at the
\r
150 public jalview.schemabinding.version2.SequenceSet getSequenceSet(
\r
151 final int index) throws java.lang.IndexOutOfBoundsException
\r
153 // check bounds for index
\r
154 if (index < 0 || index >= this._sequenceSetList.size())
\r
156 throw new IndexOutOfBoundsException("getSequenceSet: Index value '"
\r
157 + index + "' not in range [0.."
\r
158 + (this._sequenceSetList.size() - 1) + "]");
\r
161 return (jalview.schemabinding.version2.SequenceSet) _sequenceSetList
\r
166 * Method getSequenceSet.Returns the contents of the collection in an Array.
\r
168 * Note: Just in case the collection contents are changing in another thread,
\r
169 * we pass a 0-length Array of the correct type into the API call. This way we
\r
170 * <i>know</i> that the Array returned is of exactly the correct length.
\r
172 * @return this collection as an Array
\r
174 public jalview.schemabinding.version2.SequenceSet[] getSequenceSet()
\r
176 jalview.schemabinding.version2.SequenceSet[] array = new jalview.schemabinding.version2.SequenceSet[0];
\r
177 return (jalview.schemabinding.version2.SequenceSet[]) this._sequenceSetList
\r
182 * Method getSequenceSetCount.
\r
184 * @return the size of this collection
\r
186 public int getSequenceSetCount()
\r
188 return this._sequenceSetList.size();
\r
195 * @throws java.lang.IndexOutOfBoundsException
\r
196 * if the index given is outside the bounds of the collection
\r
197 * @return the value of the java.lang.String at the given index
\r
199 public java.lang.String getTree(final int index)
\r
200 throws java.lang.IndexOutOfBoundsException
\r
202 // check bounds for index
\r
203 if (index < 0 || index >= this._treeList.size())
\r
205 throw new IndexOutOfBoundsException("getTree: Index value '" + index
\r
206 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
\r
209 return (java.lang.String) _treeList.get(index);
\r
213 * Method getTree.Returns the contents of the collection in an Array.
\r
215 * Note: Just in case the collection contents are changing in another thread,
\r
216 * we pass a 0-length Array of the correct type into the API call. This way we
\r
217 * <i>know</i> that the Array returned is of exactly the correct length.
\r
219 * @return this collection as an Array
\r
221 public java.lang.String[] getTree()
\r
223 java.lang.String[] array = new java.lang.String[0];
\r
224 return (java.lang.String[]) this._treeList.toArray(array);
\r
228 * Method getTreeCount.
\r
230 * @return the size of this collection
\r
232 public int getTreeCount()
\r
234 return this._treeList.size();
\r
240 * @return true if this object is valid according to the schema
\r
242 public boolean isValid()
\r
247 } catch (org.exolab.castor.xml.ValidationException vex)
\r
258 * @throws org.exolab.castor.xml.MarshalException
\r
259 * if object is null or if any SAXException is thrown during
\r
261 * @throws org.exolab.castor.xml.ValidationException
\r
262 * if this object is an invalid instance according to the schema
\r
264 public void marshal(final java.io.Writer out)
\r
265 throws org.exolab.castor.xml.MarshalException,
\r
266 org.exolab.castor.xml.ValidationException
\r
268 Marshaller.marshal(this, out);
\r
275 * @throws java.io.IOException
\r
276 * if an IOException occurs during marshaling
\r
277 * @throws org.exolab.castor.xml.ValidationException
\r
278 * if this object is an invalid instance according to the schema
\r
279 * @throws org.exolab.castor.xml.MarshalException
\r
280 * if object is null or if any SAXException is thrown during
\r
283 public void marshal(final org.xml.sax.ContentHandler handler)
\r
284 throws java.io.IOException,
\r
285 org.exolab.castor.xml.MarshalException,
\r
286 org.exolab.castor.xml.ValidationException
\r
288 Marshaller.marshal(this, handler);
\r
293 public void removeAllSequenceSet()
\r
295 this._sequenceSetList.clear();
\r
300 public void removeAllTree()
\r
302 this._treeList.clear();
\r
306 * Method removeSequenceSet.
\r
308 * @param vSequenceSet
\r
309 * @return true if the object was removed from the collection.
\r
311 public boolean removeSequenceSet(
\r
312 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
314 boolean removed = _sequenceSetList.remove(vSequenceSet);
\r
319 * Method removeSequenceSetAt.
\r
322 * @return the element removed from the collection
\r
324 public jalview.schemabinding.version2.SequenceSet removeSequenceSetAt(
\r
327 java.lang.Object obj = this._sequenceSetList.remove(index);
\r
328 return (jalview.schemabinding.version2.SequenceSet) obj;
\r
332 * Method removeTree.
\r
335 * @return true if the object was removed from the collection.
\r
337 public boolean removeTree(final java.lang.String vTree)
\r
339 boolean removed = _treeList.remove(vTree);
\r
344 * Method removeTreeAt.
\r
347 * @return the element removed from the collection
\r
349 public java.lang.String removeTreeAt(final int index)
\r
351 java.lang.Object obj = this._treeList.remove(index);
\r
352 return (java.lang.String) obj;
\r
359 * @param vSequenceSet
\r
360 * @throws java.lang.IndexOutOfBoundsException
\r
361 * if the index given is outside the bounds of the collection
\r
363 public void setSequenceSet(final int index,
\r
364 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
\r
365 throws java.lang.IndexOutOfBoundsException
\r
367 // check bounds for index
\r
368 if (index < 0 || index >= this._sequenceSetList.size())
\r
370 throw new IndexOutOfBoundsException("setSequenceSet: Index value '"
\r
371 + index + "' not in range [0.."
\r
372 + (this._sequenceSetList.size() - 1) + "]");
\r
375 this._sequenceSetList.set(index, vSequenceSet);
\r
381 * @param vSequenceSetArray
\r
383 public void setSequenceSet(
\r
384 final jalview.schemabinding.version2.SequenceSet[] vSequenceSetArray)
\r
387 _sequenceSetList.clear();
\r
389 for (int i = 0; i < vSequenceSetArray.length; i++)
\r
391 this._sequenceSetList.add(vSequenceSetArray[i]);
\r
400 * @throws java.lang.IndexOutOfBoundsException
\r
401 * if the index given is outside the bounds of the collection
\r
403 public void setTree(final int index, final java.lang.String vTree)
\r
404 throws java.lang.IndexOutOfBoundsException
\r
406 // check bounds for index
\r
407 if (index < 0 || index >= this._treeList.size())
\r
409 throw new IndexOutOfBoundsException("setTree: Index value '" + index
\r
410 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
\r
413 this._treeList.set(index, vTree);
\r
419 * @param vTreeArray
\r
421 public void setTree(final java.lang.String[] vTreeArray)
\r
426 for (int i = 0; i < vTreeArray.length; i++)
\r
428 this._treeList.add(vTreeArray[i]);
\r
433 * Method unmarshal.
\r
436 * @throws org.exolab.castor.xml.MarshalException
\r
437 * if object is null or if any SAXException is thrown during
\r
439 * @throws org.exolab.castor.xml.ValidationException
\r
440 * if this object is an invalid instance according to the schema
\r
441 * @return the unmarshaled jalview.schemabinding.version2.VAMSAS
\r
443 public static jalview.schemabinding.version2.VAMSAS unmarshal(
\r
444 final java.io.Reader reader)
\r
445 throws org.exolab.castor.xml.MarshalException,
\r
446 org.exolab.castor.xml.ValidationException
\r
448 return (jalview.schemabinding.version2.VAMSAS) Unmarshaller.unmarshal(
\r
449 jalview.schemabinding.version2.VAMSAS.class, reader);
\r
455 * @throws org.exolab.castor.xml.ValidationException
\r
456 * if this object is an invalid instance according to the schema
\r
458 public void validate() throws org.exolab.castor.xml.ValidationException
\r
460 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
461 validator.validate(this);
\r