2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.binding;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
31 * @version $Revision$ $Date$
33 public class JSeq implements java.io.Serializable {
36 //--------------------------/
37 //- Class/Member Variables -/
38 //--------------------------/
46 * keeps track of state for field: _colour
48 private boolean _has_colour;
56 * keeps track of state for field: _start
58 private boolean _has_start;
66 * keeps track of state for field: _end
68 private boolean _has_end;
76 * keeps track of state for field: _id
78 private boolean _has_id;
81 * Field _featuresList.
83 private java.util.Vector _featuresList;
88 private java.util.Vector _pdbidsList;
97 this._featuresList = new java.util.Vector();
98 this._pdbidsList = new java.util.Vector();
110 * @throws java.lang.IndexOutOfBoundsException if the index
111 * given is outside the bounds of the collection
113 public void addFeatures(
114 final jalview.binding.Features vFeatures)
115 throws java.lang.IndexOutOfBoundsException {
116 this._featuresList.addElement(vFeatures);
124 * @throws java.lang.IndexOutOfBoundsException if the index
125 * given is outside the bounds of the collection
127 public void addFeatures(
129 final jalview.binding.Features vFeatures)
130 throws java.lang.IndexOutOfBoundsException {
131 this._featuresList.add(index, vFeatures);
138 * @throws java.lang.IndexOutOfBoundsException if the index
139 * given is outside the bounds of the collection
141 public void addPdbids(
142 final jalview.binding.Pdbids vPdbids)
143 throws java.lang.IndexOutOfBoundsException {
144 this._pdbidsList.addElement(vPdbids);
152 * @throws java.lang.IndexOutOfBoundsException if the index
153 * given is outside the bounds of the collection
155 public void addPdbids(
157 final jalview.binding.Pdbids vPdbids)
158 throws java.lang.IndexOutOfBoundsException {
159 this._pdbidsList.add(index, vPdbids);
164 public void deleteColour(
166 this._has_colour= false;
171 public void deleteEnd(
173 this._has_end= false;
178 public void deleteId(
185 public void deleteStart(
187 this._has_start= false;
191 * Method enumerateFeatures.
193 * @return an Enumeration over all jalview.binding.Features
196 public java.util.Enumeration enumerateFeatures(
198 return this._featuresList.elements();
202 * Method enumeratePdbids.
204 * @return an Enumeration over all jalview.binding.Pdbids
207 public java.util.Enumeration enumeratePdbids(
209 return this._pdbidsList.elements();
213 * Returns the value of field 'colour'.
215 * @return the value of field 'Colour'.
217 public int getColour(
223 * Returns the value of field 'end'.
225 * @return the value of field 'End'.
233 * Method getFeatures.
236 * @throws java.lang.IndexOutOfBoundsException if the index
237 * given is outside the bounds of the collection
238 * @return the value of the jalview.binding.Features at the
241 public jalview.binding.Features getFeatures(
243 throws java.lang.IndexOutOfBoundsException {
244 // check bounds for index
245 if (index < 0 || index >= this._featuresList.size()) {
246 throw new IndexOutOfBoundsException("getFeatures: Index value '" + index + "' not in range [0.." + (this._featuresList.size() - 1) + "]");
249 return (jalview.binding.Features) _featuresList.get(index);
253 * Method getFeatures.Returns the contents of the collection in
254 * an Array. <p>Note: Just in case the collection contents
255 * are changing in another thread, we pass a 0-length Array of
256 * the correct type into the API call. This way we <i>know</i>
257 * that the Array returned is of exactly the correct length.
259 * @return this collection as an Array
261 public jalview.binding.Features[] getFeatures(
263 jalview.binding.Features[] array = new jalview.binding.Features[0];
264 return (jalview.binding.Features[]) this._featuresList.toArray(array);
268 * Method getFeaturesCount.
270 * @return the size of this collection
272 public int getFeaturesCount(
274 return this._featuresList.size();
278 * Returns the value of field 'id'.
280 * @return the value of field 'Id'.
291 * @throws java.lang.IndexOutOfBoundsException if the index
292 * given is outside the bounds of the collection
293 * @return the value of the jalview.binding.Pdbids at the given
296 public jalview.binding.Pdbids getPdbids(
298 throws java.lang.IndexOutOfBoundsException {
299 // check bounds for index
300 if (index < 0 || index >= this._pdbidsList.size()) {
301 throw new IndexOutOfBoundsException("getPdbids: Index value '" + index + "' not in range [0.." + (this._pdbidsList.size() - 1) + "]");
304 return (jalview.binding.Pdbids) _pdbidsList.get(index);
308 * Method getPdbids.Returns the contents of the collection in
309 * an Array. <p>Note: Just in case the collection contents
310 * are changing in another thread, we pass a 0-length Array of
311 * the correct type into the API call. This way we <i>know</i>
312 * that the Array returned is of exactly the correct length.
314 * @return this collection as an Array
316 public jalview.binding.Pdbids[] getPdbids(
318 jalview.binding.Pdbids[] array = new jalview.binding.Pdbids[0];
319 return (jalview.binding.Pdbids[]) this._pdbidsList.toArray(array);
323 * Method getPdbidsCount.
325 * @return the size of this collection
327 public int getPdbidsCount(
329 return this._pdbidsList.size();
333 * Returns the value of field 'start'.
335 * @return the value of field 'Start'.
345 * @return true if at least one Colour has been added
347 public boolean hasColour(
349 return this._has_colour;
355 * @return true if at least one End has been added
357 public boolean hasEnd(
359 return this._has_end;
365 * @return true if at least one Id has been added
367 public boolean hasId(
375 * @return true if at least one Start has been added
377 public boolean hasStart(
379 return this._has_start;
385 * @return true if this object is valid according to the schema
387 public boolean isValid(
391 } catch (org.exolab.castor.xml.ValidationException vex) {
401 * @throws org.exolab.castor.xml.MarshalException if object is
402 * null or if any SAXException is thrown during marshaling
403 * @throws org.exolab.castor.xml.ValidationException if this
404 * object is an invalid instance according to the schema
407 final java.io.Writer out)
408 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
409 Marshaller.marshal(this, out);
416 * @throws java.io.IOException if an IOException occurs during
418 * @throws org.exolab.castor.xml.ValidationException if this
419 * object is an invalid instance according to the schema
420 * @throws org.exolab.castor.xml.MarshalException if object is
421 * null or if any SAXException is thrown during marshaling
424 final org.xml.sax.ContentHandler handler)
425 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
426 Marshaller.marshal(this, handler);
431 public void removeAllFeatures(
433 this._featuresList.clear();
438 public void removeAllPdbids(
440 this._pdbidsList.clear();
444 * Method removeFeatures.
447 * @return true if the object was removed from the collection.
449 public boolean removeFeatures(
450 final jalview.binding.Features vFeatures) {
451 boolean removed = _featuresList.remove(vFeatures);
456 * Method removeFeaturesAt.
459 * @return the element removed from the collection
461 public jalview.binding.Features removeFeaturesAt(
463 java.lang.Object obj = this._featuresList.remove(index);
464 return (jalview.binding.Features) obj;
468 * Method removePdbids.
471 * @return true if the object was removed from the collection.
473 public boolean removePdbids(
474 final jalview.binding.Pdbids vPdbids) {
475 boolean removed = _pdbidsList.remove(vPdbids);
480 * Method removePdbidsAt.
483 * @return the element removed from the collection
485 public jalview.binding.Pdbids removePdbidsAt(
487 java.lang.Object obj = this._pdbidsList.remove(index);
488 return (jalview.binding.Pdbids) obj;
492 * Sets the value of field 'colour'.
494 * @param colour the value of field 'colour'.
496 public void setColour(
498 this._colour = colour;
499 this._has_colour = true;
503 * Sets the value of field 'end'.
505 * @param end the value of field 'end'.
510 this._has_end = true;
518 * @throws java.lang.IndexOutOfBoundsException if the index
519 * given is outside the bounds of the collection
521 public void setFeatures(
523 final jalview.binding.Features vFeatures)
524 throws java.lang.IndexOutOfBoundsException {
525 // check bounds for index
526 if (index < 0 || index >= this._featuresList.size()) {
527 throw new IndexOutOfBoundsException("setFeatures: Index value '" + index + "' not in range [0.." + (this._featuresList.size() - 1) + "]");
530 this._featuresList.set(index, vFeatures);
536 * @param vFeaturesArray
538 public void setFeatures(
539 final jalview.binding.Features[] vFeaturesArray) {
541 _featuresList.clear();
543 for (int i = 0; i < vFeaturesArray.length; i++) {
544 this._featuresList.add(vFeaturesArray[i]);
549 * Sets the value of field 'id'.
551 * @param id the value of field 'id'.
564 * @throws java.lang.IndexOutOfBoundsException if the index
565 * given is outside the bounds of the collection
567 public void setPdbids(
569 final jalview.binding.Pdbids vPdbids)
570 throws java.lang.IndexOutOfBoundsException {
571 // check bounds for index
572 if (index < 0 || index >= this._pdbidsList.size()) {
573 throw new IndexOutOfBoundsException("setPdbids: Index value '" + index + "' not in range [0.." + (this._pdbidsList.size() - 1) + "]");
576 this._pdbidsList.set(index, vPdbids);
582 * @param vPdbidsArray
584 public void setPdbids(
585 final jalview.binding.Pdbids[] vPdbidsArray) {
589 for (int i = 0; i < vPdbidsArray.length; i++) {
590 this._pdbidsList.add(vPdbidsArray[i]);
595 * Sets the value of field 'start'.
597 * @param start the value of field 'start'.
599 public void setStart(
602 this._has_start = true;
609 * @throws org.exolab.castor.xml.MarshalException if object is
610 * null or if any SAXException is thrown during marshaling
611 * @throws org.exolab.castor.xml.ValidationException if this
612 * object is an invalid instance according to the schema
613 * @return the unmarshaled jalview.binding.JSeq
615 public static jalview.binding.JSeq unmarshal(
616 final java.io.Reader reader)
617 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
618 return (jalview.binding.JSeq) Unmarshaller.unmarshal(jalview.binding.JSeq.class, reader);
624 * @throws org.exolab.castor.xml.ValidationException if this
625 * object is an invalid instance according to the schema
627 public void validate(
629 throws org.exolab.castor.xml.ValidationException {
630 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
631 validator.validate(this);