2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
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 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 * The Jalview Authors are detailed in the 'AUTHORS' file.
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 schema
410 public void marshal(final java.io.Writer out)
411 throws org.exolab.castor.xml.MarshalException,
412 org.exolab.castor.xml.ValidationException
414 Marshaller.marshal(this, out);
421 * @throws java.io.IOException
422 * if an IOException occurs during marshaling
423 * @throws org.exolab.castor.xml.ValidationException
424 * if this object is an invalid instance according to the schema
425 * @throws org.exolab.castor.xml.MarshalException
426 * if object is null or if any SAXException is thrown during
429 public void marshal(final org.xml.sax.ContentHandler handler)
430 throws java.io.IOException,
431 org.exolab.castor.xml.MarshalException,
432 org.exolab.castor.xml.ValidationException
434 Marshaller.marshal(this, handler);
439 public void removeAllFeatures()
441 this._featuresList.clear();
446 public void removeAllPdbids()
448 this._pdbidsList.clear();
452 * Method removeFeatures.
455 * @return true if the object was removed from the collection.
457 public boolean removeFeatures(final jalview.binding.Features vFeatures)
459 boolean removed = _featuresList.remove(vFeatures);
464 * Method removeFeaturesAt.
467 * @return the element removed from the collection
469 public jalview.binding.Features removeFeaturesAt(final int index)
471 java.lang.Object obj = this._featuresList.remove(index);
472 return (jalview.binding.Features) obj;
476 * Method removePdbids.
479 * @return true if the object was removed from the collection.
481 public boolean removePdbids(final jalview.binding.Pdbids vPdbids)
483 boolean removed = _pdbidsList.remove(vPdbids);
488 * Method removePdbidsAt.
491 * @return the element removed from the collection
493 public jalview.binding.Pdbids removePdbidsAt(final int index)
495 java.lang.Object obj = this._pdbidsList.remove(index);
496 return (jalview.binding.Pdbids) obj;
500 * Sets the value of field 'colour'.
503 * the value of field 'colour'.
505 public void setColour(final int colour)
507 this._colour = colour;
508 this._has_colour = true;
512 * Sets the value of field 'end'.
515 * the value of field 'end'.
517 public void setEnd(final int end)
520 this._has_end = true;
528 * @throws java.lang.IndexOutOfBoundsException
529 * if the index given is outside the bounds of the collection
531 public void setFeatures(final int index,
532 final jalview.binding.Features vFeatures)
533 throws java.lang.IndexOutOfBoundsException
535 // check bounds for index
536 if (index < 0 || index >= this._featuresList.size())
538 throw new IndexOutOfBoundsException("setFeatures: Index value '"
539 + index + "' not in range [0.."
540 + (this._featuresList.size() - 1) + "]");
543 this._featuresList.set(index, vFeatures);
549 * @param vFeaturesArray
551 public void setFeatures(final jalview.binding.Features[] vFeaturesArray)
554 _featuresList.clear();
556 for (int i = 0; i < vFeaturesArray.length; i++)
558 this._featuresList.add(vFeaturesArray[i]);
563 * Sets the value of field 'id'.
566 * the value of field 'id'.
568 public void setId(final int id)
579 * @throws java.lang.IndexOutOfBoundsException
580 * if the index given is outside the bounds of the collection
582 public void setPdbids(final int index,
583 final jalview.binding.Pdbids vPdbids)
584 throws java.lang.IndexOutOfBoundsException
586 // check bounds for index
587 if (index < 0 || index >= this._pdbidsList.size())
589 throw new IndexOutOfBoundsException("setPdbids: Index value '"
590 + index + "' not in range [0.."
591 + (this._pdbidsList.size() - 1) + "]");
594 this._pdbidsList.set(index, vPdbids);
600 * @param vPdbidsArray
602 public void setPdbids(final jalview.binding.Pdbids[] vPdbidsArray)
607 for (int i = 0; i < vPdbidsArray.length; i++)
609 this._pdbidsList.add(vPdbidsArray[i]);
614 * Sets the value of field 'start'.
617 * the value of field 'start'.
619 public void setStart(final int start)
622 this._has_start = true;
629 * @throws org.exolab.castor.xml.MarshalException
630 * if object is null or if any SAXException is thrown during
632 * @throws org.exolab.castor.xml.ValidationException
633 * if this object is an invalid instance according to the schema
634 * @return the unmarshaled jalview.binding.JSeq
636 public static jalview.binding.JSeq unmarshal(final java.io.Reader reader)
637 throws org.exolab.castor.xml.MarshalException,
638 org.exolab.castor.xml.ValidationException
640 return (jalview.binding.JSeq) Unmarshaller.unmarshal(
641 jalview.binding.JSeq.class, reader);
647 * @throws org.exolab.castor.xml.ValidationException
648 * if this object is an invalid instance according to the schema
650 public void validate() throws org.exolab.castor.xml.ValidationException
652 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
653 validator.validate(this);