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

/**
 * The layout for the form controls
 * 
 * @version $Revision$ $Date$
 */
public class Layout extends com.queplix.core.utils.jxb.JXBObject 
implements java.io.Serializable
{


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

    /**
     * This section contains hidden controls
     */
    private com.queplix.core.modules.config.jxb.HiddenControls _hiddenControls;

    /**
     * Headers metainfo for layout
     */
    private com.queplix.core.modules.config.jxb.Headers _headers;

    /**
     * Describes row of the layout
     */
    private java.util.ArrayList _rowList;


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

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


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

    /**
     * Method addRow
     * 
     * 
     * 
     * @param vRow
     */
    public void addRow(com.queplix.core.modules.config.jxb.Row vRow)
        throws java.lang.IndexOutOfBoundsException
    {
        _rowList.add(vRow);
    } //-- void addRow(com.queplix.core.modules.config.jxb.Row) 

    /**
     * Method addRow
     * 
     * 
     * 
     * @param index
     * @param vRow
     */
    public void addRow(int index, com.queplix.core.modules.config.jxb.Row vRow)
        throws java.lang.IndexOutOfBoundsException
    {
        _rowList.add(index, vRow);
    } //-- void addRow(int, com.queplix.core.modules.config.jxb.Row) 

    /**
     * Method clearRow
     * 
     */
    public void clearRow()
    {
        _rowList.clear();
    } //-- void clearRow() 

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

    /**
     * Returns the value of field 'headers'. The field 'headers'
     * has the following description: Headers metainfo for layout
     * 
     * @return Headers
     * @return the value of field 'headers'.
     */
    public com.queplix.core.modules.config.jxb.Headers getHeaders()
    {
        return this._headers;
    } //-- com.queplix.core.modules.config.jxb.Headers getHeaders() 

    /**
     * Returns the value of field 'hiddenControls'. The field
     * 'hiddenControls' has the following description: This section
     * contains hidden controls
     * 
     * @return HiddenControls
     * @return the value of field 'hiddenControls'.
     */
    public com.queplix.core.modules.config.jxb.HiddenControls getHiddenControls()
    {
        return this._hiddenControls;
    } //-- com.queplix.core.modules.config.jxb.HiddenControls getHiddenControls() 

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

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

    /**
     * Method getRowCount
     * 
     * 
     * 
     * @return int
     */
    public int getRowCount()
    {
        return _rowList.size();
    } //-- int getRowCount() 

    /**
     * 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 removeRow
     * 
     * 
     * 
     * @param vRow
     * @return boolean
     */
    public boolean removeRow(com.queplix.core.modules.config.jxb.Row vRow)
    {
        boolean removed = _rowList.remove(vRow);
        return removed;
    } //-- boolean removeRow(com.queplix.core.modules.config.jxb.Row) 

    /**
     * Sets the value of field 'headers'. The field 'headers' has
     * the following description: Headers metainfo for layout
     * 
     * @param headers the value of field 'headers'.
     */
    public void setHeaders(com.queplix.core.modules.config.jxb.Headers headers)
    {
        this._headers = headers;
    } //-- void setHeaders(com.queplix.core.modules.config.jxb.Headers) 

    /**
     * Sets the value of field 'hiddenControls'. The field
     * 'hiddenControls' has the following description: This section
     * contains hidden controls
     * 
     * @param hiddenControls the value of field 'hiddenControls'.
     */
    public void setHiddenControls(com.queplix.core.modules.config.jxb.HiddenControls hiddenControls)
    {
        this._hiddenControls = hiddenControls;
    } //-- void setHiddenControls(com.queplix.core.modules.config.jxb.HiddenControls) 

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

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

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

}
