X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fschemabinding%2Fversion2%2FJalviewUserColours.java;h=7c059da19e9d5e033ec6d7170cd39d412af01a1b;hb=cfa1e4489edf808823a672584fe41084cb33b00f;hp=7963596c9d73f598a4db0281dea4f603ee708c15;hpb=65df62f4b048a1615d32ea2c3576082ad2b63af8;p=jalview.git diff --git a/src/jalview/schemabinding/version2/JalviewUserColours.java b/src/jalview/schemabinding/version2/JalviewUserColours.java index 7963596..7c059da 100755 --- a/src/jalview/schemabinding/version2/JalviewUserColours.java +++ b/src/jalview/schemabinding/version2/JalviewUserColours.java @@ -1,6 +1,6 @@ /* * This class was automatically generated with - * Castor 0.9.6, using an XML + * Castor 1.1, using an XML * Schema. * $Id$ */ @@ -11,17 +11,8 @@ package jalview.schemabinding.version2; //- 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 JalviewUserColours. @@ -36,12 +27,12 @@ public class JalviewUserColours implements java.io.Serializable { //--------------------------/ /** - * Field _schemeName + * Field _schemeName. */ private java.lang.String _schemeName; /** - * Field _colourList + * Field _colourList. */ private java.util.Vector _colourList; @@ -52,8 +43,8 @@ public class JalviewUserColours implements java.io.Serializable { public JalviewUserColours() { super(); - _colourList = new Vector(); - } //-- jalview.schemabinding.version2.JalviewUserColours() + this._colourList = new java.util.Vector(); + } //-----------/ @@ -61,240 +52,248 @@ public class JalviewUserColours implements java.io.Serializable { //-----------/ /** - * Method addColour - * * * * @param vColour + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection */ - public void addColour(jalview.schemabinding.version2.Colour vColour) - throws java.lang.IndexOutOfBoundsException - { - _colourList.addElement(vColour); - } //-- void addColour(jalview.schemabinding.version2.Colour) + public void addColour( + final Colour vColour) + throws java.lang.IndexOutOfBoundsException { + this._colourList.addElement(vColour); + } /** - * Method addColour - * * * * @param index * @param vColour + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection */ - public void addColour(int index, jalview.schemabinding.version2.Colour vColour) - throws java.lang.IndexOutOfBoundsException - { - _colourList.insertElementAt(vColour, index); - } //-- void addColour(int, jalview.schemabinding.version2.Colour) + public void addColour( + final int index, + final Colour vColour) + throws java.lang.IndexOutOfBoundsException { + this._colourList.add(index, vColour); + } /** - * Method enumerateColour - * - * + * Method enumerateColour. * - * @return Enumeration + * @return an Enumeration over all Colour elements */ - public java.util.Enumeration enumerateColour() - { - return _colourList.elements(); - } //-- java.util.Enumeration enumerateColour() + public java.util.Enumeration enumerateColour( + ) { + return this._colourList.elements(); + } /** - * Method getColour - * - * + * Method getColour. * * @param index - * @return Colour + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + * @return the value of the Colour at the given index */ - public jalview.schemabinding.version2.Colour getColour(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _colourList.size())) { - throw new IndexOutOfBoundsException(); + public Colour getColour( + final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._colourList.size()) { + throw new IndexOutOfBoundsException("getColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]"); } - return (jalview.schemabinding.version2.Colour) _colourList.elementAt(index); - } //-- jalview.schemabinding.version2.Colour getColour(int) + return (Colour) _colourList.get(index); + } /** - * Method getColour - * - * + * Method getColour.Returns the contents of the collection in + * an Array.

Note: Just in case the collection contents + * are changing in another thread, we pass a 0-length Array of + * the correct type into the API call. This way we know + * that the Array returned is of exactly the correct length. * - * @return Colour + * @return this collection as an Array */ - public jalview.schemabinding.version2.Colour[] getColour() - { - int size = _colourList.size(); - jalview.schemabinding.version2.Colour[] mArray = new jalview.schemabinding.version2.Colour[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (jalview.schemabinding.version2.Colour) _colourList.elementAt(index); - } - return mArray; - } //-- jalview.schemabinding.version2.Colour[] getColour() + public Colour[] getColour( + ) { + Colour[] array = new Colour[0]; + return (Colour[]) this._colourList.toArray(array); + } /** - * Method getColourCount - * + * Method getColourCount. * - * - * @return int + * @return the size of this collection */ - public int getColourCount() - { - return _colourList.size(); - } //-- int getColourCount() + public int getColourCount( + ) { + return this._colourList.size(); + } /** * Returns the value of field 'schemeName'. * - * @return String - * @return the value of field 'schemeName'. + * @return the value of field 'SchemeName'. */ - public java.lang.String getSchemeName() - { + public java.lang.String getSchemeName( + ) { return this._schemeName; - } //-- java.lang.String getSchemeName() + } /** - * Method isValid - * + * Method isValid. * - * - * @return boolean + * @return true if this object is valid according to the schema */ - 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() + } /** - * Method marshal - * * * * @param out + * @throws org.exolab.castor.xml.MarshalException if object is + * null or if any SAXException is thrown during marshaling + * @throws org.exolab.castor.xml.ValidationException if this + * object is an invalid instance according to the schema */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - + public void marshal( + final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } /** - * Method marshal - * * * * @param handler + * @throws java.io.IOException if an IOException occurs during + * marshaling + * @throws org.exolab.castor.xml.ValidationException if this + * object is an invalid instance according to the schema + * @throws org.exolab.castor.xml.MarshalException if object is + * null or if any SAXException is thrown during marshaling */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - + public void marshal( + final org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } /** - * Method removeAllColour - * */ - public void removeAllColour() - { - _colourList.removeAllElements(); - } //-- void removeAllColour() + public void removeAllColour( + ) { + this._colourList.clear(); + } /** - * Method removeColour - * + * Method removeColour. * + * @param vColour + * @return true if the object was removed from the collection. + */ + public boolean removeColour( + final Colour vColour) { + boolean removed = _colourList.remove(vColour); + return removed; + } + + /** + * Method removeColourAt. * * @param index - * @return Colour + * @return the element removed from the collection */ - public jalview.schemabinding.version2.Colour removeColour(int index) - { - java.lang.Object obj = _colourList.elementAt(index); - _colourList.removeElementAt(index); - return (jalview.schemabinding.version2.Colour) obj; - } //-- jalview.schemabinding.version2.Colour removeColour(int) + public Colour removeColourAt( + final int index) { + java.lang.Object obj = this._colourList.remove(index); + return (Colour) obj; + } /** - * Method setColour - * * * * @param index * @param vColour + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection */ - public void setColour(int index, jalview.schemabinding.version2.Colour vColour) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _colourList.size())) { - throw new IndexOutOfBoundsException(); + public void setColour( + final int index, + final Colour vColour) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._colourList.size()) { + throw new IndexOutOfBoundsException("setColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]"); } - _colourList.setElementAt(vColour, index); - } //-- void setColour(int, jalview.schemabinding.version2.Colour) + + this._colourList.set(index, vColour); + } /** - * Method setColour * * - * - * @param colourArray + * @param vColourArray */ - public void setColour(jalview.schemabinding.version2.Colour[] colourArray) - { + public void setColour( + final Colour[] vColourArray) { //-- copy array - _colourList.removeAllElements(); - for (int i = 0; i < colourArray.length; i++) { - _colourList.addElement(colourArray[i]); + _colourList.clear(); + + for (int i = 0; i < vColourArray.length; i++) { + this._colourList.add(vColourArray[i]); } - } //-- void setColour(jalview.schemabinding.version2.Colour) + } /** * Sets the value of field 'schemeName'. * * @param schemeName the value of field 'schemeName'. */ - public void setSchemeName(java.lang.String schemeName) - { + public void setSchemeName( + final java.lang.String schemeName) { this._schemeName = schemeName; - } //-- void setSchemeName(java.lang.String) + } /** - * Method unmarshal - * - * + * Method unmarshal. * * @param reader - * @return Object + * @throws org.exolab.castor.xml.MarshalException if object is + * null or if any SAXException is thrown during marshaling + * @throws org.exolab.castor.xml.ValidationException if this + * object is an invalid instance according to the schema + * @return the unmarshaled + * jalview.schemabinding.version2.JalviewUserColours */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { + public static jalview.schemabinding.version2.JalviewUserColours unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { return (jalview.schemabinding.version2.JalviewUserColours) Unmarshaller.unmarshal(jalview.schemabinding.version2.JalviewUserColours.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + } /** - * Method validate * + * + * @throws org.exolab.castor.xml.ValidationException if this + * object is an invalid instance according to the schema */ - 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() + } }