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

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

    /**
     * Field _id
     */
    private java.lang.Integer _id;

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

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

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

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

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

    /**
     * Method addResDataset
     *
     * @param vResDataset
     */
    public void addResDataset(
            com.queplix.core.modules.eqlext.jxb.gr.ResDataset vResDataset)
            throws java.lang.IndexOutOfBoundsException {
        _resDatasetList.add(vResDataset);
    } //-- void addResDataset(com.queplix.core.modules.eqlext.jxb.gr.ResDataset) 

    /**
     * Method addResDataset
     *
     * @param index
     * @param vResDataset
     */
    public void addResDataset(int index,
                              com.queplix.core.modules.eqlext.jxb.gr.ResDataset vResDataset)
            throws java.lang.IndexOutOfBoundsException {
        _resDatasetList.add(index, vResDataset);
    } //-- void addResDataset(int, com.queplix.core.modules.eqlext.jxb.gr.ResDataset) 

    /**
     * Method addResField
     *
     * @param vResField
     */
    public void addResField(
            com.queplix.core.modules.eqlext.jxb.gr.ResField vResField)
            throws java.lang.IndexOutOfBoundsException {
        _resFieldList.add(vResField);
    } //-- void addResField(com.queplix.core.modules.eqlext.jxb.gr.ResField) 

    /**
     * Method addResField
     *
     * @param index
     * @param vResField
     */
    public void addResField(int index,
                            com.queplix.core.modules.eqlext.jxb.gr.ResField vResField)
            throws java.lang.IndexOutOfBoundsException {
        _resFieldList.add(index, vResField);
    } //-- void addResField(int, com.queplix.core.modules.eqlext.jxb.gr.ResField) 

    /**
     * Method clearResDataset
     */
    public void clearResDataset() {
        _resDatasetList.clear();
    } //-- void clearResDataset() 

    /**
     * Method clearResField
     */
    public void clearResField() {
        _resFieldList.clear();
    } //-- void clearResField() 

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

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

    /**
     * Returns the value of field 'id'.
     *
     * @return the value of field 'id'.
     */
    public java.lang.Integer getId() {
        return this._id;
    } //-- java.lang.Integer getId() 

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

        return (com.queplix.core.modules.eqlext.jxb.gr.ResDataset) _resDatasetList
                .get(index);
    } //-- com.queplix.core.modules.eqlext.jxb.gr.ResDataset getResDataset(int) 

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

    /**
     * Method getResDatasetCount
     *
     * @return int
     */
    public int getResDatasetCount() {
        return _resDatasetList.size();
    } //-- int getResDatasetCount() 

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

        return (com.queplix.core.modules.eqlext.jxb.gr.ResField) _resFieldList
                .get(index);
    } //-- com.queplix.core.modules.eqlext.jxb.gr.ResField getResField(int) 

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

    /**
     * Method getResFieldCount
     *
     * @return int
     */
    public int getResFieldCount() {
        return _resFieldList.size();
    } //-- int getResFieldCount() 

    /**
     * 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 removeResDataset
     *
     * @param vResDataset
     * @return boolean
     */
    public boolean removeResDataset(
            com.queplix.core.modules.eqlext.jxb.gr.ResDataset vResDataset) {
        boolean removed = _resDatasetList.remove(vResDataset);
        return removed;
    } //-- boolean removeResDataset(com.queplix.core.modules.eqlext.jxb.gr.ResDataset) 

    /**
     * Method removeResField
     *
     * @param vResField
     * @return boolean
     */
    public boolean removeResField(
            com.queplix.core.modules.eqlext.jxb.gr.ResField vResField) {
        boolean removed = _resFieldList.remove(vResField);
        return removed;
    } //-- boolean removeResField(com.queplix.core.modules.eqlext.jxb.gr.ResField) 

    /**
     * Sets the value of field 'id'.
     *
     * @param id the value of field 'id'.
     */
    public void setId(java.lang.Integer id) {
        this._id = id;
    } //-- void setId(java.lang.Integer) 

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

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

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

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

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

}
