X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbinding%2FSequenceSet.java;h=4300c3951138022ebea8373e76a81051127bcae9;hb=588042b69abf8e60bcc950b24c283933c7dd422f;hp=7ef5fe75336f8a0b49ce0163d4f57d6c40212849;hpb=5cd8e373c75fb348ecda4d94d8a46468fb92756d;p=jalview.git diff --git a/src/jalview/binding/SequenceSet.java b/src/jalview/binding/SequenceSet.java index 7ef5fe7..4300c39 100755 --- a/src/jalview/binding/SequenceSet.java +++ b/src/jalview/binding/SequenceSet.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,24 +22,26 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; + +import org.xml.sax.ContentHandler; +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ import java.io.IOException; import java.io.Reader; import java.io.Serializable; import java.io.Writer; + import java.util.Enumeration; import java.util.Vector; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; + /** * Class SequenceSet. @@ -48,10 +49,8 @@ import org.xml.sax.ContentHandler; * @version $Revision$ $Date$ */ public class SequenceSet implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -79,34 +78,22 @@ public class SequenceSet implements java.io.Serializable { */ private java.util.Vector _annotationList; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public SequenceSet() { super(); _sequenceList = new Vector(); _annotationList = new Vector(); - } //-- jalview.binding.SequenceSet() + } + //-- jalview.binding.SequenceSet() + //-----------/ - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addAnnotation - * - * - * - * @param vAnnotation - */ public void addAnnotation(jalview.binding.Annotation vAnnotation) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _annotationList.addElement(vAnnotation); - } //-- void addAnnotation(jalview.binding.Annotation) + } + //-- void addAnnotation(jalview.binding.Annotation) /** * Method addAnnotation @@ -117,10 +104,10 @@ public class SequenceSet implements java.io.Serializable { * @param vAnnotation */ public void addAnnotation(int index, jalview.binding.Annotation vAnnotation) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _annotationList.insertElementAt(vAnnotation, index); - } //-- void addAnnotation(int, jalview.binding.Annotation) + } + //-- void addAnnotation(int, jalview.binding.Annotation) /** * Method addSequence @@ -130,10 +117,10 @@ public class SequenceSet implements java.io.Serializable { * @param vSequence */ public void addSequence(jalview.binding.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _sequenceList.addElement(vSequence); - } //-- void addSequence(jalview.binding.Sequence) + } + //-- void addSequence(jalview.binding.Sequence) /** * Method addSequence @@ -144,19 +131,19 @@ public class SequenceSet implements java.io.Serializable { * @param vSequence */ public void addSequence(int index, jalview.binding.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _sequenceList.insertElementAt(vSequence, index); - } //-- void addSequence(int, jalview.binding.Sequence) + } + //-- void addSequence(int, jalview.binding.Sequence) /** * Method deleteAligned * */ - public void deleteAligned() - { - this._has_aligned= false; - } //-- void deleteAligned() + public void deleteAligned() { + this._has_aligned = false; + } + //-- void deleteAligned() /** * Method enumerateAnnotation @@ -165,10 +152,10 @@ public class SequenceSet implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateAnnotation() - { + public java.util.Enumeration enumerateAnnotation() { return _annotationList.elements(); - } //-- java.util.Enumeration enumerateAnnotation() + } + //-- java.util.Enumeration enumerateAnnotation() /** * Method enumerateSequence @@ -177,10 +164,10 @@ public class SequenceSet implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateSequence() - { + public java.util.Enumeration enumerateSequence() { return _sequenceList.elements(); - } //-- java.util.Enumeration enumerateSequence() + } + //-- java.util.Enumeration enumerateSequence() /** * Returns the value of field 'aligned'. @@ -188,10 +175,10 @@ public class SequenceSet implements java.io.Serializable { * @return boolean * @return the value of field 'aligned'. */ - public boolean getAligned() - { + public boolean getAligned() { return this._aligned; - } //-- boolean getAligned() + } + //-- boolean getAligned() /** * Method getAnnotation @@ -202,15 +189,15 @@ public class SequenceSet implements java.io.Serializable { * @return Annotation */ public jalview.binding.Annotation getAnnotation(int index) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index if ((index < 0) || (index > _annotationList.size())) { throw new IndexOutOfBoundsException(); } return (jalview.binding.Annotation) _annotationList.elementAt(index); - } //-- jalview.binding.Annotation getAnnotation(int) + } + //-- jalview.binding.Annotation getAnnotation(int) /** * Method getAnnotation @@ -219,15 +206,17 @@ public class SequenceSet implements java.io.Serializable { * * @return Annotation */ - public jalview.binding.Annotation[] getAnnotation() - { + public jalview.binding.Annotation[] getAnnotation() { int size = _annotationList.size(); jalview.binding.Annotation[] mArray = new jalview.binding.Annotation[size]; + for (int index = 0; index < size; index++) { mArray[index] = (jalview.binding.Annotation) _annotationList.elementAt(index); } + return mArray; - } //-- jalview.binding.Annotation[] getAnnotation() + } + //-- jalview.binding.Annotation[] getAnnotation() /** * Method getAnnotationCount @@ -236,10 +225,10 @@ public class SequenceSet implements java.io.Serializable { * * @return int */ - public int getAnnotationCount() - { + public int getAnnotationCount() { return _annotationList.size(); - } //-- int getAnnotationCount() + } + //-- int getAnnotationCount() /** * Returns the value of field 'gapChar'. @@ -247,10 +236,10 @@ public class SequenceSet implements java.io.Serializable { * @return String * @return the value of field 'gapChar'. */ - public java.lang.String getGapChar() - { + public java.lang.String getGapChar() { return this._gapChar; - } //-- java.lang.String getGapChar() + } + //-- java.lang.String getGapChar() /** * Method getSequence @@ -261,15 +250,15 @@ public class SequenceSet implements java.io.Serializable { * @return Sequence */ public jalview.binding.Sequence getSequence(int index) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index if ((index < 0) || (index > _sequenceList.size())) { throw new IndexOutOfBoundsException(); } return (jalview.binding.Sequence) _sequenceList.elementAt(index); - } //-- jalview.binding.Sequence getSequence(int) + } + //-- jalview.binding.Sequence getSequence(int) /** * Method getSequence @@ -278,15 +267,17 @@ public class SequenceSet implements java.io.Serializable { * * @return Sequence */ - public jalview.binding.Sequence[] getSequence() - { + public jalview.binding.Sequence[] getSequence() { int size = _sequenceList.size(); jalview.binding.Sequence[] mArray = new jalview.binding.Sequence[size]; + for (int index = 0; index < size; index++) { mArray[index] = (jalview.binding.Sequence) _sequenceList.elementAt(index); } + return mArray; - } //-- jalview.binding.Sequence[] getSequence() + } + //-- jalview.binding.Sequence[] getSequence() /** * Method getSequenceCount @@ -295,10 +286,10 @@ public class SequenceSet implements java.io.Serializable { * * @return int */ - public int getSequenceCount() - { + public int getSequenceCount() { return _sequenceList.size(); - } //-- int getSequenceCount() + } + //-- int getSequenceCount() /** * Method hasAligned @@ -307,10 +298,10 @@ public class SequenceSet implements java.io.Serializable { * * @return boolean */ - public boolean hasAligned() - { + public boolean hasAligned() { return this._has_aligned; - } //-- boolean hasAligned() + } + //-- boolean hasAligned() /** * Method isValid @@ -319,16 +310,16 @@ public class SequenceSet implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { try { validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { + } catch (org.exolab.castor.xml.ValidationException vex) { return false; } + return true; - } //-- boolean isValid() + } + //-- boolean isValid() /** * Method marshal @@ -338,11 +329,11 @@ public class SequenceSet implements java.io.Serializable { * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + //-- void marshal(java.io.Writer) /** * Method marshal @@ -352,29 +343,29 @@ public class SequenceSet implements java.io.Serializable { * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + //-- void marshal(org.xml.sax.ContentHandler) /** * Method removeAllAnnotation * */ - public void removeAllAnnotation() - { + public void removeAllAnnotation() { _annotationList.removeAllElements(); - } //-- void removeAllAnnotation() + } + //-- void removeAllAnnotation() /** * Method removeAllSequence * */ - public void removeAllSequence() - { + public void removeAllSequence() { _sequenceList.removeAllElements(); - } //-- void removeAllSequence() + } + //-- void removeAllSequence() /** * Method removeAnnotation @@ -384,12 +375,13 @@ public class SequenceSet implements java.io.Serializable { * @param index * @return Annotation */ - public jalview.binding.Annotation removeAnnotation(int index) - { + public jalview.binding.Annotation removeAnnotation(int index) { java.lang.Object obj = _annotationList.elementAt(index); _annotationList.removeElementAt(index); + return (jalview.binding.Annotation) obj; - } //-- jalview.binding.Annotation removeAnnotation(int) + } + //-- jalview.binding.Annotation removeAnnotation(int) /** * Method removeSequence @@ -399,23 +391,24 @@ public class SequenceSet implements java.io.Serializable { * @param index * @return Sequence */ - public jalview.binding.Sequence removeSequence(int index) - { + public jalview.binding.Sequence removeSequence(int index) { java.lang.Object obj = _sequenceList.elementAt(index); _sequenceList.removeElementAt(index); + return (jalview.binding.Sequence) obj; - } //-- jalview.binding.Sequence removeSequence(int) + } + //-- jalview.binding.Sequence removeSequence(int) /** * Sets the value of field 'aligned'. * * @param aligned the value of field 'aligned'. */ - public void setAligned(boolean aligned) - { + public void setAligned(boolean aligned) { this._aligned = aligned; this._has_aligned = true; - } //-- void setAligned(boolean) + } + //-- void setAligned(boolean) /** * Method setAnnotation @@ -426,14 +419,15 @@ public class SequenceSet implements java.io.Serializable { * @param vAnnotation */ public void setAnnotation(int index, jalview.binding.Annotation vAnnotation) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index if ((index < 0) || (index > _annotationList.size())) { throw new IndexOutOfBoundsException(); } + _annotationList.setElementAt(vAnnotation, index); - } //-- void setAnnotation(int, jalview.binding.Annotation) + } + //-- void setAnnotation(int, jalview.binding.Annotation) /** * Method setAnnotation @@ -442,24 +436,25 @@ public class SequenceSet implements java.io.Serializable { * * @param annotationArray */ - public void setAnnotation(jalview.binding.Annotation[] annotationArray) - { + public void setAnnotation(jalview.binding.Annotation[] annotationArray) { //-- copy array _annotationList.removeAllElements(); + for (int i = 0; i < annotationArray.length; i++) { _annotationList.addElement(annotationArray[i]); } - } //-- void setAnnotation(jalview.binding.Annotation) + } + //-- void setAnnotation(jalview.binding.Annotation) /** * Sets the value of field 'gapChar'. * * @param gapChar the value of field 'gapChar'. */ - public void setGapChar(java.lang.String gapChar) - { + public void setGapChar(java.lang.String gapChar) { this._gapChar = gapChar; - } //-- void setGapChar(java.lang.String) + } + //-- void setGapChar(java.lang.String) /** * Method setSequence @@ -470,14 +465,15 @@ public class SequenceSet implements java.io.Serializable { * @param vSequence */ public void setSequence(int index, jalview.binding.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index if ((index < 0) || (index > _sequenceList.size())) { throw new IndexOutOfBoundsException(); } + _sequenceList.setElementAt(vSequence, index); - } //-- void setSequence(int, jalview.binding.Sequence) + } + //-- void setSequence(int, jalview.binding.Sequence) /** * Method setSequence @@ -486,14 +482,15 @@ public class SequenceSet implements java.io.Serializable { * * @param sequenceArray */ - public void setSequence(jalview.binding.Sequence[] sequenceArray) - { + public void setSequence(jalview.binding.Sequence[] sequenceArray) { //-- copy array _sequenceList.removeAllElements(); + for (int i = 0; i < sequenceArray.length; i++) { _sequenceList.addElement(sequenceArray[i]); } - } //-- void setSequence(jalview.binding.Sequence) + } + //-- void setSequence(jalview.binding.Sequence) /** * Method unmarshal @@ -504,20 +501,20 @@ public class SequenceSet implements java.io.Serializable { * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - return (jalview.binding.SequenceSet) Unmarshaller.unmarshal(jalview.binding.SequenceSet.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { + return (jalview.binding.SequenceSet) Unmarshaller.unmarshal(jalview.binding.SequenceSet.class, + reader); + } + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate * */ - public void validate() - throws org.exolab.castor.xml.ValidationException - { + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() - + } + //-- void validate() }