/*
 * This class was automatically generated with 
 * <a href="http://www.castor.org">Castor 0.9.5.3</a>, using an XML
 * Schema.
 * $Id$
 */

  //---------------------------------/
 //- 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 Ring.
 * 
 * @version $Revision$ $Date$
 */
public class Ring implements java.io.Serializable {


      //--------------------------/
     //- Class/Member Variables -/
    //--------------------------/

    /**
     * Field _moduleList
     */
    private java.util.Vector _moduleList;


      //----------------/
     //- Constructors -/
    //----------------/

    public Ring() {
        super();
        _moduleList = new Vector();
    } //-- Ring()


      //-----------/
     //- Methods -/
    //-----------/

    /**
     * Method addModule
     * 
     * @param vModule
     */
    public void addModule(Module vModule)
        throws java.lang.IndexOutOfBoundsException
    {
        _moduleList.addElement(vModule);
    } //-- void addModule(Module) 

    /**
     * Method addModule
     * 
     * @param index
     * @param vModule
     */
    public void addModule(int index, Module vModule)
        throws java.lang.IndexOutOfBoundsException
    {
        _moduleList.insertElementAt(vModule, index);
    } //-- void addModule(int, Module) 

    /**
     * Method enumerateModule
     */
    public java.util.Enumeration enumerateModule()
    {
        return _moduleList.elements();
    } //-- java.util.Enumeration enumerateModule() 

    /**
     * Method getModule
     * 
     * @param index
     */
    public Module getModule(int index)
        throws java.lang.IndexOutOfBoundsException
    {
        //-- check bounds for index
        if ((index < 0) || (index > _moduleList.size())) {
            throw new IndexOutOfBoundsException();
        }
        
        return (Module) _moduleList.elementAt(index);
    } //-- Module getModule(int) 

    /**
     * Method getModule
     */
    public Module[] getModule()
    {
        int size = _moduleList.size();
        Module[] mArray = new Module[size];
        for (int index = 0; index < size; index++) {
            mArray[index] = (Module) _moduleList.elementAt(index);
        }
        return mArray;
    } //-- Module[] getModule() 

    /**
     * Method getModuleCount
     */
    public int getModuleCount()
    {
        return _moduleList.size();
    } //-- int getModuleCount() 

    /**
     * Method isValid
     */
    public boolean isValid()
    {
        try {
            validate();
        }
        catch (org.exolab.castor.xml.ValidationException vex) {
            return false;
        }
        return true;
    } //-- boolean isValid() 

    /**
     * Method marshal
     * 
     * @param out
     */
    public void marshal(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
     */
    public void marshal(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 removeAllModule
     */
    public void removeAllModule()
    {
        _moduleList.removeAllElements();
    } //-- void removeAllModule() 

    /**
     * Method removeModule
     * 
     * @param index
     */
    public Module removeModule(int index)
    {
        java.lang.Object obj = _moduleList.elementAt(index);
        _moduleList.removeElementAt(index);
        return (Module) obj;
    } //-- Module removeModule(int) 

    /**
     * Method setModule
     * 
     * @param index
     * @param vModule
     */
    public void setModule(int index, Module vModule)
        throws java.lang.IndexOutOfBoundsException
    {
        //-- check bounds for index
        if ((index < 0) || (index > _moduleList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _moduleList.setElementAt(vModule, index);
    } //-- void setModule(int, Module) 

    /**
     * Method setModule
     * 
     * @param moduleArray
     */
    public void setModule(Module[] moduleArray)
    {
        //-- copy array
        _moduleList.removeAllElements();
        for (int i = 0; i < moduleArray.length; i++) {
            _moduleList.addElement(moduleArray[i]);
        }
    } //-- void setModule(Module) 

    /**
     * Method unmarshal
     * 
     * @param reader
     */
    public static java.lang.Object unmarshal(java.io.Reader reader)
        throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
    {
        return (Ring) Unmarshaller.unmarshal(Ring.class, reader);
    } //-- java.lang.Object unmarshal(java.io.Reader) 

    /**
     * Method validate
     */
    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() 

}
