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


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

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


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

    public Subdetector() {
        super();
        _detectorPartList = new Vector();
    } //-- Subdetector()


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

    /**
     * Method addDetectorPart
     * 
     * @param vDetectorPart
     */
    public void addDetectorPart(DetectorPart vDetectorPart)
        throws java.lang.IndexOutOfBoundsException
    {
        _detectorPartList.addElement(vDetectorPart);
    } //-- void addDetectorPart(DetectorPart) 

    /**
     * Method addDetectorPart
     * 
     * @param index
     * @param vDetectorPart
     */
    public void addDetectorPart(int index, DetectorPart vDetectorPart)
        throws java.lang.IndexOutOfBoundsException
    {
        _detectorPartList.insertElementAt(vDetectorPart, index);
    } //-- void addDetectorPart(int, DetectorPart) 

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

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

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

    /**
     * Method getDetectorPartCount
     */
    public int getDetectorPartCount()
    {
        return _detectorPartList.size();
    } //-- int getDetectorPartCount() 

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

    /**
     * Method removeDetectorPart
     * 
     * @param index
     */
    public DetectorPart removeDetectorPart(int index)
    {
        java.lang.Object obj = _detectorPartList.elementAt(index);
        _detectorPartList.removeElementAt(index);
        return (DetectorPart) obj;
    } //-- DetectorPart removeDetectorPart(int) 

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

    /**
     * Method setDetectorPart
     * 
     * @param detectorPartArray
     */
    public void setDetectorPart(DetectorPart[] detectorPartArray)
    {
        //-- copy array
        _detectorPartList.removeAllElements();
        for (int i = 0; i < detectorPartArray.length; i++) {
            _detectorPartList.addElement(detectorPartArray[i]);
        }
    } //-- void setDetectorPart(DetectorPart) 

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

}
