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

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

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

import java.util.ArrayList;

/**
 * Class Res.
 *
 * @version $Revision$ $Date$
 */
public class Res extends com.queplix.core.utils.jxb.JXBObject
        implements java.io.Serializable {

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

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

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

    public Res() {
        super();
        _resRecordList = new ArrayList();
    } //-- com.queplix.core.modules.eqlext.jxb.gr.Res()

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

    /**
     * Method addResRecord
     *
     * @param vResRecord
     */
    public void addResRecord(
            com.queplix.core.modules.eqlext.jxb.gr.ResRecord vResRecord)
            throws java.lang.IndexOutOfBoundsException {
        _resRecordList.add(vResRecord);
    } //-- void addResRecord(com.queplix.core.modules.eqlext.jxb.gr.ResRecord) 

    /**
     * Method addResRecord
     *
     * @param index
     * @param vResRecord
     */
    public void addResRecord(int index,
                             com.queplix.core.modules.eqlext.jxb.gr.ResRecord vResRecord)
            throws java.lang.IndexOutOfBoundsException {
        _resRecordList.add(index, vResRecord);
    } //-- void addResRecord(int, com.queplix.core.modules.eqlext.jxb.gr.ResRecord) 

    /**
     * Method clearResRecord
     */
    public void clearResRecord() {
        _resRecordList.clear();
    } //-- void clearResRecord() 

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

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

        return (com.queplix.core.modules.eqlext.jxb.gr.ResRecord) _resRecordList
                .get(index);
    } //-- com.queplix.core.modules.eqlext.jxb.gr.ResRecord getResRecord(int) 

    /**
     * Method getResRecord
     *
     * @return ResRecord
     */
    public com.queplix.core.modules.eqlext.jxb.gr.ResRecord[] getResRecord() {
        int size = _resRecordList.size();
        com.queplix.core.modules.eqlext.jxb.gr.ResRecord[] mArray
                = new com.queplix.core.modules.eqlext.jxb.gr.ResRecord[size];
        for(int index = 0; index < size; index++) {
            mArray[index]
                    = (com.queplix.core.modules.eqlext.jxb.gr.ResRecord) _resRecordList
                    .get(index);
        }
        return mArray;
    } //-- com.queplix.core.modules.eqlext.jxb.gr.ResRecord[] getResRecord() 

    /**
     * Method getResRecordCount
     *
     * @return int
     */
    public int getResRecordCount() {
        return _resRecordList.size();
    } //-- int getResRecordCount() 

    /**
     * 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 removeResRecord
     *
     * @param vResRecord
     * @return boolean
     */
    public boolean removeResRecord(
            com.queplix.core.modules.eqlext.jxb.gr.ResRecord vResRecord) {
        boolean removed = _resRecordList.remove(vResRecord);
        return removed;
    } //-- boolean removeResRecord(com.queplix.core.modules.eqlext.jxb.gr.ResRecord) 

    /**
     * Method setResRecord
     *
     * @param index
     * @param vResRecord
     */
    public void setResRecord(int index,
                             com.queplix.core.modules.eqlext.jxb.gr.ResRecord vResRecord)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _resRecordList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _resRecordList.set(index, vResRecord);
    } //-- void setResRecord(int, com.queplix.core.modules.eqlext.jxb.gr.ResRecord) 

    /**
     * Method setResRecord
     *
     * @param resRecordArray
     */
    public void setResRecord(
            com.queplix.core.modules.eqlext.jxb.gr.ResRecord[] resRecordArray) {
        //-- copy array
        _resRecordList.clear();
        for(int i = 0; i < resRecordArray.length; i++) {
            _resRecordList.add(resRecordArray[i]);
        }
    } //-- void setResRecord(com.queplix.core.modules.eqlext.jxb.gr.ResRecord) 

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

}
