1 /*******************************************************************************
2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $(date) 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.
20 *******************************************************************************/
22 * This class was automatically generated with
23 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
28 package jalview.binding;
30 //---------------------------------/
31 //- Imported classes and packages -/
32 //---------------------------------/
34 import org.exolab.castor.xml.Marshaller;
35 import org.exolab.castor.xml.Unmarshaller;
40 * @version $Revision$ $Date$
42 public class SequenceSet implements java.io.Serializable
45 // --------------------------/
46 // - Class/Member Variables -/
47 // --------------------------/
52 private java.lang.String _gapChar;
57 private boolean _aligned;
60 * keeps track of state for field: _aligned
62 private boolean _has_aligned;
65 * Field _sequenceList.
67 private java.util.Vector _sequenceList;
70 * Field _annotationList.
72 private java.util.Vector _annotationList;
81 this._sequenceList = new java.util.Vector();
82 this._annotationList = new java.util.Vector();
93 * @throws java.lang.IndexOutOfBoundsException
94 * if the index given is outside the bounds of the collection
96 public void addAnnotation(final jalview.binding.Annotation vAnnotation)
97 throws java.lang.IndexOutOfBoundsException
99 this._annotationList.addElement(vAnnotation);
107 * @throws java.lang.IndexOutOfBoundsException
108 * if the index given is outside the bounds of the collection
110 public void addAnnotation(final int index,
111 final jalview.binding.Annotation vAnnotation)
112 throws java.lang.IndexOutOfBoundsException
114 this._annotationList.add(index, vAnnotation);
121 * @throws java.lang.IndexOutOfBoundsException
122 * if the index given is outside the bounds of the collection
124 public void addSequence(final jalview.binding.Sequence vSequence)
125 throws java.lang.IndexOutOfBoundsException
127 this._sequenceList.addElement(vSequence);
135 * @throws java.lang.IndexOutOfBoundsException
136 * if the index given is outside the bounds of the collection
138 public void addSequence(final int index,
139 final jalview.binding.Sequence vSequence)
140 throws java.lang.IndexOutOfBoundsException
142 this._sequenceList.add(index, vSequence);
147 public void deleteAligned()
149 this._has_aligned = false;
153 * Method enumerateAnnotation.
155 * @return an Enumeration over all jalview.binding.Annotation elements
157 public java.util.Enumeration enumerateAnnotation()
159 return this._annotationList.elements();
163 * Method enumerateSequence.
165 * @return an Enumeration over all jalview.binding.Sequence elements
167 public java.util.Enumeration enumerateSequence()
169 return this._sequenceList.elements();
173 * Returns the value of field 'aligned'.
175 * @return the value of field 'Aligned'.
177 public boolean getAligned()
179 return this._aligned;
183 * Method getAnnotation.
186 * @throws java.lang.IndexOutOfBoundsException
187 * if the index given is outside the bounds of the collection
188 * @return the value of the jalview.binding.Annotation at the given index
190 public jalview.binding.Annotation getAnnotation(final int index)
191 throws java.lang.IndexOutOfBoundsException
193 // check bounds for index
194 if (index < 0 || index >= this._annotationList.size())
196 throw new IndexOutOfBoundsException(
197 "getAnnotation: Index value '" + index + "' not in range [0.."
198 + (this._annotationList.size() - 1) + "]");
201 return (jalview.binding.Annotation) _annotationList.get(index);
205 * Method getAnnotation.Returns the contents of the collection in an Array.
207 * Note: Just in case the collection contents are changing in another thread,
208 * we pass a 0-length Array of the correct type into the API call. This way we
209 * <i>know</i> that the Array returned is of exactly the correct length.
211 * @return this collection as an Array
213 public jalview.binding.Annotation[] getAnnotation()
215 jalview.binding.Annotation[] array = new jalview.binding.Annotation[0];
216 return (jalview.binding.Annotation[]) this._annotationList
221 * Method getAnnotationCount.
223 * @return the size of this collection
225 public int getAnnotationCount()
227 return this._annotationList.size();
231 * Returns the value of field 'gapChar'.
233 * @return the value of field 'GapChar'.
235 public java.lang.String getGapChar()
237 return this._gapChar;
241 * Method getSequence.
244 * @throws java.lang.IndexOutOfBoundsException
245 * if the index given is outside the bounds of the collection
246 * @return the value of the jalview.binding.Sequence at the given index
248 public jalview.binding.Sequence getSequence(final int index)
249 throws java.lang.IndexOutOfBoundsException
251 // check bounds for index
252 if (index < 0 || index >= this._sequenceList.size())
254 throw new IndexOutOfBoundsException(
255 "getSequence: Index value '" + index + "' not in range [0.."
256 + (this._sequenceList.size() - 1) + "]");
259 return (jalview.binding.Sequence) _sequenceList.get(index);
263 * Method getSequence.Returns the contents of the collection in an Array.
265 * Note: Just in case the collection contents are changing in another thread,
266 * we pass a 0-length Array of the correct type into the API call. This way we
267 * <i>know</i> that the Array returned is of exactly the correct length.
269 * @return this collection as an Array
271 public jalview.binding.Sequence[] getSequence()
273 jalview.binding.Sequence[] array = new jalview.binding.Sequence[0];
274 return (jalview.binding.Sequence[]) this._sequenceList.toArray(array);
278 * Method getSequenceCount.
280 * @return the size of this collection
282 public int getSequenceCount()
284 return this._sequenceList.size();
290 * @return true if at least one Aligned has been added
292 public boolean hasAligned()
294 return this._has_aligned;
298 * Returns the value of field 'aligned'.
300 * @return the value of field 'Aligned'.
302 public boolean isAligned()
304 return this._aligned;
310 * @return true if this object is valid according to the schema
312 public boolean isValid()
317 } catch (org.exolab.castor.xml.ValidationException vex)
328 * @throws org.exolab.castor.xml.MarshalException
329 * if object is null or if any SAXException is thrown during
331 * @throws org.exolab.castor.xml.ValidationException
332 * if this object is an invalid instance according to the schema
334 public void marshal(final java.io.Writer out)
335 throws org.exolab.castor.xml.MarshalException,
336 org.exolab.castor.xml.ValidationException
338 Marshaller.marshal(this, out);
345 * @throws java.io.IOException
346 * if an IOException occurs during marshaling
347 * @throws org.exolab.castor.xml.ValidationException
348 * if this object is an invalid instance according to the schema
349 * @throws org.exolab.castor.xml.MarshalException
350 * if object is null or if any SAXException is thrown during
353 public void marshal(final org.xml.sax.ContentHandler handler)
354 throws java.io.IOException,
355 org.exolab.castor.xml.MarshalException,
356 org.exolab.castor.xml.ValidationException
358 Marshaller.marshal(this, handler);
363 public void removeAllAnnotation()
365 this._annotationList.clear();
370 public void removeAllSequence()
372 this._sequenceList.clear();
376 * Method removeAnnotation.
379 * @return true if the object was removed from the collection.
381 public boolean removeAnnotation(
382 final jalview.binding.Annotation vAnnotation)
384 boolean removed = _annotationList.remove(vAnnotation);
389 * Method removeAnnotationAt.
392 * @return the element removed from the collection
394 public jalview.binding.Annotation removeAnnotationAt(final int index)
396 java.lang.Object obj = this._annotationList.remove(index);
397 return (jalview.binding.Annotation) obj;
401 * Method removeSequence.
404 * @return true if the object was removed from the collection.
406 public boolean removeSequence(final jalview.binding.Sequence vSequence)
408 boolean removed = _sequenceList.remove(vSequence);
413 * Method removeSequenceAt.
416 * @return the element removed from the collection
418 public jalview.binding.Sequence removeSequenceAt(final int index)
420 java.lang.Object obj = this._sequenceList.remove(index);
421 return (jalview.binding.Sequence) obj;
425 * Sets the value of field 'aligned'.
428 * the value of field 'aligned'.
430 public void setAligned(final boolean aligned)
432 this._aligned = aligned;
433 this._has_aligned = true;
441 * @throws java.lang.IndexOutOfBoundsException
442 * if the index given is outside the bounds of the collection
444 public void setAnnotation(final int index,
445 final jalview.binding.Annotation vAnnotation)
446 throws java.lang.IndexOutOfBoundsException
448 // check bounds for index
449 if (index < 0 || index >= this._annotationList.size())
451 throw new IndexOutOfBoundsException(
452 "setAnnotation: Index value '" + index + "' not in range [0.."
453 + (this._annotationList.size() - 1) + "]");
456 this._annotationList.set(index, vAnnotation);
462 * @param vAnnotationArray
464 public void setAnnotation(
465 final jalview.binding.Annotation[] vAnnotationArray)
468 _annotationList.clear();
470 for (int i = 0; i < vAnnotationArray.length; i++)
472 this._annotationList.add(vAnnotationArray[i]);
477 * Sets the value of field 'gapChar'.
480 * the value of field 'gapChar'.
482 public void setGapChar(final java.lang.String gapChar)
484 this._gapChar = gapChar;
492 * @throws java.lang.IndexOutOfBoundsException
493 * if the index given is outside the bounds of the collection
495 public void setSequence(final int index,
496 final jalview.binding.Sequence vSequence)
497 throws java.lang.IndexOutOfBoundsException
499 // check bounds for index
500 if (index < 0 || index >= this._sequenceList.size())
502 throw new IndexOutOfBoundsException(
503 "setSequence: Index value '" + index + "' not in range [0.."
504 + (this._sequenceList.size() - 1) + "]");
507 this._sequenceList.set(index, vSequence);
513 * @param vSequenceArray
515 public void setSequence(final jalview.binding.Sequence[] vSequenceArray)
518 _sequenceList.clear();
520 for (int i = 0; i < vSequenceArray.length; i++)
522 this._sequenceList.add(vSequenceArray[i]);
530 * @throws org.exolab.castor.xml.MarshalException
531 * if object is null or if any SAXException is thrown during
533 * @throws org.exolab.castor.xml.ValidationException
534 * if this object is an invalid instance according to the schema
535 * @return the unmarshaled jalview.binding.SequenceSet
537 public static jalview.binding.SequenceSet unmarshal(
538 final java.io.Reader reader)
539 throws org.exolab.castor.xml.MarshalException,
540 org.exolab.castor.xml.ValidationException
542 return (jalview.binding.SequenceSet) Unmarshaller
543 .unmarshal(jalview.binding.SequenceSet.class, reader);
549 * @throws org.exolab.castor.xml.ValidationException
550 * if this object is an invalid instance according to the schema
552 public void validate() throws org.exolab.castor.xml.ValidationException
554 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
555 validator.validate(this);