2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2)
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();
109 * @throws java.lang.IndexOutOfBoundsException
110 * if the index given is outside the bounds of the collection
112 public void addFeatures(final jalview.binding.Features vFeatures)
113 throws java.lang.IndexOutOfBoundsException
115 this._featuresList.addElement(vFeatures);
123 * @throws java.lang.IndexOutOfBoundsException
124 * if the index given is outside the bounds of the collection
126 public void addFeatures(final int index,
127 final jalview.binding.Features vFeatures)
128 throws java.lang.IndexOutOfBoundsException
130 this._featuresList.add(index, vFeatures);
137 * @throws java.lang.IndexOutOfBoundsException
138 * if the index given is outside the bounds of the collection
140 public void addPdbids(final jalview.binding.Pdbids vPdbids)
141 throws java.lang.IndexOutOfBoundsException
143 this._pdbidsList.addElement(vPdbids);
151 * @throws java.lang.IndexOutOfBoundsException
152 * if the index given is outside the bounds of the collection
154 public void addPdbids(final int index,
155 final jalview.binding.Pdbids vPdbids)
156 throws java.lang.IndexOutOfBoundsException
158 this._pdbidsList.add(index, vPdbids);
163 public void deleteColour()
165 this._has_colour = false;
170 public void deleteEnd()
172 this._has_end = false;
177 public void deleteId()
179 this._has_id = false;
184 public void deleteStart()
186 this._has_start = false;
190 * Method enumerateFeatures.
192 * @return an Enumeration over all jalview.binding.Features elements
194 public java.util.Enumeration enumerateFeatures()
196 return this._featuresList.elements();
200 * Method enumeratePdbids.
202 * @return an Enumeration over all jalview.binding.Pdbids elements
204 public java.util.Enumeration enumeratePdbids()
206 return this._pdbidsList.elements();
210 * Returns the value of field 'colour'.
212 * @return the value of field 'Colour'.
214 public int getColour()
220 * Returns the value of field 'end'.
222 * @return the value of field 'End'.
230 * Method getFeatures.
233 * @throws java.lang.IndexOutOfBoundsException
234 * if the index given is outside the bounds of the collection
235 * @return the value of the jalview.binding.Features at the given index
237 public jalview.binding.Features getFeatures(final int index)
238 throws java.lang.IndexOutOfBoundsException
240 // check bounds for index
241 if (index < 0 || index >= this._featuresList.size())
243 throw new IndexOutOfBoundsException("getFeatures: Index value '"
244 + index + "' not in range [0.."
245 + (this._featuresList.size() - 1) + "]");
248 return (jalview.binding.Features) _featuresList.get(index);
252 * Method getFeatures.Returns the contents of the collection in an Array.
254 * Note: Just in case the collection contents are changing in another thread,
255 * we pass a 0-length Array of the correct type into the API call. This way we
256 * <i>know</i> that the Array returned is of exactly the correct length.
258 * @return this collection as an Array
260 public jalview.binding.Features[] getFeatures()
262 jalview.binding.Features[] array = new jalview.binding.Features[0];
263 return (jalview.binding.Features[]) this._featuresList.toArray(array);
267 * Method getFeaturesCount.
269 * @return the size of this collection
271 public int getFeaturesCount()
273 return this._featuresList.size();
277 * Returns the value of field 'id'.
279 * @return the value of field 'Id'.
290 * @throws java.lang.IndexOutOfBoundsException
291 * if the index given is outside the bounds of the collection
292 * @return the value of the jalview.binding.Pdbids at the given index
294 public jalview.binding.Pdbids getPdbids(final int index)
295 throws java.lang.IndexOutOfBoundsException
297 // check bounds for index
298 if (index < 0 || index >= this._pdbidsList.size())
300 throw new IndexOutOfBoundsException("getPdbids: Index value '"
301 + index + "' not in range [0.."
302 + (this._pdbidsList.size() - 1) + "]");
305 return (jalview.binding.Pdbids) _pdbidsList.get(index);
309 * Method getPdbids.Returns the contents of the collection in an Array.
311 * Note: Just in case the collection contents are changing in another thread,
312 * we pass a 0-length Array of the correct type into the API call. This way we
313 * <i>know</i> that the Array returned is of exactly the correct length.
315 * @return this collection as an Array
317 public jalview.binding.Pdbids[] getPdbids()
319 jalview.binding.Pdbids[] array = new jalview.binding.Pdbids[0];
320 return (jalview.binding.Pdbids[]) this._pdbidsList.toArray(array);
324 * Method getPdbidsCount.
326 * @return the size of this collection
328 public int getPdbidsCount()
330 return this._pdbidsList.size();
334 * Returns the value of field 'start'.
336 * @return the value of field 'Start'.
338 public int getStart()
346 * @return true if at least one Colour has been added
348 public boolean hasColour()
350 return this._has_colour;
356 * @return true if at least one End has been added
358 public boolean hasEnd()
360 return this._has_end;
366 * @return true if at least one Id has been added
368 public boolean hasId()
376 * @return true if at least one Start has been added
378 public boolean hasStart()
380 return this._has_start;
386 * @return true if this object is valid according to the schema
388 public boolean isValid()
393 } catch (org.exolab.castor.xml.ValidationException vex)
404 * @throws org.exolab.castor.xml.MarshalException
405 * if object is null or if any SAXException is thrown during
407 * @throws org.exolab.castor.xml.ValidationException
408 * if this object is an invalid instance according to the
411 public void marshal(final java.io.Writer out)
412 throws org.exolab.castor.xml.MarshalException,
413 org.exolab.castor.xml.ValidationException
415 Marshaller.marshal(this, out);
422 * @throws java.io.IOException
423 * if an IOException occurs during marshaling
424 * @throws org.exolab.castor.xml.ValidationException
425 * if this object is an invalid instance according to the
427 * @throws org.exolab.castor.xml.MarshalException
428 * if object is null or if any SAXException is thrown during
431 public void marshal(final org.xml.sax.ContentHandler handler)
432 throws java.io.IOException,
433 org.exolab.castor.xml.MarshalException,
434 org.exolab.castor.xml.ValidationException
436 Marshaller.marshal(this, handler);
441 public void removeAllFeatures()
443 this._featuresList.clear();
448 public void removeAllPdbids()
450 this._pdbidsList.clear();
454 * Method removeFeatures.
457 * @return true if the object was removed from the collection.
459 public boolean removeFeatures(final jalview.binding.Features vFeatures)
461 boolean removed = _featuresList.remove(vFeatures);
466 * Method removeFeaturesAt.
469 * @return the element removed from the collection
471 public jalview.binding.Features removeFeaturesAt(final int index)
473 java.lang.Object obj = this._featuresList.remove(index);
474 return (jalview.binding.Features) obj;
478 * Method removePdbids.
481 * @return true if the object was removed from the collection.
483 public boolean removePdbids(final jalview.binding.Pdbids vPdbids)
485 boolean removed = _pdbidsList.remove(vPdbids);
490 * Method removePdbidsAt.
493 * @return the element removed from the collection
495 public jalview.binding.Pdbids removePdbidsAt(final int index)
497 java.lang.Object obj = this._pdbidsList.remove(index);
498 return (jalview.binding.Pdbids) obj;
502 * Sets the value of field 'colour'.
505 * the value of field 'colour'.
507 public void setColour(final int colour)
509 this._colour = colour;
510 this._has_colour = true;
514 * Sets the value of field 'end'.
517 * the value of field 'end'.
519 public void setEnd(final int end)
522 this._has_end = true;
530 * @throws java.lang.IndexOutOfBoundsException
531 * if the index given is outside the bounds of the collection
533 public void setFeatures(final int index,
534 final jalview.binding.Features vFeatures)
535 throws java.lang.IndexOutOfBoundsException
537 // check bounds for index
538 if (index < 0 || index >= this._featuresList.size())
540 throw new IndexOutOfBoundsException("setFeatures: Index value '"
541 + index + "' not in range [0.."
542 + (this._featuresList.size() - 1) + "]");
545 this._featuresList.set(index, vFeatures);
551 * @param vFeaturesArray
553 public void setFeatures(final jalview.binding.Features[] vFeaturesArray)
556 _featuresList.clear();
558 for (int i = 0; i < vFeaturesArray.length; i++)
560 this._featuresList.add(vFeaturesArray[i]);
565 * Sets the value of field 'id'.
568 * the value of field 'id'.
570 public void setId(final int id)
581 * @throws java.lang.IndexOutOfBoundsException
582 * if the index given is outside the bounds of the collection
584 public void setPdbids(final int index,
585 final jalview.binding.Pdbids vPdbids)
586 throws java.lang.IndexOutOfBoundsException
588 // check bounds for index
589 if (index < 0 || index >= this._pdbidsList.size())
591 throw new IndexOutOfBoundsException("setPdbids: Index value '"
592 + index + "' not in range [0.."
593 + (this._pdbidsList.size() - 1) + "]");
596 this._pdbidsList.set(index, vPdbids);
602 * @param vPdbidsArray
604 public void setPdbids(final jalview.binding.Pdbids[] vPdbidsArray)
609 for (int i = 0; i < vPdbidsArray.length; i++)
611 this._pdbidsList.add(vPdbidsArray[i]);
616 * Sets the value of field 'start'.
619 * the value of field 'start'.
621 public void setStart(final int start)
624 this._has_start = true;
631 * @throws org.exolab.castor.xml.MarshalException
632 * if object is null or if any SAXException is thrown during
634 * @throws org.exolab.castor.xml.ValidationException
635 * if this object is an invalid instance according to the
637 * @return the unmarshaled jalview.binding.JSeq
639 public static jalview.binding.JSeq unmarshal(final java.io.Reader reader)
640 throws org.exolab.castor.xml.MarshalException,
641 org.exolab.castor.xml.ValidationException
643 return (jalview.binding.JSeq) Unmarshaller.unmarshal(
644 jalview.binding.JSeq.class, reader);
650 * @throws org.exolab.castor.xml.ValidationException
651 * if this object is an invalid instance according to the
654 public void validate() throws org.exolab.castor.xml.ValidationException
656 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
657 validator.validate(this);