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

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

    /**
     * Field _entity
     */
    private java.lang.String _entity;

    /**
     * Field _name
     */
    private java.lang.String _name;

    /**
     * Field _loaded
     */
    private java.lang.Boolean _loaded = new java.lang.Boolean("false");

    /**
     * Field _external
     */
    private java.lang.String _external;

    /**
     * Field _internal
     */
    private java.lang.String _internal;

    /**
     * This attrubute is used on client-side to determine this
     * record is fake or not
     */
    private java.lang.Integer _rows = new java.lang.Integer("-1");

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

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

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

    //-----------/
    //- 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() 

    /**
     * Returns the value of field 'entity'.
     *
     * @return the value of field 'entity'.
     */
    public java.lang.String getEntity() {
        return this._entity;
    } //-- java.lang.String getEntity() 

    /**
     * Returns the value of field 'external'.
     *
     * @return the value of field 'external'.
     */
    public java.lang.String getExternal() {
        return this._external;
    } //-- java.lang.String getExternal() 

    /**
     * Returns the value of field 'internal'.
     *
     * @return the value of field 'internal'.
     */
    public java.lang.String getInternal() {
        return this._internal;
    } //-- java.lang.String getInternal() 

    /**
     * Returns the value of field 'loaded'.
     *
     * @return the value of field 'loaded'.
     */
    public java.lang.Boolean getLoaded() {
        return this._loaded;
    } //-- java.lang.Boolean getLoaded() 

    /**
     * Returns the value of field 'name'.
     *
     * @return the value of field 'name'.
     */
    public java.lang.String getName() {
        return this._name;
    } //-- java.lang.String getName() 

    /**
     * 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() 

    /**
     * Returns the value of field 'rows'. The field 'rows' has the
     * following description: This attrubute is used on client-side
     * to determine this record is fake or not
     *
     * @return the value of field 'rows'.
     */
    public java.lang.Integer getRows() {
        return this._rows;
    } //-- java.lang.Integer getRows() 

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

    /**
     * Sets the value of field 'entity'.
     *
     * @param entity the value of field 'entity'.
     */
    public void setEntity(java.lang.String entity) {
        this._entity = entity;
    } //-- void setForm(java.lang.String)

    /**
     * Sets the value of field 'external'.
     *
     * @param external the value of field 'external'.
     */
    public void setExternal(java.lang.String external) {
        this._external = external;
    } //-- void setExternal(java.lang.String) 

    /**
     * Sets the value of field 'internal'.
     *
     * @param internal the value of field 'internal'.
     */
    public void setInternal(java.lang.String internal) {
        this._internal = internal;
    } //-- void setInternal(java.lang.String) 

    /**
     * Sets the value of field 'loaded'.
     *
     * @param loaded the value of field 'loaded'.
     */
    public void setLoaded(java.lang.Boolean loaded) {
        this._loaded = loaded;
    } //-- void setLoaded(java.lang.Boolean) 

    /**
     * Sets the value of field 'name'.
     *
     * @param name the value of field 'name'.
     */
    public void setName(java.lang.String name) {
        this._name = name;
    } //-- void setName(java.lang.String) 

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

    /**
     * Sets the value of field 'rows'. The field 'rows' has the
     * following description: This attrubute is used on client-side
     * to determine this record is fake or not
     *
     * @param rows the value of field 'rows'.
     */
    public void setRows(java.lang.Integer rows) {
        this._rows = rows;
    } //-- void setRows(java.lang.Integer) 

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

}
