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

package com.queplix.core.modules.config.jxb.portal;

  //---------------------------------/
 //- Imported classes and packages -/
//---------------------------------/

import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Enumeration;
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 MainToolbarType.
 * 
 * @version $Revision$ $Date$
 */
public class MainToolbarType extends com.queplix.core.utils.jxb.JXBObject 
implements java.io.Serializable
{


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

    /**
     * Field _controlList
     */
    private java.util.ArrayList _controlList;


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

    public MainToolbarType() 
     {
        super();
        _controlList = new ArrayList();
    } //-- com.queplix.core.modules.config.jxb.portal.MainToolbarType()


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

    /**
     * Method addControl
     * 
     * 
     * 
     * @param vControl
     */
    public void addControl(com.queplix.core.modules.config.jxb.portal.Control vControl)
        throws java.lang.IndexOutOfBoundsException
    {
        _controlList.add(vControl);
    } //-- void addControl(com.queplix.core.modules.config.jxb.portal.Control) 

    /**
     * Method addControl
     * 
     * 
     * 
     * @param index
     * @param vControl
     */
    public void addControl(int index, com.queplix.core.modules.config.jxb.portal.Control vControl)
        throws java.lang.IndexOutOfBoundsException
    {
        _controlList.add(index, vControl);
    } //-- void addControl(int, com.queplix.core.modules.config.jxb.portal.Control) 

    /**
     * Method clearControl
     * 
     */
    public void clearControl()
    {
        _controlList.clear();
    } //-- void clearControl() 

    /**
     * Method enumerateControl
     * 
     * 
     * 
     * @return Enumeration
     */
    public java.util.Enumeration enumerateControl()
    {
        return new org.exolab.castor.util.IteratorEnumeration(_controlList.iterator());
    } //-- java.util.Enumeration enumerateControl() 

    /**
     * Method getControl
     * 
     * 
     * 
     * @param index
     * @return Control
     */
    public com.queplix.core.modules.config.jxb.portal.Control getControl(int index)
        throws java.lang.IndexOutOfBoundsException
    {
        //-- check bounds for index
        if ((index < 0) || (index > _controlList.size())) {
            throw new IndexOutOfBoundsException();
        }
        
        return (com.queplix.core.modules.config.jxb.portal.Control) _controlList.get(index);
    } //-- com.queplix.core.modules.config.jxb.portal.Control getControl(int) 

    /**
     * Method getControl
     * 
     * 
     * 
     * @return Control
     */
    public com.queplix.core.modules.config.jxb.portal.Control[] getControl()
    {
        int size = _controlList.size();
        com.queplix.core.modules.config.jxb.portal.Control[] mArray = new com.queplix.core.modules.config.jxb.portal.Control[size];
        for (int index = 0; index < size; index++) {
            mArray[index] = (com.queplix.core.modules.config.jxb.portal.Control) _controlList.get(index);
        }
        return mArray;
    } //-- com.queplix.core.modules.config.jxb.portal.Control[] getControl() 

    /**
     * Method getControlCount
     * 
     * 
     * 
     * @return int
     */
    public int getControlCount()
    {
        return _controlList.size();
    } //-- int getControlCount() 

    /**
     * Method isValid
     * 
     * 
     * 
     * @return boolean
     */
    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 removeControl
     * 
     * 
     * 
     * @param vControl
     * @return boolean
     */
    public boolean removeControl(com.queplix.core.modules.config.jxb.portal.Control vControl)
    {
        boolean removed = _controlList.remove(vControl);
        return removed;
    } //-- boolean removeControl(com.queplix.core.modules.config.jxb.portal.Control) 

    /**
     * Method setControl
     * 
     * 
     * 
     * @param index
     * @param vControl
     */
    public void setControl(int index, com.queplix.core.modules.config.jxb.portal.Control vControl)
        throws java.lang.IndexOutOfBoundsException
    {
        //-- check bounds for index
        if ((index < 0) || (index > _controlList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _controlList.set(index, vControl);
    } //-- void setControl(int, com.queplix.core.modules.config.jxb.portal.Control) 

    /**
     * Method setControl
     * 
     * 
     * 
     * @param controlArray
     */
    public void setControl(com.queplix.core.modules.config.jxb.portal.Control[] controlArray)
    {
        //-- copy array
        _controlList.clear();
        for (int i = 0; i < controlArray.length; i++) {
            _controlList.add(controlArray[i]);
        }
    } //-- void setControl(com.queplix.core.modules.config.jxb.portal.Control) 

    /**
     * Method unmarshal
     * 
     * 
     * 
     * @param reader
     * @return Object
     */
    public static java.lang.Object unmarshal(java.io.Reader reader)
        throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
    {
        return (com.queplix.core.modules.config.jxb.portal.MainToolbarType) Unmarshaller.unmarshal(com.queplix.core.modules.config.jxb.portal.MainToolbarType.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() 

}
