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

/**
 * Headers metainfo for layout
 * 
 * @version $Revision$ $Date$
 */
public class Headers extends com.queplix.core.utils.jxb.JXBObject 
implements java.io.Serializable
{


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

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


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

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


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

    /**
     * Method addHeader
     * 
     * 
     * 
     * @param vHeader
     */
    public void addHeader(com.queplix.core.modules.config.jxb.Header vHeader)
        throws java.lang.IndexOutOfBoundsException
    {
        _headerList.add(vHeader);
    } //-- void addHeader(com.queplix.core.modules.config.jxb.Header) 

    /**
     * Method addHeader
     * 
     * 
     * 
     * @param index
     * @param vHeader
     */
    public void addHeader(int index, com.queplix.core.modules.config.jxb.Header vHeader)
        throws java.lang.IndexOutOfBoundsException
    {
        _headerList.add(index, vHeader);
    } //-- void addHeader(int, com.queplix.core.modules.config.jxb.Header) 

    /**
     * Method clearHeader
     * 
     */
    public void clearHeader()
    {
        _headerList.clear();
    } //-- void clearHeader() 

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

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

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

    /**
     * Method getHeaderCount
     * 
     * 
     * 
     * @return int
     */
    public int getHeaderCount()
    {
        return _headerList.size();
    } //-- int getHeaderCount() 

    /**
     * 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 removeHeader
     * 
     * 
     * 
     * @param vHeader
     * @return boolean
     */
    public boolean removeHeader(com.queplix.core.modules.config.jxb.Header vHeader)
    {
        boolean removed = _headerList.remove(vHeader);
        return removed;
    } //-- boolean removeHeader(com.queplix.core.modules.config.jxb.Header) 

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

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

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

}
