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

/**
 * Chart's parameters
 *
 * @version $Revision$ $Date$
 */
public class ChartParams extends com.queplix.core.utils.jxb.JXBObject
        implements java.io.Serializable {

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

    /**
     * Chart's visible title
     */
    private java.lang.String _title;

    /**
     * Chart's type (only bar and pie are supported now)
     */
    private com.queplix.core.modules.eqlext.jxb.gr.types.ChartType _type;

    /**
     * Chart's orientation (vertical or horizontal)
     */
    private com.queplix.core.modules.eqlext.jxb.gr.types.ChartOrientation _orientation;

    /**
     * Optional parameters
     */
    private java.util.ArrayList _chartParamList;

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

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

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

    /**
     * Method addChartParam
     *
     * @param vChartParam
     */
    public void addChartParam(
            com.queplix.core.modules.eqlext.jxb.gr.ChartParam vChartParam)
            throws java.lang.IndexOutOfBoundsException {
        _chartParamList.add(vChartParam);
    } //-- void addChartParam(com.queplix.core.modules.eqlext.jxb.gr.ChartParam) 

    /**
     * Method addChartParam
     *
     * @param index
     * @param vChartParam
     */
    public void addChartParam(int index,
                              com.queplix.core.modules.eqlext.jxb.gr.ChartParam vChartParam)
            throws java.lang.IndexOutOfBoundsException {
        _chartParamList.add(index, vChartParam);
    } //-- void addChartParam(int, com.queplix.core.modules.eqlext.jxb.gr.ChartParam) 

    /**
     * Method clearChartParam
     */
    public void clearChartParam() {
        _chartParamList.clear();
    } //-- void clearChartParam() 

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

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

        return (com.queplix.core.modules.eqlext.jxb.gr.ChartParam) _chartParamList
                .get(index);
    } //-- com.queplix.core.modules.eqlext.jxb.gr.ChartParam getChartParam(int) 

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

    /**
     * Method getChartParamCount
     *
     * @return int
     */
    public int getChartParamCount() {
        return _chartParamList.size();
    } //-- int getChartParamCount() 

    /**
     * Returns the value of field 'orientation'. The field
     * 'orientation' has the following description: Chart's
     * orientation (vertical or horizontal)
     *
     * @return the value of field 'orientation'.
     */
    public com.queplix.core.modules.eqlext.jxb.gr.types.ChartOrientation getOrientation() {
        return this._orientation;
    } //-- com.queplix.core.modules.eqlext.jxb.gr.types.ChartOrientation getOrientation() 

    /**
     * Returns the value of field 'title'. The field 'title' has
     * the following description: Chart's visible title
     *
     * @return the value of field 'title'.
     */
    public java.lang.String getTitle() {
        return this._title;
    } //-- java.lang.String getTitle() 

    /**
     * Returns the value of field 'type'. The field 'type' has the
     * following description: Chart's type (only bar and pie are
     * supported now)
     *
     * @return the value of field 'type'.
     */
    public com.queplix.core.modules.eqlext.jxb.gr.types.ChartType getType() {
        return this._type;
    } //-- com.queplix.core.modules.eqlext.jxb.gr.types.ChartType getType() 

    /**
     * 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 removeChartParam
     *
     * @param vChartParam
     * @return boolean
     */
    public boolean removeChartParam(
            com.queplix.core.modules.eqlext.jxb.gr.ChartParam vChartParam) {
        boolean removed = _chartParamList.remove(vChartParam);
        return removed;
    } //-- boolean removeChartParam(com.queplix.core.modules.eqlext.jxb.gr.ChartParam) 

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

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

    /**
     * Sets the value of field 'orientation'. The field
     * 'orientation' has the following description: Chart's
     * orientation (vertical or horizontal)
     *
     * @param orientation the value of field 'orientation'.
     */
    public void setOrientation(
            com.queplix.core.modules.eqlext.jxb.gr.types.ChartOrientation orientation) {
        this._orientation = orientation;
    } //-- void setOrientation(com.queplix.core.modules.eqlext.jxb.gr.types.ChartOrientation) 

    /**
     * Sets the value of field 'title'. The field 'title' has the
     * following description: Chart's visible title
     *
     * @param title the value of field 'title'.
     */
    public void setTitle(java.lang.String title) {
        this._title = title;
    } //-- void setTitle(java.lang.String) 

    /**
     * Sets the value of field 'type'. The field 'type' has the
     * following description: Chart's type (only bar and pie are
     * supported now)
     *
     * @param type the value of field 'type'.
     */
    public void setType(
            com.queplix.core.modules.eqlext.jxb.gr.types.ChartType type) {
        this._type = type;
    } //-- void setType(com.queplix.core.modules.eqlext.jxb.gr.types.ChartType) 

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

}
