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.schemabinding.version2;
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 // --------------------------/
47 private java.util.Vector _treeList;
50 * Field _sequenceSetList.
52 private java.util.Vector _sequenceSetList;
61 this._treeList = new java.util.Vector();
62 this._sequenceSetList = new java.util.Vector();
73 * @throws java.lang.IndexOutOfBoundsException
74 * if the index given is outside the bounds of the collection
76 public void addSequenceSet(
77 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
78 throws java.lang.IndexOutOfBoundsException
80 this._sequenceSetList.addElement(vSequenceSet);
88 * @throws java.lang.IndexOutOfBoundsException
89 * if the index given is outside the bounds of the collection
91 public void addSequenceSet(final int index,
92 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
93 throws java.lang.IndexOutOfBoundsException
95 this._sequenceSetList.add(index, vSequenceSet);
102 * @throws java.lang.IndexOutOfBoundsException
103 * if the index given is outside the bounds of the collection
105 public void addTree(final java.lang.String vTree)
106 throws java.lang.IndexOutOfBoundsException
108 this._treeList.addElement(vTree);
116 * @throws java.lang.IndexOutOfBoundsException
117 * if the index given is outside the bounds of the collection
119 public void addTree(final int index, final java.lang.String vTree)
120 throws java.lang.IndexOutOfBoundsException
122 this._treeList.add(index, vTree);
126 * Method enumerateSequenceSet.
128 * @return an Enumeration over all jalview.schemabinding.version2.SequenceSet
131 public java.util.Enumeration enumerateSequenceSet()
133 return this._sequenceSetList.elements();
137 * Method enumerateTree.
139 * @return an Enumeration over all java.lang.String elements
141 public java.util.Enumeration enumerateTree()
143 return this._treeList.elements();
147 * Method getSequenceSet.
150 * @throws java.lang.IndexOutOfBoundsException
151 * if the index given is outside the bounds of the collection
152 * @return the value of the jalview.schemabinding.version2.SequenceSet at the
155 public jalview.schemabinding.version2.SequenceSet getSequenceSet(
156 final int index) throws java.lang.IndexOutOfBoundsException
158 // check bounds for index
159 if (index < 0 || index >= this._sequenceSetList.size())
161 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
163 Integer.valueOf(index).toString(),
164 Integer.valueOf((this._sequenceSetList.size() - 1)).toString()
168 return (jalview.schemabinding.version2.SequenceSet) _sequenceSetList
173 * Method getSequenceSet.Returns the contents of the collection in an Array.
175 * Note: Just in case the collection contents are changing in another thread,
176 * we pass a 0-length Array of the correct type into the API call. This way we
177 * <i>know</i> that the Array returned is of exactly the correct length.
179 * @return this collection as an Array
181 public jalview.schemabinding.version2.SequenceSet[] getSequenceSet()
183 jalview.schemabinding.version2.SequenceSet[] array = new jalview.schemabinding.version2.SequenceSet[0];
184 return (jalview.schemabinding.version2.SequenceSet[]) this._sequenceSetList
189 * Method getSequenceSetCount.
191 * @return the size of this collection
193 public int getSequenceSetCount()
195 return this._sequenceSetList.size();
202 * @throws java.lang.IndexOutOfBoundsException
203 * if the index given is outside the bounds of the collection
204 * @return the value of the java.lang.String at the given index
206 public java.lang.String getTree(final int index)
207 throws java.lang.IndexOutOfBoundsException
209 // check bounds for index
210 if (index < 0 || index >= this._treeList.size())
212 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
214 Integer.valueOf(index).toString(),
215 Integer.valueOf((this._treeList.size() - 1)).toString()
219 return (java.lang.String) _treeList.get(index);
223 * Method getTree.Returns the contents of the collection in an Array.
225 * Note: Just in case the collection contents are changing in another thread,
226 * we pass a 0-length Array of the correct type into the API call. This way we
227 * <i>know</i> that the Array returned is of exactly the correct length.
229 * @return this collection as an Array
231 public java.lang.String[] getTree()
233 java.lang.String[] array = new java.lang.String[0];
234 return (java.lang.String[]) this._treeList.toArray(array);
238 * Method getTreeCount.
240 * @return the size of this collection
242 public int getTreeCount()
244 return this._treeList.size();
250 * @return true if this object is valid according to the schema
252 public boolean isValid()
257 } catch (org.exolab.castor.xml.ValidationException vex)
268 * @throws org.exolab.castor.xml.MarshalException
269 * if object is null or if any SAXException is thrown during
271 * @throws org.exolab.castor.xml.ValidationException
272 * if this object is an invalid instance according to the schema
274 public void marshal(final java.io.Writer out)
275 throws org.exolab.castor.xml.MarshalException,
276 org.exolab.castor.xml.ValidationException
278 Marshaller.marshal(this, out);
285 * @throws java.io.IOException
286 * if an IOException occurs during marshaling
287 * @throws org.exolab.castor.xml.ValidationException
288 * if this object is an invalid instance according to the schema
289 * @throws org.exolab.castor.xml.MarshalException
290 * if object is null or if any SAXException is thrown during
293 public void marshal(final org.xml.sax.ContentHandler handler)
294 throws java.io.IOException,
295 org.exolab.castor.xml.MarshalException,
296 org.exolab.castor.xml.ValidationException
298 Marshaller.marshal(this, handler);
303 public void removeAllSequenceSet()
305 this._sequenceSetList.clear();
310 public void removeAllTree()
312 this._treeList.clear();
316 * Method removeSequenceSet.
318 * @param vSequenceSet
319 * @return true if the object was removed from the collection.
321 public boolean removeSequenceSet(
322 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
324 boolean removed = _sequenceSetList.remove(vSequenceSet);
329 * Method removeSequenceSetAt.
332 * @return the element removed from the collection
334 public jalview.schemabinding.version2.SequenceSet removeSequenceSetAt(
337 java.lang.Object obj = this._sequenceSetList.remove(index);
338 return (jalview.schemabinding.version2.SequenceSet) obj;
345 * @return true if the object was removed from the collection.
347 public boolean removeTree(final java.lang.String vTree)
349 boolean removed = _treeList.remove(vTree);
354 * Method removeTreeAt.
357 * @return the element removed from the collection
359 public java.lang.String removeTreeAt(final int index)
361 java.lang.Object obj = this._treeList.remove(index);
362 return (java.lang.String) obj;
369 * @param vSequenceSet
370 * @throws java.lang.IndexOutOfBoundsException
371 * if the index given is outside the bounds of the collection
373 public void setSequenceSet(final int index,
374 final jalview.schemabinding.version2.SequenceSet vSequenceSet)
375 throws java.lang.IndexOutOfBoundsException
377 // check bounds for index
378 if (index < 0 || index >= this._sequenceSetList.size())
380 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
382 Integer.valueOf(index).toString(),
383 Integer.valueOf((this._sequenceSetList.size() - 1)).toString()
387 this._sequenceSetList.set(index, vSequenceSet);
393 * @param vSequenceSetArray
395 public void setSequenceSet(
396 final jalview.schemabinding.version2.SequenceSet[] vSequenceSetArray)
399 _sequenceSetList.clear();
401 for (int i = 0; i < vSequenceSetArray.length; i++)
403 this._sequenceSetList.add(vSequenceSetArray[i]);
412 * @throws java.lang.IndexOutOfBoundsException
413 * if the index given is outside the bounds of the collection
415 public void setTree(final int index, final java.lang.String vTree)
416 throws java.lang.IndexOutOfBoundsException
418 // check bounds for index
419 if (index < 0 || index >= this._treeList.size())
421 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
423 Integer.valueOf(index).toString(),
424 Integer.valueOf((this._treeList.size() - 1)).toString()
428 this._treeList.set(index, vTree);
436 public void setTree(final java.lang.String[] vTreeArray)
441 for (int i = 0; i < vTreeArray.length; i++)
443 this._treeList.add(vTreeArray[i]);
451 * @throws org.exolab.castor.xml.MarshalException
452 * if object is null or if any SAXException is thrown during
454 * @throws org.exolab.castor.xml.ValidationException
455 * if this object is an invalid instance according to the schema
456 * @return the unmarshaled jalview.schemabinding.version2.VAMSAS
458 public static jalview.schemabinding.version2.VAMSAS unmarshal(
459 final java.io.Reader reader)
460 throws org.exolab.castor.xml.MarshalException,
461 org.exolab.castor.xml.ValidationException
463 return (jalview.schemabinding.version2.VAMSAS) Unmarshaller.unmarshal(
464 jalview.schemabinding.version2.VAMSAS.class, reader);
470 * @throws org.exolab.castor.xml.ValidationException
471 * if this object is an invalid instance according to the schema
473 public void validate() throws org.exolab.castor.xml.ValidationException
475 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
476 validator.validate(this);