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

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

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

import java.util.ArrayList;

/**
 * Set of com.queplix.core.modules.inbox.utils.MailFilter
 * implementations
 *
 * @version $Revision$ $Date$
 */
public class Filters extends com.queplix.core.utils.jxb.JXBObject
        implements java.io.Serializable {

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

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

    /**
     * Default error handler filter.
     */
    private com.queplix.core.modules.inbox.jxb.ErrorFilter _errorFilter;

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

    public Filters() {
        super();
        _filterList = new ArrayList();
    } //-- com.queplix.core.modules.inbox.jxb.Filters()

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

    /**
     * Method addFilter
     *
     * @param vFilter
     */
    public void addFilter(com.queplix.core.modules.inbox.jxb.Filter vFilter)
            throws java.lang.IndexOutOfBoundsException {
        _filterList.add(vFilter);
    } //-- void addFilter(com.queplix.core.modules.inbox.jxb.Filter) 

    /**
     * Method addFilter
     *
     * @param index
     * @param vFilter
     */
    public void addFilter(int index,
                          com.queplix.core.modules.inbox.jxb.Filter vFilter)
            throws java.lang.IndexOutOfBoundsException {
        _filterList.add(index, vFilter);
    } //-- void addFilter(int, com.queplix.core.modules.inbox.jxb.Filter) 

    /**
     * Method clearFilter
     */
    public void clearFilter() {
        _filterList.clear();
    } //-- void clearFilter() 

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

    /**
     * Returns the value of field 'errorFilter'. The field
     * 'errorFilter' has the following description: Default error
     * handler filter.
     *
     * @return the value of field 'errorFilter'.
     */
    public com.queplix.core.modules.inbox.jxb.ErrorFilter getErrorFilter() {
        return this._errorFilter;
    } //-- com.queplix.core.modules.inbox.jxb.ErrorFilter getErrorFilter() 

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

        return (com.queplix.core.modules.inbox.jxb.Filter) _filterList.get(
                index);
    } //-- com.queplix.core.modules.inbox.jxb.Filter getFilter(int) 

    /**
     * Method getFilter
     *
     * @return Filter
     */
    public com.queplix.core.modules.inbox.jxb.Filter[] getFilter() {
        int size = _filterList.size();
        com.queplix.core.modules.inbox.jxb.Filter[] mArray
                = new com.queplix.core.modules.inbox.jxb.Filter[size];
        for(int index = 0; index < size; index++) {
            mArray[index]
                    = (com.queplix.core.modules.inbox.jxb.Filter) _filterList
                    .get(index);
        }
        return mArray;
    } //-- com.queplix.core.modules.inbox.jxb.Filter[] getFilter() 

    /**
     * Method getFilterCount
     *
     * @return int
     */
    public int getFilterCount() {
        return _filterList.size();
    } //-- int getFilterCount() 

    /**
     * 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 removeFilter
     *
     * @param vFilter
     * @return boolean
     */
    public boolean removeFilter(
            com.queplix.core.modules.inbox.jxb.Filter vFilter) {
        boolean removed = _filterList.remove(vFilter);
        return removed;
    } //-- boolean removeFilter(com.queplix.core.modules.inbox.jxb.Filter) 

    /**
     * Sets the value of field 'errorFilter'. The field
     * 'errorFilter' has the following description: Default error
     * handler filter.
     *
     * @param errorFilter the value of field 'errorFilter'.
     */
    public void setErrorFilter(
            com.queplix.core.modules.inbox.jxb.ErrorFilter errorFilter) {
        this._errorFilter = errorFilter;
    } //-- void setErrorFilter(com.queplix.core.modules.inbox.jxb.ErrorFilter) 

    /**
     * Method setFilter
     *
     * @param index
     * @param vFilter
     */
    public void setFilter(int index,
                          com.queplix.core.modules.inbox.jxb.Filter vFilter)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _filterList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _filterList.set(index, vFilter);
    } //-- void setFilter(int, com.queplix.core.modules.inbox.jxb.Filter) 

    /**
     * Method setFilter
     *
     * @param filterArray
     */
    public void setFilter(
            com.queplix.core.modules.inbox.jxb.Filter[] filterArray) {
        //-- copy array
        _filterList.clear();
        for(int i = 0; i < filterArray.length; i++) {
            _filterList.add(filterArray[i]);
        }
    } //-- void setFilter(com.queplix.core.modules.inbox.jxb.Filter) 

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

}
