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


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

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


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

    public Detector() {
        super();
        _subdetectorList = new Vector();
    } //-- Detector()


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

    /**
     * Method addSubdetector
     * 
     * @param vSubdetector
     */
    public void addSubdetector(Subdetector vSubdetector)
        throws java.lang.IndexOutOfBoundsException
    {
        _subdetectorList.addElement(vSubdetector);
    } //-- void addSubdetector(Subdetector) 

    /**
     * Method addSubdetector
     * 
     * @param index
     * @param vSubdetector
     */
    public void addSubdetector(int index, Subdetector vSubdetector)
        throws java.lang.IndexOutOfBoundsException
    {
        _subdetectorList.insertElementAt(vSubdetector, index);
    } //-- void addSubdetector(int, Subdetector) 

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

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

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

    /**
     * Method getSubdetectorCount
     */
    public int getSubdetectorCount()
    {
        return _subdetectorList.size();
    } //-- int getSubdetectorCount() 

    /**
     * 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 removeAllSubdetector
     */
    public void removeAllSubdetector()
    {
        _subdetectorList.removeAllElements();
    } //-- void removeAllSubdetector() 

    /**
     * Method removeSubdetector
     * 
     * @param index
     */
    public Subdetector removeSubdetector(int index)
    {
        java.lang.Object obj = _subdetectorList.elementAt(index);
        _subdetectorList.removeElementAt(index);
        return (Subdetector) obj;
    } //-- Subdetector removeSubdetector(int) 

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

    /**
     * Method setSubdetector
     * 
     * @param subdetectorArray
     */
    public void setSubdetector(Subdetector[] subdetectorArray)
    {
        //-- copy array
        _subdetectorList.removeAllElements();
        for (int i = 0; i < subdetectorArray.length; i++) {
            _subdetectorList.addElement(subdetectorArray[i]);
        }
    } //-- void setSubdetector(Subdetector) 

    /**
     * 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 (Detector) Unmarshaller.unmarshal(Detector.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() 

}
