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

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

    /**
     * Internal choice value storage
     */
    private java.lang.Object _choiceValue;

    /**
     * Field _reqEntity
     */
    private com.queplix.core.modules.eqlext.jxb.gr.ReqEntity _reqEntity;

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

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

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

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

    /**
     * Method addReqField
     *
     * @param vReqField
     */
    public void addReqField(
            com.queplix.core.modules.eqlext.jxb.gr.ReqField vReqField)
            throws java.lang.IndexOutOfBoundsException {
        _reqFieldList.add(vReqField);
    } //-- void addReqField(com.queplix.core.modules.eqlext.jxb.gr.ReqField) 

    /**
     * Method addReqField
     *
     * @param index
     * @param vReqField
     */
    public void addReqField(int index,
                            com.queplix.core.modules.eqlext.jxb.gr.ReqField vReqField)
            throws java.lang.IndexOutOfBoundsException {
        _reqFieldList.add(index, vReqField);
    } //-- void addReqField(int, com.queplix.core.modules.eqlext.jxb.gr.ReqField) 

    /**
     * Method clearReqField
     */
    public void clearReqField() {
        _reqFieldList.clear();
    } //-- void clearReqField() 

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

    /**
     * Returns the value of field 'choiceValue'. The field
     * 'choiceValue' has the following description: Internal choice
     * value storage
     *
     * @return the value of field 'choiceValue'.
     */
    public java.lang.Object getChoiceValue() {
        return this._choiceValue;
    } //-- java.lang.Object getChoiceValue() 

    /**
     * Returns the value of field 'reqEntity'.
     *
     * @return the value of field 'reqEntity'.
     */
    public com.queplix.core.modules.eqlext.jxb.gr.ReqEntity getReqEntity() {
        return this._reqEntity;
    } //-- com.queplix.core.modules.eqlext.jxb.gr.ReqEntity getReqEntity() 

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

        return (com.queplix.core.modules.eqlext.jxb.gr.ReqField) _reqFieldList
                .get(index);
    } //-- com.queplix.core.modules.eqlext.jxb.gr.ReqField getReqField(int) 

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

    /**
     * Method getReqFieldCount
     *
     * @return int
     */
    public int getReqFieldCount() {
        return _reqFieldList.size();
    } //-- int getReqFieldCount() 

    /**
     * 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 removeReqField
     *
     * @param vReqField
     * @return boolean
     */
    public boolean removeReqField(
            com.queplix.core.modules.eqlext.jxb.gr.ReqField vReqField) {
        boolean removed = _reqFieldList.remove(vReqField);
        return removed;
    } //-- boolean removeReqField(com.queplix.core.modules.eqlext.jxb.gr.ReqField) 

    /**
     * Sets the value of field 'reqEntity'.
     *
     * @param reqEntity the value of field 'reqEntity'.
     */
    public void setReqEntity(
            com.queplix.core.modules.eqlext.jxb.gr.ReqEntity reqEntity) {
        this._reqEntity = reqEntity;
        this._choiceValue = reqEntity;
    } //-- void setReqEntity(com.queplix.core.modules.eqlext.jxb.gr.ReqEntity) 

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

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

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

}
