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 AlcodonFrame implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
47 private java.util.Vector _alcodonList;
50 * Field _alcodMapList.
52 private java.util.Vector _alcodMapList;
61 this._alcodonList = new java.util.Vector();
62 this._alcodMapList = new java.util.Vector();
73 * @throws java.lang.IndexOutOfBoundsException
74 * if the index given is outside the bounds of the collection
76 public void addAlcodMap(
77 final jalview.schemabinding.version2.AlcodMap vAlcodMap)
78 throws java.lang.IndexOutOfBoundsException
80 this._alcodMapList.addElement(vAlcodMap);
88 * @throws java.lang.IndexOutOfBoundsException
89 * if the index given is outside the bounds of the collection
91 public void addAlcodMap(final int index,
92 final jalview.schemabinding.version2.AlcodMap vAlcodMap)
93 throws java.lang.IndexOutOfBoundsException
95 this._alcodMapList.add(index, vAlcodMap);
102 * @throws java.lang.IndexOutOfBoundsException
103 * if the index given is outside the bounds of the collection
105 public void addAlcodon(
106 final jalview.schemabinding.version2.Alcodon vAlcodon)
107 throws java.lang.IndexOutOfBoundsException
109 this._alcodonList.addElement(vAlcodon);
117 * @throws java.lang.IndexOutOfBoundsException
118 * if the index given is outside the bounds of the collection
120 public void addAlcodon(final int index,
121 final jalview.schemabinding.version2.Alcodon vAlcodon)
122 throws java.lang.IndexOutOfBoundsException
124 this._alcodonList.add(index, vAlcodon);
128 * Method enumerateAlcodMap.
130 * @return an Enumeration over all jalview.schemabinding.version2.AlcodMap
133 public java.util.Enumeration enumerateAlcodMap()
135 return this._alcodMapList.elements();
139 * Method enumerateAlcodon.
141 * @return an Enumeration over all jalview.schemabinding.version2.Alcodon
144 public java.util.Enumeration enumerateAlcodon()
146 return this._alcodonList.elements();
150 * Method getAlcodMap.
153 * @throws java.lang.IndexOutOfBoundsException
154 * if the index given is outside the bounds of the collection
155 * @return the value of the jalview.schemabinding.version2.AlcodMap at the
158 public jalview.schemabinding.version2.AlcodMap getAlcodMap(final int index)
159 throws java.lang.IndexOutOfBoundsException
161 // check bounds for index
162 if (index < 0 || index >= this._alcodMapList.size())
164 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
166 Integer.valueOf(index).toString(),
167 Integer.valueOf((this._alcodMapList.size() - 1)).toString()
171 return (jalview.schemabinding.version2.AlcodMap) _alcodMapList
176 * Method getAlcodMap.Returns the contents of the collection in an Array.
178 * Note: Just in case the collection contents are changing in another thread,
179 * we pass a 0-length Array of the correct type into the API call. This way we
180 * <i>know</i> that the Array returned is of exactly the correct length.
182 * @return this collection as an Array
184 public jalview.schemabinding.version2.AlcodMap[] getAlcodMap()
186 jalview.schemabinding.version2.AlcodMap[] array = new jalview.schemabinding.version2.AlcodMap[0];
187 return (jalview.schemabinding.version2.AlcodMap[]) this._alcodMapList
192 * Method getAlcodMapCount.
194 * @return the size of this collection
196 public int getAlcodMapCount()
198 return this._alcodMapList.size();
205 * @throws java.lang.IndexOutOfBoundsException
206 * if the index given is outside the bounds of the collection
207 * @return the value of the jalview.schemabinding.version2.Alcodon at the
210 public jalview.schemabinding.version2.Alcodon getAlcodon(final int index)
211 throws java.lang.IndexOutOfBoundsException
213 // check bounds for index
214 if (index < 0 || index >= this._alcodonList.size())
216 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
218 Integer.valueOf(index).toString(),
219 Integer.valueOf((this._alcodonList.size() - 1)).toString()
223 return (jalview.schemabinding.version2.Alcodon) _alcodonList.get(index);
227 * Method getAlcodon.Returns the contents of the collection in an Array.
229 * Note: Just in case the collection contents are changing in another thread,
230 * we pass a 0-length Array of the correct type into the API call. This way we
231 * <i>know</i> that the Array returned is of exactly the correct length.
233 * @return this collection as an Array
235 public jalview.schemabinding.version2.Alcodon[] getAlcodon()
237 jalview.schemabinding.version2.Alcodon[] array = new jalview.schemabinding.version2.Alcodon[0];
238 return (jalview.schemabinding.version2.Alcodon[]) this._alcodonList
243 * Method getAlcodonCount.
245 * @return the size of this collection
247 public int getAlcodonCount()
249 return this._alcodonList.size();
255 * @return true if this object is valid according to the schema
257 public boolean isValid()
262 } catch (org.exolab.castor.xml.ValidationException vex)
273 * @throws org.exolab.castor.xml.MarshalException
274 * if object is null or if any SAXException is thrown during
276 * @throws org.exolab.castor.xml.ValidationException
277 * if this object is an invalid instance according to the schema
279 public void marshal(final java.io.Writer out)
280 throws org.exolab.castor.xml.MarshalException,
281 org.exolab.castor.xml.ValidationException
283 Marshaller.marshal(this, out);
290 * @throws java.io.IOException
291 * if an IOException occurs during marshaling
292 * @throws org.exolab.castor.xml.ValidationException
293 * if this object is an invalid instance according to the schema
294 * @throws org.exolab.castor.xml.MarshalException
295 * if object is null or if any SAXException is thrown during
298 public void marshal(final org.xml.sax.ContentHandler handler)
299 throws java.io.IOException,
300 org.exolab.castor.xml.MarshalException,
301 org.exolab.castor.xml.ValidationException
303 Marshaller.marshal(this, handler);
307 * Method removeAlcodMap.
310 * @return true if the object was removed from the collection.
312 public boolean removeAlcodMap(
313 final jalview.schemabinding.version2.AlcodMap vAlcodMap)
315 boolean removed = _alcodMapList.remove(vAlcodMap);
320 * Method removeAlcodMapAt.
323 * @return the element removed from the collection
325 public jalview.schemabinding.version2.AlcodMap removeAlcodMapAt(
328 java.lang.Object obj = this._alcodMapList.remove(index);
329 return (jalview.schemabinding.version2.AlcodMap) obj;
333 * Method removeAlcodon.
336 * @return true if the object was removed from the collection.
338 public boolean removeAlcodon(
339 final jalview.schemabinding.version2.Alcodon vAlcodon)
341 boolean removed = _alcodonList.remove(vAlcodon);
346 * Method removeAlcodonAt.
349 * @return the element removed from the collection
351 public jalview.schemabinding.version2.Alcodon removeAlcodonAt(
354 java.lang.Object obj = this._alcodonList.remove(index);
355 return (jalview.schemabinding.version2.Alcodon) obj;
360 public void removeAllAlcodMap()
362 this._alcodMapList.clear();
367 public void removeAllAlcodon()
369 this._alcodonList.clear();
377 * @throws java.lang.IndexOutOfBoundsException
378 * if the index given is outside the bounds of the collection
380 public void setAlcodMap(final int index,
381 final jalview.schemabinding.version2.AlcodMap vAlcodMap)
382 throws java.lang.IndexOutOfBoundsException
384 // check bounds for index
385 if (index < 0 || index >= this._alcodMapList.size())
387 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
389 Integer.valueOf(index).toString(),
390 Integer.valueOf((this._alcodonList.size() - 1)).toString()
394 this._alcodMapList.set(index, vAlcodMap);
400 * @param vAlcodMapArray
402 public void setAlcodMap(
403 final jalview.schemabinding.version2.AlcodMap[] vAlcodMapArray)
406 _alcodMapList.clear();
408 for (int i = 0; i < vAlcodMapArray.length; i++)
410 this._alcodMapList.add(vAlcodMapArray[i]);
419 * @throws java.lang.IndexOutOfBoundsException
420 * if the index given is outside the bounds of the collection
422 public void setAlcodon(final int index,
423 final jalview.schemabinding.version2.Alcodon vAlcodon)
424 throws java.lang.IndexOutOfBoundsException
426 // check bounds for index
427 if (index < 0 || index >= this._alcodonList.size())
429 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
431 Integer.valueOf(index).toString(),
432 Integer.valueOf((this._alcodonList.size() - 1)).toString()
436 this._alcodonList.set(index, vAlcodon);
442 * @param vAlcodonArray
444 public void setAlcodon(
445 final jalview.schemabinding.version2.Alcodon[] vAlcodonArray)
448 _alcodonList.clear();
450 for (int i = 0; i < vAlcodonArray.length; i++)
452 this._alcodonList.add(vAlcodonArray[i]);
460 * @throws org.exolab.castor.xml.MarshalException
461 * if object is null or if any SAXException is thrown during
463 * @throws org.exolab.castor.xml.ValidationException
464 * if this object is an invalid instance according to the schema
465 * @return the unmarshaled jalview.schemabinding.version2.AlcodonFrame
467 public static jalview.schemabinding.version2.AlcodonFrame unmarshal(
468 final java.io.Reader reader)
469 throws org.exolab.castor.xml.MarshalException,
470 org.exolab.castor.xml.ValidationException
472 return (jalview.schemabinding.version2.AlcodonFrame) Unmarshaller
473 .unmarshal(jalview.schemabinding.version2.AlcodonFrame.class,
480 * @throws org.exolab.castor.xml.ValidationException
481 * if this object is an invalid instance according to the schema
483 public void validate() throws org.exolab.castor.xml.ValidationException
485 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
486 validator.validate(this);