/*
 * 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;

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

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

import java.util.ArrayList;

/**
 * The entity customization description
 *
 * @version $Revision$ $Date$
 */
public class Custom extends com.queplix.core.utils.jxb.JXBObject
        implements java.io.Serializable {

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

    /**
     * The name of entity
     */
    private java.lang.String _entity;

    /**
     * The entity field customization description
     */
    private java.util.ArrayList _customFieldList;

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

    public Custom() {
        super();
        _customFieldList = new ArrayList();
    } //-- com.queplix.core.modules.config.jxb.Custom()

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

    /**
     * Method addCustomField
     *
     * @param vCustomField
     */
    public void addCustomField(
            com.queplix.core.modules.config.jxb.CustomField vCustomField)
            throws java.lang.IndexOutOfBoundsException {
        _customFieldList.add(vCustomField);
    } //-- void addCustomField(com.queplix.core.modules.config.jxb.CustomField) 

    /**
     * Method addCustomField
     *
     * @param index
     * @param vCustomField
     */
    public void addCustomField(int index,
                               com.queplix.core.modules.config.jxb.CustomField vCustomField)
            throws java.lang.IndexOutOfBoundsException {
        _customFieldList.add(index, vCustomField);
    } //-- void addCustomField(int, com.queplix.core.modules.config.jxb.CustomField) 

    /**
     * Method clearCustomField
     */
    public void clearCustomField() {
        _customFieldList.clear();
    } //-- void clearCustomField() 

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

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

        return (com.queplix.core.modules.config.jxb.CustomField) _customFieldList
                .get(index);
    } //-- com.queplix.core.modules.config.jxb.CustomField getCustomField(int) 

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

    /**
     * Method getCustomFieldCount
     *
     * @return int
     */
    public int getCustomFieldCount() {
        return _customFieldList.size();
    } //-- int getCustomFieldCount() 

    /**
     * Returns the value of field 'entity'. The field 'entity' has
     * the following description: The name of entity
     *
     * @return the value of field 'entity'.
     */
    public java.lang.String getEntity() {
        return this._entity;
    } //-- java.lang.String getEntity() 

    /**
     * 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 removeCustomField
     *
     * @param vCustomField
     * @return boolean
     */
    public boolean removeCustomField(
            com.queplix.core.modules.config.jxb.CustomField vCustomField) {
        boolean removed = _customFieldList.remove(vCustomField);
        return removed;
    } //-- boolean removeCustomField(com.queplix.core.modules.config.jxb.CustomField) 

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

    /**
     * Method setCustomField
     *
     * @param customFieldArray
     */
    public void setCustomField(
            com.queplix.core.modules.config.jxb.CustomField[] customFieldArray) {
        //-- copy array
        _customFieldList.clear();
        for(int i = 0; i < customFieldArray.length; i++) {
            _customFieldList.add(customFieldArray[i]);
        }
    } //-- void setCustomField(com.queplix.core.modules.config.jxb.CustomField) 

    /**
     * Sets the value of field 'entity'. The field 'entity' has the
     * following description: The name of entity
     *
     * @param entity the value of field 'entity'.
     */
    public void setEntity(java.lang.String entity) {
        this._entity = entity;
    } //-- void setForm(java.lang.String)

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

}
