/*
 * 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 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 ExtLayout.
 * 
 * @version $Revision$ $Date$
 */
public class ExtLayout extends com.queplix.core.utils.jxb.JXBObject 
implements java.io.Serializable
{


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

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


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

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


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

    /**
     * Method addField
     * 
     * 
     * 
     * @param vField
     */
    public void addField(com.queplix.core.modules.config.jxb.Field vField)
        throws java.lang.IndexOutOfBoundsException
    {
        _fieldList.add(vField);
    } //-- void addField(com.queplix.core.modules.config.jxb.Field) 

    /**
     * Method addField
     * 
     * 
     * 
     * @param index
     * @param vField
     */
    public void addField(int index, com.queplix.core.modules.config.jxb.Field vField)
        throws java.lang.IndexOutOfBoundsException
    {
        _fieldList.add(index, vField);
    } //-- void addField(int, com.queplix.core.modules.config.jxb.Field) 

    /**
     * Method clearField
     * 
     */
    public void clearField()
    {
        _fieldList.clear();
    } //-- void clearField() 

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

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

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

    /**
     * Method getFieldCount
     * 
     * 
     * 
     * @return int
     */
    public int getFieldCount()
    {
        return _fieldList.size();
    } //-- int getFieldCount() 

    /**
     * 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 removeField
     * 
     * 
     * 
     * @param vField
     * @return boolean
     */
    public boolean removeField(com.queplix.core.modules.config.jxb.Field vField)
    {
        boolean removed = _fieldList.remove(vField);
        return removed;
    } //-- boolean removeField(com.queplix.core.modules.config.jxb.Field) 

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

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

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

}
