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
28 * Class AlcodonFrame.
\r
30 * @version $Revision$ $Date$
\r
32 public class AlcodonFrame implements java.io.Serializable
\r
35 // --------------------------/
\r
36 // - Class/Member Variables -/
\r
37 // --------------------------/
\r
40 * Field _alcodonList.
\r
42 private java.util.Vector _alcodonList;
\r
45 * Field _alcodMapList.
\r
47 private java.util.Vector _alcodMapList;
\r
49 // ----------------/
\r
50 // - Constructors -/
\r
51 // ----------------/
\r
53 public AlcodonFrame()
\r
56 this._alcodonList = new java.util.Vector();
\r
57 this._alcodMapList = new java.util.Vector();
\r
68 * @throws java.lang.IndexOutOfBoundsException
\r
69 * if the index given is outside the bounds of the collection
\r
71 public void addAlcodMap(
\r
72 final jalview.schemabinding.version2.AlcodMap vAlcodMap)
\r
73 throws java.lang.IndexOutOfBoundsException
\r
75 this._alcodMapList.addElement(vAlcodMap);
\r
83 * @throws java.lang.IndexOutOfBoundsException
\r
84 * if the index given is outside the bounds of the collection
\r
86 public void addAlcodMap(final int index,
\r
87 final jalview.schemabinding.version2.AlcodMap vAlcodMap)
\r
88 throws java.lang.IndexOutOfBoundsException
\r
90 this._alcodMapList.add(index, vAlcodMap);
\r
97 * @throws java.lang.IndexOutOfBoundsException
\r
98 * if the index given is outside the bounds of the collection
\r
100 public void addAlcodon(
\r
101 final jalview.schemabinding.version2.Alcodon vAlcodon)
\r
102 throws java.lang.IndexOutOfBoundsException
\r
104 this._alcodonList.addElement(vAlcodon);
\r
112 * @throws java.lang.IndexOutOfBoundsException
\r
113 * if the index given is outside the bounds of the collection
\r
115 public void addAlcodon(final int index,
\r
116 final jalview.schemabinding.version2.Alcodon vAlcodon)
\r
117 throws java.lang.IndexOutOfBoundsException
\r
119 this._alcodonList.add(index, vAlcodon);
\r
123 * Method enumerateAlcodMap.
\r
125 * @return an Enumeration over all jalview.schemabinding.version2.AlcodMap
\r
128 public java.util.Enumeration enumerateAlcodMap()
\r
130 return this._alcodMapList.elements();
\r
134 * Method enumerateAlcodon.
\r
136 * @return an Enumeration over all jalview.schemabinding.version2.Alcodon
\r
139 public java.util.Enumeration enumerateAlcodon()
\r
141 return this._alcodonList.elements();
\r
145 * Method getAlcodMap.
\r
148 * @throws java.lang.IndexOutOfBoundsException
\r
149 * if the index given is outside the bounds of the collection
\r
150 * @return the value of the jalview.schemabinding.version2.AlcodMap at the
\r
153 public jalview.schemabinding.version2.AlcodMap getAlcodMap(final int index)
\r
154 throws java.lang.IndexOutOfBoundsException
\r
156 // check bounds for index
\r
157 if (index < 0 || index >= this._alcodMapList.size())
\r
159 throw new IndexOutOfBoundsException("getAlcodMap: Index value '"
\r
160 + index + "' not in range [0.."
\r
161 + (this._alcodMapList.size() - 1) + "]");
\r
164 return (jalview.schemabinding.version2.AlcodMap) _alcodMapList
\r
169 * Method getAlcodMap.Returns the contents of the collection in an Array.
\r
171 * Note: Just in case the collection contents are changing in another thread,
\r
172 * we pass a 0-length Array of the correct type into the API call. This way we
\r
173 * <i>know</i> that the Array returned is of exactly the correct length.
\r
175 * @return this collection as an Array
\r
177 public jalview.schemabinding.version2.AlcodMap[] getAlcodMap()
\r
179 jalview.schemabinding.version2.AlcodMap[] array = new jalview.schemabinding.version2.AlcodMap[0];
\r
180 return (jalview.schemabinding.version2.AlcodMap[]) this._alcodMapList
\r
185 * Method getAlcodMapCount.
\r
187 * @return the size of this collection
\r
189 public int getAlcodMapCount()
\r
191 return this._alcodMapList.size();
\r
195 * Method getAlcodon.
\r
198 * @throws java.lang.IndexOutOfBoundsException
\r
199 * if the index given is outside the bounds of the collection
\r
200 * @return the value of the jalview.schemabinding.version2.Alcodon at the
\r
203 public jalview.schemabinding.version2.Alcodon getAlcodon(final int index)
\r
204 throws java.lang.IndexOutOfBoundsException
\r
206 // check bounds for index
\r
207 if (index < 0 || index >= this._alcodonList.size())
\r
209 throw new IndexOutOfBoundsException("getAlcodon: Index value '"
\r
210 + index + "' not in range [0.."
\r
211 + (this._alcodonList.size() - 1) + "]");
\r
214 return (jalview.schemabinding.version2.Alcodon) _alcodonList.get(index);
\r
218 * Method getAlcodon.Returns the contents of the collection in an Array.
\r
220 * Note: Just in case the collection contents are changing in another thread,
\r
221 * we pass a 0-length Array of the correct type into the API call. This way we
\r
222 * <i>know</i> that the Array returned is of exactly the correct length.
\r
224 * @return this collection as an Array
\r
226 public jalview.schemabinding.version2.Alcodon[] getAlcodon()
\r
228 jalview.schemabinding.version2.Alcodon[] array = new jalview.schemabinding.version2.Alcodon[0];
\r
229 return (jalview.schemabinding.version2.Alcodon[]) this._alcodonList
\r
234 * Method getAlcodonCount.
\r
236 * @return the size of this collection
\r
238 public int getAlcodonCount()
\r
240 return this._alcodonList.size();
\r
246 * @return true if this object is valid according to the schema
\r
248 public boolean isValid()
\r
253 } catch (org.exolab.castor.xml.ValidationException vex)
\r
264 * @throws org.exolab.castor.xml.MarshalException
\r
265 * if object is null or if any SAXException is thrown during
\r
267 * @throws org.exolab.castor.xml.ValidationException
\r
268 * if this object is an invalid instance according to the schema
\r
270 public void marshal(final java.io.Writer out)
\r
271 throws org.exolab.castor.xml.MarshalException,
\r
272 org.exolab.castor.xml.ValidationException
\r
274 Marshaller.marshal(this, out);
\r
281 * @throws java.io.IOException
\r
282 * if an IOException occurs during marshaling
\r
283 * @throws org.exolab.castor.xml.ValidationException
\r
284 * if this object is an invalid instance according to the schema
\r
285 * @throws org.exolab.castor.xml.MarshalException
\r
286 * if object is null or if any SAXException is thrown during
\r
289 public void marshal(final org.xml.sax.ContentHandler handler)
\r
290 throws java.io.IOException,
\r
291 org.exolab.castor.xml.MarshalException,
\r
292 org.exolab.castor.xml.ValidationException
\r
294 Marshaller.marshal(this, handler);
\r
298 * Method removeAlcodMap.
\r
301 * @return true if the object was removed from the collection.
\r
303 public boolean removeAlcodMap(
\r
304 final jalview.schemabinding.version2.AlcodMap vAlcodMap)
\r
306 boolean removed = _alcodMapList.remove(vAlcodMap);
\r
311 * Method removeAlcodMapAt.
\r
314 * @return the element removed from the collection
\r
316 public jalview.schemabinding.version2.AlcodMap removeAlcodMapAt(
\r
319 java.lang.Object obj = this._alcodMapList.remove(index);
\r
320 return (jalview.schemabinding.version2.AlcodMap) obj;
\r
324 * Method removeAlcodon.
\r
327 * @return true if the object was removed from the collection.
\r
329 public boolean removeAlcodon(
\r
330 final jalview.schemabinding.version2.Alcodon vAlcodon)
\r
332 boolean removed = _alcodonList.remove(vAlcodon);
\r
337 * Method removeAlcodonAt.
\r
340 * @return the element removed from the collection
\r
342 public jalview.schemabinding.version2.Alcodon removeAlcodonAt(
\r
345 java.lang.Object obj = this._alcodonList.remove(index);
\r
346 return (jalview.schemabinding.version2.Alcodon) obj;
\r
351 public void removeAllAlcodMap()
\r
353 this._alcodMapList.clear();
\r
358 public void removeAllAlcodon()
\r
360 this._alcodonList.clear();
\r
368 * @throws java.lang.IndexOutOfBoundsException
\r
369 * if the index given is outside the bounds of the collection
\r
371 public void setAlcodMap(final int index,
\r
372 final jalview.schemabinding.version2.AlcodMap vAlcodMap)
\r
373 throws java.lang.IndexOutOfBoundsException
\r
375 // check bounds for index
\r
376 if (index < 0 || index >= this._alcodMapList.size())
\r
378 throw new IndexOutOfBoundsException("setAlcodMap: Index value '"
\r
379 + index + "' not in range [0.."
\r
380 + (this._alcodMapList.size() - 1) + "]");
\r
383 this._alcodMapList.set(index, vAlcodMap);
\r
389 * @param vAlcodMapArray
\r
391 public void setAlcodMap(
\r
392 final jalview.schemabinding.version2.AlcodMap[] vAlcodMapArray)
\r
395 _alcodMapList.clear();
\r
397 for (int i = 0; i < vAlcodMapArray.length; i++)
\r
399 this._alcodMapList.add(vAlcodMapArray[i]);
\r
408 * @throws java.lang.IndexOutOfBoundsException
\r
409 * if the index given is outside the bounds of the collection
\r
411 public void setAlcodon(final int index,
\r
412 final jalview.schemabinding.version2.Alcodon vAlcodon)
\r
413 throws java.lang.IndexOutOfBoundsException
\r
415 // check bounds for index
\r
416 if (index < 0 || index >= this._alcodonList.size())
\r
418 throw new IndexOutOfBoundsException("setAlcodon: Index value '"
\r
419 + index + "' not in range [0.."
\r
420 + (this._alcodonList.size() - 1) + "]");
\r
423 this._alcodonList.set(index, vAlcodon);
\r
429 * @param vAlcodonArray
\r
431 public void setAlcodon(
\r
432 final jalview.schemabinding.version2.Alcodon[] vAlcodonArray)
\r
435 _alcodonList.clear();
\r
437 for (int i = 0; i < vAlcodonArray.length; i++)
\r
439 this._alcodonList.add(vAlcodonArray[i]);
\r
444 * Method unmarshal.
\r
447 * @throws org.exolab.castor.xml.MarshalException
\r
448 * if object is null or if any SAXException is thrown during
\r
450 * @throws org.exolab.castor.xml.ValidationException
\r
451 * if this object is an invalid instance according to the schema
\r
452 * @return the unmarshaled jalview.schemabinding.version2.AlcodonFrame
\r
454 public static jalview.schemabinding.version2.AlcodonFrame unmarshal(
\r
455 final java.io.Reader reader)
\r
456 throws org.exolab.castor.xml.MarshalException,
\r
457 org.exolab.castor.xml.ValidationException
\r
459 return (jalview.schemabinding.version2.AlcodonFrame) Unmarshaller
\r
460 .unmarshal(jalview.schemabinding.version2.AlcodonFrame.class,
\r
467 * @throws org.exolab.castor.xml.ValidationException
\r
468 * if this object is an invalid instance according to the schema
\r
470 public void validate() throws org.exolab.castor.xml.ValidationException
\r
472 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
473 validator.validate(this);
\r