/* * This class was automatically generated with * Castor 1.1, using an XML * Schema. * $Id$ */ package jalview.schemabinding.version2; //---------------------------------/ //- Imported classes and packages -/ //---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** * Class DoubleVector. * * @version $Revision$ $Date$ */ public class DoubleVector implements java.io.Serializable { // --------------------------/ // - Class/Member Variables -/ // --------------------------/ /** * Field _vList. */ private java.util.Vector _vList; // ----------------/ // - Constructors -/ // ----------------/ public DoubleVector() { super(); this._vList = new java.util.Vector(); } // -----------/ // - Methods -/ // -----------/ /** * * * @param vV * @throws java.lang.IndexOutOfBoundsException * if the index given is outside the bounds of the collection */ public void addV(final double vV) throws java.lang.IndexOutOfBoundsException { this._vList.addElement(new java.lang.Double(vV)); } /** * * * @param index * @param vV * @throws java.lang.IndexOutOfBoundsException * if the index given is outside the bounds of the collection */ public void addV(final int index, final double vV) throws java.lang.IndexOutOfBoundsException { this._vList.add(index, new java.lang.Double(vV)); } /** * Method enumerateV. * * @return an Enumeration over all double elements */ public java.util.Enumeration enumerateV() { return this._vList.elements(); } /** * Method getV. * * @param index * @throws java.lang.IndexOutOfBoundsException * if the index given is outside the bounds of the collection * @return the value of the double at the given index */ public double getV(final int index) throws java.lang.IndexOutOfBoundsException { // check bounds for index if (index < 0 || index >= this._vList.size()) { throw new IndexOutOfBoundsException("getV: Index value '" + index + "' not in range [0.." + (this._vList.size() - 1) + "]"); } return ((java.lang.Double) _vList.get(index)).doubleValue(); } /** * Method getV.Returns the contents of the collection in an Array. * * @return this collection as an Array */ public double[] getV() { int size = this._vList.size(); double[] array = new double[size]; java.util.Iterator iter = _vList.iterator(); for (int index = 0; index < size; index++) { array[index] = ((java.lang.Double) iter.next()).doubleValue(); } return array; } /** * Method getVCount. * * @return the size of this collection */ public int getVCount() { return this._vList.size(); } /** * 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) { return false; } return true; } /** * * * @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(final java.io.Writer out) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, out); } /** * * * @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(final org.xml.sax.ContentHandler handler) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { Marshaller.marshal(this, handler); } /** */ public void removeAllV() { this._vList.clear(); } /** * Method removeV. * * @param vV * @return true if the object was removed from the collection. */ public boolean removeV(final double vV) { boolean removed = _vList.remove(new java.lang.Double(vV)); return removed; } /** * Method removeVAt. * * @param index * @return the element removed from the collection */ public double removeVAt(final int index) { java.lang.Object obj = this._vList.remove(index); return ((java.lang.Double) obj).doubleValue(); } /** * * * @param index * @param vV * @throws java.lang.IndexOutOfBoundsException * if the index given is outside the bounds of the collection */ public void setV(final int index, final double vV) throws java.lang.IndexOutOfBoundsException { // check bounds for index if (index < 0 || index >= this._vList.size()) { throw new IndexOutOfBoundsException("setV: Index value '" + index + "' not in range [0.." + (this._vList.size() - 1) + "]"); } this._vList.set(index, new java.lang.Double(vV)); } /** * * * @param vVArray */ public void setV(final double[] vVArray) { // -- copy array _vList.clear(); for (int i = 0; i < vVArray.length; i++) { this._vList.add(new java.lang.Double(vVArray[i])); } } /** * Method unmarshal. * * @param reader * @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.DoubleVector */ public static jalview.schemabinding.version2.DoubleVector unmarshal( final java.io.Reader reader) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { return (jalview.schemabinding.version2.DoubleVector) Unmarshaller .unmarshal(jalview.schemabinding.version2.DoubleVector.class, reader); } /** * * * @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 { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); } }