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

//---------------------------------/
//- 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 EntityConfig extends com.queplix.core.utils.jxb.JXBObject
        implements java.io.Serializable {

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

    /**
     * The entity description
     */
    private java.util.ArrayList _entityList;

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

    public EntityConfig() {
        super();
        _entityList = new ArrayList();
    } //-- com.queplix.core.jxb.entity.EntityConfig()

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

    /**
     * Method addEntity
     *
     * @param vEntity
     */
    public void addEntity(com.queplix.core.jxb.entity.Entity vEntity)
            throws java.lang.IndexOutOfBoundsException {
        _entityList.add(vEntity);
    } //-- void addEntity(com.queplix.core.jxb.entity.Entity) 

    /**
     * Method addEntity
     *
     * @param index
     * @param vEntity
     */
    public void addEntity(int index, com.queplix.core.jxb.entity.Entity vEntity)
            throws java.lang.IndexOutOfBoundsException {
        _entityList.add(index, vEntity);
    } //-- void addEntity(int, com.queplix.core.jxb.entity.Entity) 

    /**
     * Method clearEntity
     */
    public void clearEntity() {
        _entityList.clear();
    } //-- void clearEntity() 

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

    /**
     * Method getEntity
     *
     * @param index
     * @return Entity
     */
    public com.queplix.core.jxb.entity.Entity getEntity(int index)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _entityList.size())) {
            throw new IndexOutOfBoundsException();
        }

        return (com.queplix.core.jxb.entity.Entity) _entityList.get(index);
    } //-- com.queplix.core.jxb.entity.Entity getEntity(int) 

    /**
     * Method getEntity
     *
     * @return Entity
     */
    public com.queplix.core.jxb.entity.Entity[] getEntity() {
        int size = _entityList.size();
        com.queplix.core.jxb.entity.Entity[] mArray
                = new com.queplix.core.jxb.entity.Entity[size];
        for(int index = 0; index < size; index++) {
            mArray[index] = (com.queplix.core.jxb.entity.Entity) _entityList
                    .get(index);
        }
        return mArray;
    } //-- com.queplix.core.jxb.entity.Entity[] getEntity() 

    /**
     * Method getEntityCount
     *
     * @return int
     */
    public int getEntityCount() {
        return _entityList.size();
    } //-- int getEntityCount() 

    /**
     * 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 removeEntity
     *
     * @param vEntity
     * @return boolean
     */
    public boolean removeEntity(com.queplix.core.jxb.entity.Entity vEntity) {
        boolean removed = _entityList.remove(vEntity);
        return removed;
    } //-- boolean removeEntity(com.queplix.core.jxb.entity.Entity) 

    /**
     * Method setForm
     *
     * @param index
     * @param vEntity
     */
    public void setEntity(int index, com.queplix.core.jxb.entity.Entity vEntity)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _entityList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _entityList.set(index, vEntity);
    } //-- void setForm(int, com.queplix.core.jxb.entity.Entity)

    /**
     * Method setForm
     *
     * @param entityArray
     */
    public void setEntity(com.queplix.core.jxb.entity.Entity[] entityArray) {
        //-- copy array
        _entityList.clear();
        for(int i = 0; i < entityArray.length; i++) {
            _entityList.add(entityArray[i]);
        }
    } //-- void setForm(com.queplix.core.jxb.entity.Entity)

    /**
     * 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.jxb.entity.EntityConfig) Unmarshaller
                .unmarshal(com.queplix.core.jxb.entity.EntityConfig.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() 

}
