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.schemabinding.version2;
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;
75 private java.lang.String _id;
80 private boolean _hidden;
83 * keeps track of state for field: _hidden
85 private boolean _has_hidden;
88 * Field _featuresList.
90 private java.util.Vector _featuresList;
95 private java.util.Vector _pdbidsList;
98 * Field _hiddenSequencesList.
100 private java.util.Vector _hiddenSequencesList;
109 this._featuresList = new java.util.Vector();
110 this._pdbidsList = new java.util.Vector();
111 this._hiddenSequencesList = new java.util.Vector();
122 * @throws java.lang.IndexOutOfBoundsException
123 * if the index given is outside the bounds of the collection
125 public void addFeatures(
126 final jalview.schemabinding.version2.Features vFeatures)
127 throws java.lang.IndexOutOfBoundsException
129 this._featuresList.addElement(vFeatures);
137 * @throws java.lang.IndexOutOfBoundsException
138 * if the index given is outside the bounds of the collection
140 public void addFeatures(final int index,
141 final jalview.schemabinding.version2.Features vFeatures)
142 throws java.lang.IndexOutOfBoundsException
144 this._featuresList.add(index, vFeatures);
150 * @param vHiddenSequences
151 * @throws java.lang.IndexOutOfBoundsException
152 * if the index given is outside the bounds of the collection
154 public void addHiddenSequences(final int vHiddenSequences)
155 throws java.lang.IndexOutOfBoundsException
157 this._hiddenSequencesList.addElement(new java.lang.Integer(
165 * @param vHiddenSequences
166 * @throws java.lang.IndexOutOfBoundsException
167 * if the index given is outside the bounds of the collection
169 public void addHiddenSequences(final int index, final int vHiddenSequences)
170 throws java.lang.IndexOutOfBoundsException
172 this._hiddenSequencesList.add(index, new java.lang.Integer(
180 * @throws java.lang.IndexOutOfBoundsException
181 * if the index given is outside the bounds of the collection
183 public void addPdbids(final jalview.schemabinding.version2.Pdbids vPdbids)
184 throws java.lang.IndexOutOfBoundsException
186 this._pdbidsList.addElement(vPdbids);
194 * @throws java.lang.IndexOutOfBoundsException
195 * if the index given is outside the bounds of the collection
197 public void addPdbids(final int index,
198 final jalview.schemabinding.version2.Pdbids vPdbids)
199 throws java.lang.IndexOutOfBoundsException
201 this._pdbidsList.add(index, vPdbids);
206 public void deleteColour()
208 this._has_colour = false;
213 public void deleteEnd()
215 this._has_end = false;
220 public void deleteHidden()
222 this._has_hidden = false;
227 public void deleteStart()
229 this._has_start = false;
233 * Method enumerateFeatures.
235 * @return an Enumeration over all jalview.schemabinding.version2.Features
238 public java.util.Enumeration enumerateFeatures()
240 return this._featuresList.elements();
244 * Method enumerateHiddenSequences.
246 * @return an Enumeration over all int elements
248 public java.util.Enumeration enumerateHiddenSequences()
250 return this._hiddenSequencesList.elements();
254 * Method enumeratePdbids.
256 * @return an Enumeration over all jalview.schemabinding.version2.Pdbids
259 public java.util.Enumeration enumeratePdbids()
261 return this._pdbidsList.elements();
265 * Returns the value of field 'colour'.
267 * @return the value of field 'Colour'.
269 public int getColour()
275 * Returns the value of field 'end'.
277 * @return the value of field 'End'.
285 * Method getFeatures.
288 * @throws java.lang.IndexOutOfBoundsException
289 * if the index given is outside the bounds of the collection
290 * @return the value of the jalview.schemabinding.version2.Features at the
293 public jalview.schemabinding.version2.Features getFeatures(final int index)
294 throws java.lang.IndexOutOfBoundsException
296 // check bounds for index
297 if (index < 0 || index >= this._featuresList.size())
299 throw new IndexOutOfBoundsException("getFeatures: Index value '"
300 + index + "' not in range [0.."
301 + (this._featuresList.size() - 1) + "]");
304 return (jalview.schemabinding.version2.Features) _featuresList
309 * Method getFeatures.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.schemabinding.version2.Features[] getFeatures()
319 jalview.schemabinding.version2.Features[] array = new jalview.schemabinding.version2.Features[0];
320 return (jalview.schemabinding.version2.Features[]) this._featuresList
325 * Method getFeaturesCount.
327 * @return the size of this collection
329 public int getFeaturesCount()
331 return this._featuresList.size();
335 * Returns the value of field 'hidden'.
337 * @return the value of field 'Hidden'.
339 public boolean getHidden()
345 * Method getHiddenSequences.
348 * @throws java.lang.IndexOutOfBoundsException
349 * if the index given is outside the bounds of the collection
350 * @return the value of the int at the given index
352 public int getHiddenSequences(final int index)
353 throws java.lang.IndexOutOfBoundsException
355 // check bounds for index
356 if (index < 0 || index >= this._hiddenSequencesList.size())
358 throw new IndexOutOfBoundsException(
359 "getHiddenSequences: Index value '" + index
360 + "' not in range [0.."
361 + (this._hiddenSequencesList.size() - 1) + "]");
364 return ((java.lang.Integer) _hiddenSequencesList.get(index)).intValue();
368 * Method getHiddenSequences.Returns the contents of the collection in an
371 * @return this collection as an Array
373 public int[] getHiddenSequences()
375 int size = this._hiddenSequencesList.size();
376 int[] array = new int[size];
377 java.util.Iterator iter = _hiddenSequencesList.iterator();
378 for (int index = 0; index < size; index++)
380 array[index] = ((java.lang.Integer) iter.next()).intValue();
386 * Method getHiddenSequencesCount.
388 * @return the size of this collection
390 public int getHiddenSequencesCount()
392 return this._hiddenSequencesList.size();
396 * Returns the value of field 'id'.
398 * @return the value of field 'Id'.
400 public java.lang.String getId()
409 * @throws java.lang.IndexOutOfBoundsException
410 * if the index given is outside the bounds of the collection
411 * @return the value of the jalview.schemabinding.version2.Pdbids at the given
414 public jalview.schemabinding.version2.Pdbids getPdbids(final int index)
415 throws java.lang.IndexOutOfBoundsException
417 // check bounds for index
418 if (index < 0 || index >= this._pdbidsList.size())
420 throw new IndexOutOfBoundsException("getPdbids: Index value '"
421 + index + "' not in range [0.."
422 + (this._pdbidsList.size() - 1) + "]");
425 return (jalview.schemabinding.version2.Pdbids) _pdbidsList.get(index);
429 * Method getPdbids.Returns the contents of the collection in an Array.
431 * Note: Just in case the collection contents are changing in another thread,
432 * we pass a 0-length Array of the correct type into the API call. This way we
433 * <i>know</i> that the Array returned is of exactly the correct length.
435 * @return this collection as an Array
437 public jalview.schemabinding.version2.Pdbids[] getPdbids()
439 jalview.schemabinding.version2.Pdbids[] array = new jalview.schemabinding.version2.Pdbids[0];
440 return (jalview.schemabinding.version2.Pdbids[]) this._pdbidsList
445 * Method getPdbidsCount.
447 * @return the size of this collection
449 public int getPdbidsCount()
451 return this._pdbidsList.size();
455 * Returns the value of field 'start'.
457 * @return the value of field 'Start'.
459 public int getStart()
467 * @return true if at least one Colour has been added
469 public boolean hasColour()
471 return this._has_colour;
477 * @return true if at least one End has been added
479 public boolean hasEnd()
481 return this._has_end;
487 * @return true if at least one Hidden has been added
489 public boolean hasHidden()
491 return this._has_hidden;
497 * @return true if at least one Start has been added
499 public boolean hasStart()
501 return this._has_start;
505 * Returns the value of field 'hidden'.
507 * @return the value of field 'Hidden'.
509 public boolean isHidden()
517 * @return true if this object is valid according to the schema
519 public boolean isValid()
524 } catch (org.exolab.castor.xml.ValidationException vex)
535 * @throws org.exolab.castor.xml.MarshalException
536 * if object is null or if any SAXException is thrown during
538 * @throws org.exolab.castor.xml.ValidationException
539 * if this object is an invalid instance according to the schema
541 public void marshal(final java.io.Writer out)
542 throws org.exolab.castor.xml.MarshalException,
543 org.exolab.castor.xml.ValidationException
545 Marshaller.marshal(this, out);
552 * @throws java.io.IOException
553 * if an IOException occurs during marshaling
554 * @throws org.exolab.castor.xml.ValidationException
555 * if this object is an invalid instance according to the schema
556 * @throws org.exolab.castor.xml.MarshalException
557 * if object is null or if any SAXException is thrown during
560 public void marshal(final org.xml.sax.ContentHandler handler)
561 throws java.io.IOException,
562 org.exolab.castor.xml.MarshalException,
563 org.exolab.castor.xml.ValidationException
565 Marshaller.marshal(this, handler);
570 public void removeAllFeatures()
572 this._featuresList.clear();
577 public void removeAllHiddenSequences()
579 this._hiddenSequencesList.clear();
584 public void removeAllPdbids()
586 this._pdbidsList.clear();
590 * Method removeFeatures.
593 * @return true if the object was removed from the collection.
595 public boolean removeFeatures(
596 final jalview.schemabinding.version2.Features vFeatures)
598 boolean removed = _featuresList.remove(vFeatures);
603 * Method removeFeaturesAt.
606 * @return the element removed from the collection
608 public jalview.schemabinding.version2.Features removeFeaturesAt(
611 java.lang.Object obj = this._featuresList.remove(index);
612 return (jalview.schemabinding.version2.Features) obj;
616 * Method removeHiddenSequences.
618 * @param vHiddenSequences
619 * @return true if the object was removed from the collection.
621 public boolean removeHiddenSequences(final int vHiddenSequences)
623 boolean removed = _hiddenSequencesList.remove(new java.lang.Integer(
629 * Method removeHiddenSequencesAt.
632 * @return the element removed from the collection
634 public int removeHiddenSequencesAt(final int index)
636 java.lang.Object obj = this._hiddenSequencesList.remove(index);
637 return ((java.lang.Integer) obj).intValue();
641 * Method removePdbids.
644 * @return true if the object was removed from the collection.
646 public boolean removePdbids(
647 final jalview.schemabinding.version2.Pdbids vPdbids)
649 boolean removed = _pdbidsList.remove(vPdbids);
654 * Method removePdbidsAt.
657 * @return the element removed from the collection
659 public jalview.schemabinding.version2.Pdbids removePdbidsAt(
662 java.lang.Object obj = this._pdbidsList.remove(index);
663 return (jalview.schemabinding.version2.Pdbids) obj;
667 * Sets the value of field 'colour'.
670 * the value of field 'colour'.
672 public void setColour(final int colour)
674 this._colour = colour;
675 this._has_colour = true;
679 * Sets the value of field 'end'.
682 * the value of field 'end'.
684 public void setEnd(final int end)
687 this._has_end = true;
695 * @throws java.lang.IndexOutOfBoundsException
696 * if the index given is outside the bounds of the collection
698 public void setFeatures(final int index,
699 final jalview.schemabinding.version2.Features vFeatures)
700 throws java.lang.IndexOutOfBoundsException
702 // check bounds for index
703 if (index < 0 || index >= this._featuresList.size())
705 throw new IndexOutOfBoundsException("setFeatures: Index value '"
706 + index + "' not in range [0.."
707 + (this._featuresList.size() - 1) + "]");
710 this._featuresList.set(index, vFeatures);
716 * @param vFeaturesArray
718 public void setFeatures(
719 final jalview.schemabinding.version2.Features[] vFeaturesArray)
722 _featuresList.clear();
724 for (int i = 0; i < vFeaturesArray.length; i++)
726 this._featuresList.add(vFeaturesArray[i]);
731 * Sets the value of field 'hidden'.
734 * the value of field 'hidden'.
736 public void setHidden(final boolean hidden)
738 this._hidden = hidden;
739 this._has_hidden = true;
746 * @param vHiddenSequences
747 * @throws java.lang.IndexOutOfBoundsException
748 * if the index given is outside the bounds of the collection
750 public void setHiddenSequences(final int index, final int vHiddenSequences)
751 throws java.lang.IndexOutOfBoundsException
753 // check bounds for index
754 if (index < 0 || index >= this._hiddenSequencesList.size())
756 throw new IndexOutOfBoundsException(
757 "setHiddenSequences: Index value '" + index
758 + "' not in range [0.."
759 + (this._hiddenSequencesList.size() - 1) + "]");
762 this._hiddenSequencesList.set(index, new java.lang.Integer(
769 * @param vHiddenSequencesArray
771 public void setHiddenSequences(final int[] vHiddenSequencesArray)
774 _hiddenSequencesList.clear();
776 for (int i = 0; i < vHiddenSequencesArray.length; i++)
778 this._hiddenSequencesList.add(new java.lang.Integer(
779 vHiddenSequencesArray[i]));
784 * Sets the value of field 'id'.
787 * the value of field 'id'.
789 public void setId(final java.lang.String id)
799 * @throws java.lang.IndexOutOfBoundsException
800 * if the index given is outside the bounds of the collection
802 public void setPdbids(final int index,
803 final jalview.schemabinding.version2.Pdbids vPdbids)
804 throws java.lang.IndexOutOfBoundsException
806 // check bounds for index
807 if (index < 0 || index >= this._pdbidsList.size())
809 throw new IndexOutOfBoundsException("setPdbids: Index value '"
810 + index + "' not in range [0.."
811 + (this._pdbidsList.size() - 1) + "]");
814 this._pdbidsList.set(index, vPdbids);
820 * @param vPdbidsArray
822 public void setPdbids(
823 final jalview.schemabinding.version2.Pdbids[] vPdbidsArray)
828 for (int i = 0; i < vPdbidsArray.length; i++)
830 this._pdbidsList.add(vPdbidsArray[i]);
835 * Sets the value of field 'start'.
838 * the value of field 'start'.
840 public void setStart(final int start)
843 this._has_start = true;
850 * @throws org.exolab.castor.xml.MarshalException
851 * if object is null or if any SAXException is thrown during
853 * @throws org.exolab.castor.xml.ValidationException
854 * if this object is an invalid instance according to the schema
855 * @return the unmarshaled jalview.schemabinding.version2.JSeq
857 public static jalview.schemabinding.version2.JSeq unmarshal(
858 final java.io.Reader reader)
859 throws org.exolab.castor.xml.MarshalException,
860 org.exolab.castor.xml.ValidationException
862 return (jalview.schemabinding.version2.JSeq) Unmarshaller.unmarshal(
863 jalview.schemabinding.version2.JSeq.class, reader);
869 * @throws org.exolab.castor.xml.ValidationException
870 * if this object is an invalid instance according to the schema
872 public void validate() throws org.exolab.castor.xml.ValidationException
874 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
875 validator.validate(this);