1 /*******************************************************************************
2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 *******************************************************************************/
19 * This class was automatically generated with
20 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
25 package jalview.binding;
27 //---------------------------------/
28 //- Imported classes and packages -/
29 //---------------------------------/
31 import org.exolab.castor.xml.Marshaller;
32 import org.exolab.castor.xml.Unmarshaller;
37 * @version $Revision$ $Date$
39 public class SequenceSet implements java.io.Serializable {
42 //--------------------------/
43 //- Class/Member Variables -/
44 //--------------------------/
49 private java.lang.String _gapChar;
54 private boolean _aligned;
57 * keeps track of state for field: _aligned
59 private boolean _has_aligned;
62 * Field _sequenceList.
64 private java.util.Vector _sequenceList;
67 * Field _annotationList.
69 private java.util.Vector _annotationList;
76 public SequenceSet() {
78 this._sequenceList = new java.util.Vector();
79 this._annotationList = new java.util.Vector();
91 * @throws java.lang.IndexOutOfBoundsException if the index
92 * given is outside the bounds of the collection
94 public void addAnnotation(
95 final jalview.binding.Annotation vAnnotation)
96 throws java.lang.IndexOutOfBoundsException {
97 this._annotationList.addElement(vAnnotation);
105 * @throws java.lang.IndexOutOfBoundsException if the index
106 * given is outside the bounds of the collection
108 public void addAnnotation(
110 final jalview.binding.Annotation vAnnotation)
111 throws java.lang.IndexOutOfBoundsException {
112 this._annotationList.add(index, vAnnotation);
119 * @throws java.lang.IndexOutOfBoundsException if the index
120 * given is outside the bounds of the collection
122 public void addSequence(
123 final jalview.binding.Sequence vSequence)
124 throws java.lang.IndexOutOfBoundsException {
125 this._sequenceList.addElement(vSequence);
133 * @throws java.lang.IndexOutOfBoundsException if the index
134 * given is outside the bounds of the collection
136 public void addSequence(
138 final jalview.binding.Sequence vSequence)
139 throws java.lang.IndexOutOfBoundsException {
140 this._sequenceList.add(index, vSequence);
145 public void deleteAligned(
147 this._has_aligned= false;
151 * Method enumerateAnnotation.
153 * @return an Enumeration over all jalview.binding.Annotation
156 public java.util.Enumeration enumerateAnnotation(
158 return this._annotationList.elements();
162 * Method enumerateSequence.
164 * @return an Enumeration over all jalview.binding.Sequence
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 if the index
187 * given is outside the bounds of the collection
188 * @return the value of the jalview.binding.Annotation at the
191 public jalview.binding.Annotation getAnnotation(
193 throws java.lang.IndexOutOfBoundsException {
194 // check bounds for index
195 if (index < 0 || index >= this._annotationList.size()) {
196 throw new IndexOutOfBoundsException("getAnnotation: Index value '" + index + "' not in range [0.." + (this._annotationList.size() - 1) + "]");
199 return (jalview.binding.Annotation) _annotationList.get(index);
203 * Method getAnnotation.Returns the contents of the collection
204 * in an Array. <p>Note: Just in case the collection contents
205 * are changing in another thread, we pass a 0-length Array of
206 * the correct type into the API call. This way we <i>know</i>
207 * that the Array returned is of exactly the correct length.
209 * @return this collection as an Array
211 public jalview.binding.Annotation[] getAnnotation(
213 jalview.binding.Annotation[] array = new jalview.binding.Annotation[0];
214 return (jalview.binding.Annotation[]) this._annotationList.toArray(array);
218 * Method getAnnotationCount.
220 * @return the size of this collection
222 public int getAnnotationCount(
224 return this._annotationList.size();
228 * Returns the value of field 'gapChar'.
230 * @return the value of field 'GapChar'.
232 public java.lang.String getGapChar(
234 return this._gapChar;
238 * Method getSequence.
241 * @throws java.lang.IndexOutOfBoundsException if the index
242 * given is outside the bounds of the collection
243 * @return the value of the jalview.binding.Sequence at the
246 public jalview.binding.Sequence getSequence(
248 throws java.lang.IndexOutOfBoundsException {
249 // check bounds for index
250 if (index < 0 || index >= this._sequenceList.size()) {
251 throw new IndexOutOfBoundsException("getSequence: Index value '" + index + "' not in range [0.." + (this._sequenceList.size() - 1) + "]");
254 return (jalview.binding.Sequence) _sequenceList.get(index);
258 * Method getSequence.Returns the contents of the collection in
259 * an Array. <p>Note: Just in case the collection contents
260 * are changing in another thread, we pass a 0-length Array of
261 * the correct type into the API call. This way we <i>know</i>
262 * that the Array returned is of exactly the correct length.
264 * @return this collection as an Array
266 public jalview.binding.Sequence[] getSequence(
268 jalview.binding.Sequence[] array = new jalview.binding.Sequence[0];
269 return (jalview.binding.Sequence[]) this._sequenceList.toArray(array);
273 * Method getSequenceCount.
275 * @return the size of this collection
277 public int getSequenceCount(
279 return this._sequenceList.size();
285 * @return true if at least one Aligned has been added
287 public boolean hasAligned(
289 return this._has_aligned;
293 * Returns the value of field 'aligned'.
295 * @return the value of field 'Aligned'.
297 public boolean isAligned(
299 return this._aligned;
305 * @return true if this object is valid according to the schema
307 public boolean isValid(
311 } catch (org.exolab.castor.xml.ValidationException vex) {
321 * @throws org.exolab.castor.xml.MarshalException if object is
322 * null or if any SAXException is thrown during marshaling
323 * @throws org.exolab.castor.xml.ValidationException if this
324 * object is an invalid instance according to the schema
327 final java.io.Writer out)
328 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
329 Marshaller.marshal(this, out);
336 * @throws java.io.IOException if an IOException occurs during
338 * @throws org.exolab.castor.xml.ValidationException if this
339 * object is an invalid instance according to the schema
340 * @throws org.exolab.castor.xml.MarshalException if object is
341 * null or if any SAXException is thrown during marshaling
344 final org.xml.sax.ContentHandler handler)
345 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
346 Marshaller.marshal(this, handler);
351 public void removeAllAnnotation(
353 this._annotationList.clear();
358 public void removeAllSequence(
360 this._sequenceList.clear();
364 * Method removeAnnotation.
367 * @return true if the object was removed from the collection.
369 public boolean removeAnnotation(
370 final jalview.binding.Annotation vAnnotation) {
371 boolean removed = _annotationList.remove(vAnnotation);
376 * Method removeAnnotationAt.
379 * @return the element removed from the collection
381 public jalview.binding.Annotation removeAnnotationAt(
383 java.lang.Object obj = this._annotationList.remove(index);
384 return (jalview.binding.Annotation) obj;
388 * Method removeSequence.
391 * @return true if the object was removed from the collection.
393 public boolean removeSequence(
394 final jalview.binding.Sequence vSequence) {
395 boolean removed = _sequenceList.remove(vSequence);
400 * Method removeSequenceAt.
403 * @return the element removed from the collection
405 public jalview.binding.Sequence removeSequenceAt(
407 java.lang.Object obj = this._sequenceList.remove(index);
408 return (jalview.binding.Sequence) obj;
412 * Sets the value of field 'aligned'.
414 * @param aligned the value of field 'aligned'.
416 public void setAligned(
417 final boolean aligned) {
418 this._aligned = aligned;
419 this._has_aligned = true;
427 * @throws java.lang.IndexOutOfBoundsException if the index
428 * given is outside the bounds of the collection
430 public void setAnnotation(
432 final jalview.binding.Annotation vAnnotation)
433 throws java.lang.IndexOutOfBoundsException {
434 // check bounds for index
435 if (index < 0 || index >= this._annotationList.size()) {
436 throw new IndexOutOfBoundsException("setAnnotation: Index value '" + index + "' not in range [0.." + (this._annotationList.size() - 1) + "]");
439 this._annotationList.set(index, vAnnotation);
445 * @param vAnnotationArray
447 public void setAnnotation(
448 final jalview.binding.Annotation[] vAnnotationArray) {
450 _annotationList.clear();
452 for (int i = 0; i < vAnnotationArray.length; i++) {
453 this._annotationList.add(vAnnotationArray[i]);
458 * Sets the value of field 'gapChar'.
460 * @param gapChar the value of field 'gapChar'.
462 public void setGapChar(
463 final java.lang.String gapChar) {
464 this._gapChar = gapChar;
472 * @throws java.lang.IndexOutOfBoundsException if the index
473 * given is outside the bounds of the collection
475 public void setSequence(
477 final jalview.binding.Sequence vSequence)
478 throws java.lang.IndexOutOfBoundsException {
479 // check bounds for index
480 if (index < 0 || index >= this._sequenceList.size()) {
481 throw new IndexOutOfBoundsException("setSequence: Index value '" + index + "' not in range [0.." + (this._sequenceList.size() - 1) + "]");
484 this._sequenceList.set(index, vSequence);
490 * @param vSequenceArray
492 public void setSequence(
493 final jalview.binding.Sequence[] vSequenceArray) {
495 _sequenceList.clear();
497 for (int i = 0; i < vSequenceArray.length; i++) {
498 this._sequenceList.add(vSequenceArray[i]);
506 * @throws org.exolab.castor.xml.MarshalException if object is
507 * null or if any SAXException is thrown during marshaling
508 * @throws org.exolab.castor.xml.ValidationException if this
509 * object is an invalid instance according to the schema
510 * @return the unmarshaled jalview.binding.SequenceSet
512 public static jalview.binding.SequenceSet unmarshal(
513 final java.io.Reader reader)
514 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
515 return (jalview.binding.SequenceSet) Unmarshaller.unmarshal(jalview.binding.SequenceSet.class, reader);
521 * @throws org.exolab.castor.xml.ValidationException if this
522 * object is an invalid instance according to the schema
524 public void validate(
526 throws org.exolab.castor.xml.ValidationException {
527 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
528 validator.validate(this);