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 jalview.util.MessageManager;
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
35 * @version $Revision$ $Date$
37 public class JSeq implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
50 * keeps track of state for field: _colour
52 private boolean _has_colour;
60 * keeps track of state for field: _start
62 private boolean _has_start;
70 * keeps track of state for field: _end
72 private boolean _has_end;
80 * keeps track of state for field: _id
82 private boolean _has_id;
85 * Field _featuresList.
87 private java.util.Vector _featuresList;
92 private java.util.Vector _pdbidsList;
101 this._featuresList = new java.util.Vector();
102 this._pdbidsList = new java.util.Vector();
113 * @throws java.lang.IndexOutOfBoundsException
114 * if the index given is outside the bounds of the collection
116 public void addFeatures(final jalview.binding.Features vFeatures)
117 throws java.lang.IndexOutOfBoundsException
119 this._featuresList.addElement(vFeatures);
127 * @throws java.lang.IndexOutOfBoundsException
128 * if the index given is outside the bounds of the collection
130 public void addFeatures(final int index,
131 final jalview.binding.Features vFeatures)
132 throws java.lang.IndexOutOfBoundsException
134 this._featuresList.add(index, vFeatures);
141 * @throws java.lang.IndexOutOfBoundsException
142 * if the index given is outside the bounds of the collection
144 public void addPdbids(final jalview.binding.Pdbids vPdbids)
145 throws java.lang.IndexOutOfBoundsException
147 this._pdbidsList.addElement(vPdbids);
155 * @throws java.lang.IndexOutOfBoundsException
156 * if the index given is outside the bounds of the collection
158 public void addPdbids(final int index,
159 final jalview.binding.Pdbids vPdbids)
160 throws java.lang.IndexOutOfBoundsException
162 this._pdbidsList.add(index, vPdbids);
167 public void deleteColour()
169 this._has_colour = false;
174 public void deleteEnd()
176 this._has_end = false;
181 public void deleteId()
183 this._has_id = false;
188 public void deleteStart()
190 this._has_start = false;
194 * Method enumerateFeatures.
196 * @return an Enumeration over all jalview.binding.Features elements
198 public java.util.Enumeration enumerateFeatures()
200 return this._featuresList.elements();
204 * Method enumeratePdbids.
206 * @return an Enumeration over all jalview.binding.Pdbids elements
208 public java.util.Enumeration enumeratePdbids()
210 return this._pdbidsList.elements();
214 * Returns the value of field 'colour'.
216 * @return the value of field 'Colour'.
218 public int getColour()
224 * Returns the value of field 'end'.
226 * @return the value of field 'End'.
234 * Method getFeatures.
237 * @throws java.lang.IndexOutOfBoundsException
238 * if the index given is outside the bounds of the collection
239 * @return the value of the jalview.binding.Features at the given index
241 public jalview.binding.Features getFeatures(final int index)
242 throws java.lang.IndexOutOfBoundsException
244 // check bounds for index
245 if (index < 0 || index >= this._featuresList.size())
247 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
249 Integer.valueOf(index).toString(),
250 Integer.valueOf((this._featuresList.size() - 1)).toString()
254 return (jalview.binding.Features) _featuresList.get(index);
258 * Method getFeatures.Returns the contents of the collection in an Array.
260 * Note: Just in case the collection contents are changing in another thread,
261 * we pass a 0-length Array of the correct type into the API call. This way we
262 * <i>know</i> that the Array returned is of exactly the correct length.
264 * @return this collection as an Array
266 public jalview.binding.Features[] getFeatures()
268 jalview.binding.Features[] array = new jalview.binding.Features[0];
269 return (jalview.binding.Features[]) this._featuresList.toArray(array);
273 * Method getFeaturesCount.
275 * @return the size of this collection
277 public int getFeaturesCount()
279 return this._featuresList.size();
283 * Returns the value of field 'id'.
285 * @return the value of field 'Id'.
296 * @throws java.lang.IndexOutOfBoundsException
297 * if the index given is outside the bounds of the collection
298 * @return the value of the jalview.binding.Pdbids at the given index
300 public jalview.binding.Pdbids getPdbids(final int index)
301 throws java.lang.IndexOutOfBoundsException
303 // check bounds for index
304 if (index < 0 || index >= this._pdbidsList.size())
306 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
308 Integer.valueOf(index).toString(),
309 Integer.valueOf((this._pdbidsList.size() - 1)).toString()
313 return (jalview.binding.Pdbids) _pdbidsList.get(index);
317 * Method getPdbids.Returns the contents of the collection in an Array.
319 * Note: Just in case the collection contents are changing in another thread,
320 * we pass a 0-length Array of the correct type into the API call. This way we
321 * <i>know</i> that the Array returned is of exactly the correct length.
323 * @return this collection as an Array
325 public jalview.binding.Pdbids[] getPdbids()
327 jalview.binding.Pdbids[] array = new jalview.binding.Pdbids[0];
328 return (jalview.binding.Pdbids[]) this._pdbidsList.toArray(array);
332 * Method getPdbidsCount.
334 * @return the size of this collection
336 public int getPdbidsCount()
338 return this._pdbidsList.size();
342 * Returns the value of field 'start'.
344 * @return the value of field 'Start'.
346 public int getStart()
354 * @return true if at least one Colour has been added
356 public boolean hasColour()
358 return this._has_colour;
364 * @return true if at least one End has been added
366 public boolean hasEnd()
368 return this._has_end;
374 * @return true if at least one Id has been added
376 public boolean hasId()
384 * @return true if at least one Start has been added
386 public boolean hasStart()
388 return this._has_start;
394 * @return true if this object is valid according to the schema
396 public boolean isValid()
401 } catch (org.exolab.castor.xml.ValidationException vex)
412 * @throws org.exolab.castor.xml.MarshalException
413 * if object is null or if any SAXException is thrown during
415 * @throws org.exolab.castor.xml.ValidationException
416 * if this object is an invalid instance according to the schema
418 public void marshal(final java.io.Writer out)
419 throws org.exolab.castor.xml.MarshalException,
420 org.exolab.castor.xml.ValidationException
422 Marshaller.marshal(this, out);
429 * @throws java.io.IOException
430 * if an IOException occurs during marshaling
431 * @throws org.exolab.castor.xml.ValidationException
432 * if this object is an invalid instance according to the schema
433 * @throws org.exolab.castor.xml.MarshalException
434 * if object is null or if any SAXException is thrown during
437 public void marshal(final org.xml.sax.ContentHandler handler)
438 throws java.io.IOException,
439 org.exolab.castor.xml.MarshalException,
440 org.exolab.castor.xml.ValidationException
442 Marshaller.marshal(this, handler);
447 public void removeAllFeatures()
449 this._featuresList.clear();
454 public void removeAllPdbids()
456 this._pdbidsList.clear();
460 * Method removeFeatures.
463 * @return true if the object was removed from the collection.
465 public boolean removeFeatures(final jalview.binding.Features vFeatures)
467 boolean removed = _featuresList.remove(vFeatures);
472 * Method removeFeaturesAt.
475 * @return the element removed from the collection
477 public jalview.binding.Features removeFeaturesAt(final int index)
479 java.lang.Object obj = this._featuresList.remove(index);
480 return (jalview.binding.Features) obj;
484 * Method removePdbids.
487 * @return true if the object was removed from the collection.
489 public boolean removePdbids(final jalview.binding.Pdbids vPdbids)
491 boolean removed = _pdbidsList.remove(vPdbids);
496 * Method removePdbidsAt.
499 * @return the element removed from the collection
501 public jalview.binding.Pdbids removePdbidsAt(final int index)
503 java.lang.Object obj = this._pdbidsList.remove(index);
504 return (jalview.binding.Pdbids) obj;
508 * Sets the value of field 'colour'.
511 * the value of field 'colour'.
513 public void setColour(final int colour)
515 this._colour = colour;
516 this._has_colour = true;
520 * Sets the value of field 'end'.
523 * the value of field 'end'.
525 public void setEnd(final int end)
528 this._has_end = true;
536 * @throws java.lang.IndexOutOfBoundsException
537 * if the index given is outside the bounds of the collection
539 public void setFeatures(final int index,
540 final jalview.binding.Features vFeatures)
541 throws java.lang.IndexOutOfBoundsException
543 // check bounds for index
544 if (index < 0 || index >= this._featuresList.size())
546 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
548 Integer.valueOf(index).toString(),
549 Integer.valueOf((this._featuresList.size() - 1)).toString()
553 this._featuresList.set(index, vFeatures);
559 * @param vFeaturesArray
561 public void setFeatures(final jalview.binding.Features[] vFeaturesArray)
564 _featuresList.clear();
566 for (int i = 0; i < vFeaturesArray.length; i++)
568 this._featuresList.add(vFeaturesArray[i]);
573 * Sets the value of field 'id'.
576 * the value of field 'id'.
578 public void setId(final int id)
589 * @throws java.lang.IndexOutOfBoundsException
590 * if the index given is outside the bounds of the collection
592 public void setPdbids(final int index,
593 final jalview.binding.Pdbids vPdbids)
594 throws java.lang.IndexOutOfBoundsException
596 // check bounds for index
597 if (index < 0 || index >= this._pdbidsList.size())
599 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
601 Integer.valueOf(index).toString(),
602 Integer.valueOf((this._pdbidsList.size() - 1)).toString()
606 this._pdbidsList.set(index, vPdbids);
612 * @param vPdbidsArray
614 public void setPdbids(final jalview.binding.Pdbids[] vPdbidsArray)
619 for (int i = 0; i < vPdbidsArray.length; i++)
621 this._pdbidsList.add(vPdbidsArray[i]);
626 * Sets the value of field 'start'.
629 * the value of field 'start'.
631 public void setStart(final int start)
634 this._has_start = true;
641 * @throws org.exolab.castor.xml.MarshalException
642 * if object is null or if any SAXException is thrown during
644 * @throws org.exolab.castor.xml.ValidationException
645 * if this object is an invalid instance according to the schema
646 * @return the unmarshaled jalview.binding.JSeq
648 public static jalview.binding.JSeq unmarshal(final java.io.Reader reader)
649 throws org.exolab.castor.xml.MarshalException,
650 org.exolab.castor.xml.ValidationException
652 return (jalview.binding.JSeq) Unmarshaller.unmarshal(
653 jalview.binding.JSeq.class, reader);
659 * @throws org.exolab.castor.xml.ValidationException
660 * if this object is an invalid instance according to the schema
662 public void validate() throws org.exolab.castor.xml.ValidationException
664 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
665 validator.validate(this);