X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fschemabinding%2Fversion2%2FJalviewUserColours.java;h=f1217e78b4f29f59f53e23c2af5b44e9908aaac4;hb=46ca91c8b2a49f1d2f80b6823ade9f1c29c4121c;hp=5b4fb76d74c6069e982862b64f1149d74539dae7;hpb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;p=jalview.git
diff --git a/src/jalview/schemabinding/version2/JalviewUserColours.java b/src/jalview/schemabinding/version2/JalviewUserColours.java
index 5b4fb76..f1217e7 100755
--- a/src/jalview/schemabinding/version2/JalviewUserColours.java
+++ b/src/jalview/schemabinding/version2/JalviewUserColours.java
@@ -1,308 +1,356 @@
/*
- * This class was automatically generated with
- * Castor 0.9.6, using an XML
- * Schema.
- * $Id$
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see
+ * 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 this collection as an Array */ - public jalview.schemabinding.version2.Colour[] getColour() + public 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() + Colour[] array = new Colour[0]; + return (Colour[]) this._colourList.toArray(array); + } /** - * Method getColourCount - * - * - * - * @return int + * Method getColourCount. + * + * @return the size of this collection */ public int getColourCount() { - return _colourList.size(); - } //-- 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() { return this._schemeName; - } //-- java.lang.String getSchemeName() + } /** - * Method isValid - * - * - * - * @return boolean + * Returns the value of field 'version'. The field 'version' has the following + * description: Jalview colour scheme document version. + * + * + * @return the value of field 'Version'. + */ + public java.lang.String getVersion() + { + return this._version; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema */ 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() + this._colourList.clear(); + } + + /** + * 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 removeColour - * - * - * + * Method removeColourAt. + * * @param index - * @return Colour + * @return the element removed from the collection */ - public jalview.schemabinding.version2.Colour removeColour(int index) + public Colour removeColourAt(final int index) { - java.lang.Object obj = _colourList.elementAt(index); - _colourList.removeElementAt(index); - return (jalview.schemabinding.version2.Colour) obj; - } //-- jalview.schemabinding.version2.Colour removeColour(int) + 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 + public void setColour(final int index, final Colour vColour) + throws java.lang.IndexOutOfBoundsException { - //-- check bounds for index - if ( (index < 0) || (index > _colourList.size())) + // check bounds for index + if (index < 0 || index >= this._colourList.size()) { - throw new IndexOutOfBoundsException(); + 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++) + // -- copy array + _colourList.clear(); + + for (int i = 0; i < vColourArray.length; i++) { - _colourList.addElement(colourArray[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'. + * + * @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) + } + + /** + * Sets the value of field 'version'. The field 'version' has the following + * description: Jalview colour scheme document version. + * + * + * @param version + * the value of field 'version'. + */ + public void setVersion(final java.lang.String version) + { + this._version = version; + } /** - * 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) + return (jalview.schemabinding.version2.JalviewUserColours) Unmarshaller + .unmarshal( + jalview.schemabinding.version2.JalviewUserColours.class, + 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(); + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } }