/* * 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 _dList. */ private java.util.Vector _dList; // ----------------/ // - Constructors -/ // ----------------/ public DoubleVector() { super(); this._dList = new java.util.Vector(); } // -----------/ // - Methods -/ // -----------/ /** * * * @param vD * @throws java.lang.IndexOutOfBoundsException * if the index given is outside the bounds of the collection */ public void addD(final double vD) throws java.lang.IndexOutOfBoundsException { this._dList.addElement(new java.lang.Double(vD)); } /** * * * @param index * @param vD * @throws java.lang.IndexOutOfBoundsException * if the index given is outside the bounds of the collection */ public void addD(final int index, final double vD) throws java.lang.IndexOutOfBoundsException { this._dList.add(index, new java.lang.Double(vD)); } /** * Method enumerateD. * * @return an Enumeration over all double elements */ public java.util.Enumeration enumerateD() { return this._dList.elements(); } /** * Method getD. * * @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 getD(final int index) throws java.lang.IndexOutOfBoundsException { // check bounds for index if (index < 0 || index >= this._dList.size()) { throw new IndexOutOfBoundsException("getD: Index value '" + index + "' not in range [0.." + (this._dList.size() - 1) + "]"); } return ((java.lang.Double) _dList.get(index)).doubleValue(); } /** * Method getD.Returns the contents of the collection in an Array. * * @return this collection as an Array */ public double[] getD() { int size = this._dList.size(); double[] array = new double[size]; java.util.Iterator iter = _dList.iterator(); for (int index = 0; index < size; index++) { array[index] = ((java.lang.Double) iter.next()).doubleValue(); } return array; } /** * Method getDCount. * * @return the size of this collection */ public int getDCount() { return this._dList.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 removeAllD() { this._dList.clear(); } /** * Method removeD. * * @param vD * @return true if the object was removed from the collection. */ public boolean removeD(final double vD) { boolean removed = _dList.remove(new java.lang.Double(vD)); return removed; } /** * Method removeDAt. * * @param index * @return the element removed from the collection */ public double removeDAt(final int index) { java.lang.Object obj = this._dList.remove(index); return ((java.lang.Double) obj).doubleValue(); } /** * * * @param index * @param vD * @throws java.lang.IndexOutOfBoundsException * if the index given is outside the bounds of the collection */ public void setD(final int index, final double vD) throws java.lang.IndexOutOfBoundsException { // check bounds for index if (index < 0 || index >= this._dList.size()) { throw new IndexOutOfBoundsException("setD: Index value '" + index + "' not in range [0.." + (this._dList.size() - 1) + "]"); } this._dList.set(index, new java.lang.Double(vD)); } /** * * * @param vDArray */ public void setD(final double[] vDArray) { // -- copy array _dList.clear(); for (int i = 0; i < vDArray.length; i++) { this._dList.add(new java.lang.Double(vDArray[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); } }