2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.
21 package jalview.binding;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import org.exolab.castor.xml.Marshaller;
28 import org.exolab.castor.xml.Unmarshaller;
33 * @version $Revision$ $Date$
35 public class JSeq implements java.io.Serializable
38 // --------------------------/
39 // - Class/Member Variables -/
40 // --------------------------/
48 * keeps track of state for field: _colour
50 private boolean _has_colour;
58 * keeps track of state for field: _start
60 private boolean _has_start;
68 * keeps track of state for field: _end
70 private boolean _has_end;
78 * keeps track of state for field: _id
80 private boolean _has_id;
83 * Field _featuresList.
85 private java.util.Vector _featuresList;
90 private java.util.Vector _pdbidsList;
99 this._featuresList = new java.util.Vector();
100 this._pdbidsList = new java.util.Vector();
111 * @throws java.lang.IndexOutOfBoundsException
112 * if the index given is outside the bounds of the collection
114 public void addFeatures(final jalview.binding.Features vFeatures)
115 throws java.lang.IndexOutOfBoundsException
117 this._featuresList.addElement(vFeatures);
125 * @throws java.lang.IndexOutOfBoundsException
126 * if the index given is outside the bounds of the collection
128 public void addFeatures(final int index,
129 final jalview.binding.Features vFeatures)
130 throws java.lang.IndexOutOfBoundsException
132 this._featuresList.add(index, vFeatures);
139 * @throws java.lang.IndexOutOfBoundsException
140 * if the index given is outside the bounds of the collection
142 public void addPdbids(final jalview.binding.Pdbids vPdbids)
143 throws java.lang.IndexOutOfBoundsException
145 this._pdbidsList.addElement(vPdbids);
153 * @throws java.lang.IndexOutOfBoundsException
154 * if the index given is outside the bounds of the collection
156 public void addPdbids(final int index,
157 final jalview.binding.Pdbids vPdbids)
158 throws java.lang.IndexOutOfBoundsException
160 this._pdbidsList.add(index, vPdbids);
165 public void deleteColour()
167 this._has_colour = false;
172 public void deleteEnd()
174 this._has_end = false;
179 public void deleteId()
181 this._has_id = false;
186 public void deleteStart()
188 this._has_start = false;
192 * Method enumerateFeatures.
194 * @return an Enumeration over all jalview.binding.Features elements
196 public java.util.Enumeration enumerateFeatures()
198 return this._featuresList.elements();
202 * Method enumeratePdbids.
204 * @return an Enumeration over all jalview.binding.Pdbids elements
206 public java.util.Enumeration enumeratePdbids()
208 return this._pdbidsList.elements();
212 * Returns the value of field 'colour'.
214 * @return the value of field 'Colour'.
216 public int getColour()
222 * Returns the value of field 'end'.
224 * @return the value of field 'End'.
232 * Method getFeatures.
235 * @throws java.lang.IndexOutOfBoundsException
236 * if the index given is outside the bounds of the collection
237 * @return the value of the jalview.binding.Features at the given index
239 public jalview.binding.Features getFeatures(final int index)
240 throws java.lang.IndexOutOfBoundsException
242 // check bounds for index
243 if (index < 0 || index >= this._featuresList.size())
245 throw new IndexOutOfBoundsException("getFeatures: Index value '"
246 + index + "' not in range [0.."
247 + (this._featuresList.size() - 1) + "]");
250 return (jalview.binding.Features) _featuresList.get(index);
254 * Method getFeatures.Returns the contents of the collection in an Array.
256 * Note: Just in case the collection contents are changing in another thread,
257 * we pass a 0-length Array of the correct type into the API call. This way we
258 * <i>know</i> that the Array returned is of exactly the correct length.
260 * @return this collection as an Array
262 public jalview.binding.Features[] getFeatures()
264 jalview.binding.Features[] array = new jalview.binding.Features[0];
265 return (jalview.binding.Features[]) this._featuresList.toArray(array);
269 * Method getFeaturesCount.
271 * @return the size of this collection
273 public int getFeaturesCount()
275 return this._featuresList.size();
279 * Returns the value of field 'id'.
281 * @return the value of field 'Id'.
292 * @throws java.lang.IndexOutOfBoundsException
293 * if the index given is outside the bounds of the collection
294 * @return the value of the jalview.binding.Pdbids at the given index
296 public jalview.binding.Pdbids getPdbids(final int index)
297 throws java.lang.IndexOutOfBoundsException
299 // check bounds for index
300 if (index < 0 || index >= this._pdbidsList.size())
302 throw new IndexOutOfBoundsException("getPdbids: Index value '"
303 + index + "' not in range [0.."
304 + (this._pdbidsList.size() - 1) + "]");
307 return (jalview.binding.Pdbids) _pdbidsList.get(index);
311 * Method getPdbids.Returns the contents of the collection in an Array.
313 * Note: Just in case the collection contents are changing in another thread,
314 * we pass a 0-length Array of the correct type into the API call. This way we
315 * <i>know</i> that the Array returned is of exactly the correct length.
317 * @return this collection as an Array
319 public jalview.binding.Pdbids[] getPdbids()
321 jalview.binding.Pdbids[] array = new jalview.binding.Pdbids[0];
322 return (jalview.binding.Pdbids[]) this._pdbidsList.toArray(array);
326 * Method getPdbidsCount.
328 * @return the size of this collection
330 public int getPdbidsCount()
332 return this._pdbidsList.size();
336 * Returns the value of field 'start'.
338 * @return the value of field 'Start'.
340 public int getStart()
348 * @return true if at least one Colour has been added
350 public boolean hasColour()
352 return this._has_colour;
358 * @return true if at least one End has been added
360 public boolean hasEnd()
362 return this._has_end;
368 * @return true if at least one Id has been added
370 public boolean hasId()
378 * @return true if at least one Start has been added
380 public boolean hasStart()
382 return this._has_start;
388 * @return true if this object is valid according to the schema
390 public boolean isValid()
395 } catch (org.exolab.castor.xml.ValidationException vex)
406 * @throws org.exolab.castor.xml.MarshalException
407 * if object is null or if any SAXException is thrown during
409 * @throws org.exolab.castor.xml.ValidationException
410 * if this object is an invalid instance according to the schema
412 public void marshal(final java.io.Writer out)
413 throws org.exolab.castor.xml.MarshalException,
414 org.exolab.castor.xml.ValidationException
416 Marshaller.marshal(this, out);
423 * @throws java.io.IOException
424 * if an IOException occurs during marshaling
425 * @throws org.exolab.castor.xml.ValidationException
426 * if this object is an invalid instance according to the schema
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 schema
636 * @return the unmarshaled jalview.binding.JSeq
638 public static jalview.binding.JSeq unmarshal(final java.io.Reader reader)
639 throws org.exolab.castor.xml.MarshalException,
640 org.exolab.castor.xml.ValidationException
642 return (jalview.binding.JSeq) Unmarshaller.unmarshal(
643 jalview.binding.JSeq.class, reader);
649 * @throws org.exolab.castor.xml.ValidationException
650 * if this object is an invalid instance according to the schema
652 public void validate() throws org.exolab.castor.xml.ValidationException
654 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
655 validator.validate(this);