/*
 * 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.services.jxb;

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

import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;

import java.util.ArrayList;

/**
 * The root element
 *
 * @version $Revision$ $Date$
 */
public class Scripts extends com.queplix.core.utils.jxb.JXBObject
        implements java.io.Serializable {

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

    /**
     * The custom script description
     */
    private java.util.ArrayList _scriptList;

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

    public Scripts() {
        super();
        _scriptList = new ArrayList();
    } //-- com.queplix.core.modules.services.jxb.Scripts()

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

    /**
     * Method addScript
     *
     * @param vScript
     */
    public void addScript(com.queplix.core.modules.services.jxb.Script vScript)
            throws java.lang.IndexOutOfBoundsException {
        _scriptList.add(vScript);
    } //-- void addScript(com.queplix.core.modules.services.jxb.Script) 

    /**
     * Method addScript
     *
     * @param index
     * @param vScript
     */
    public void addScript(int index,
                          com.queplix.core.modules.services.jxb.Script vScript)
            throws java.lang.IndexOutOfBoundsException {
        _scriptList.add(index, vScript);
    } //-- void addScript(int, com.queplix.core.modules.services.jxb.Script) 

    /**
     * Method clearScript
     */
    public void clearScript() {
        _scriptList.clear();
    } //-- void clearScript() 

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

    /**
     * Method getScript
     *
     * @param index
     * @return Script
     */
    public com.queplix.core.modules.services.jxb.Script getScript(int index)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _scriptList.size())) {
            throw new IndexOutOfBoundsException();
        }

        return (com.queplix.core.modules.services.jxb.Script) _scriptList.get(
                index);
    } //-- com.queplix.core.modules.services.jxb.Script getScript(int) 

    /**
     * Method getScript
     *
     * @return Script
     */
    public com.queplix.core.modules.services.jxb.Script[] getScript() {
        int size = _scriptList.size();
        com.queplix.core.modules.services.jxb.Script[] mArray
                = new com.queplix.core.modules.services.jxb.Script[size];
        for(int index = 0; index < size; index++) {
            mArray[index]
                    = (com.queplix.core.modules.services.jxb.Script) _scriptList
                    .get(index);
        }
        return mArray;
    } //-- com.queplix.core.modules.services.jxb.Script[] getScript() 

    /**
     * Method getScriptCount
     *
     * @return int
     */
    public int getScriptCount() {
        return _scriptList.size();
    } //-- int getScriptCount() 

    /**
     * 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 removeScript
     *
     * @param vScript
     * @return boolean
     */
    public boolean removeScript(
            com.queplix.core.modules.services.jxb.Script vScript) {
        boolean removed = _scriptList.remove(vScript);
        return removed;
    } //-- boolean removeScript(com.queplix.core.modules.services.jxb.Script) 

    /**
     * Method setScript
     *
     * @param index
     * @param vScript
     */
    public void setScript(int index,
                          com.queplix.core.modules.services.jxb.Script vScript)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _scriptList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _scriptList.set(index, vScript);
    } //-- void setScript(int, com.queplix.core.modules.services.jxb.Script) 

    /**
     * Method setScript
     *
     * @param scriptArray
     */
    public void setScript(
            com.queplix.core.modules.services.jxb.Script[] scriptArray) {
        //-- copy array
        _scriptList.clear();
        for(int i = 0; i < scriptArray.length; i++) {
            _scriptList.add(scriptArray[i]);
        }
    } //-- void setScript(com.queplix.core.modules.services.jxb.Script) 

    /**
     * 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.services.jxb.Scripts) Unmarshaller
                .unmarshal(com.queplix.core.modules.services.jxb.Scripts.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() 

}
