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

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

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

import java.util.ArrayList;

/**
 * The context menu type description
 *
 * @version $Revision$ $Date$
 */
public class ContextMenuType extends com.queplix.core.utils.jxb.JXBObject
        implements java.io.Serializable {

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

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

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

    /**
     * The menu item description
     */
    private java.util.ArrayList _menuItemList;

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

    public ContextMenuType() {
        super();
        _contextMenuFormList = new ArrayList();
        _menuItemList = new ArrayList();
    } //-- com.queplix.core.modules.config.jxb.ContextMenuType()

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

    /**
     * Method addContextMenuForm
     *
     * @param vContextMenuForm
     */
    public void addContextMenuForm(
            com.queplix.core.modules.config.jxb.ContextMenuForm vContextMenuForm)
            throws java.lang.IndexOutOfBoundsException {
        _contextMenuFormList.add(vContextMenuForm);
    } //-- void addContextMenuForm(com.queplix.core.modules.config.jxb.ContextMenuForm) 

    /**
     * Method addContextMenuForm
     *
     * @param index
     * @param vContextMenuForm
     */
    public void addContextMenuForm(int index,
                                   com.queplix.core.modules.config.jxb.ContextMenuForm vContextMenuForm)
            throws java.lang.IndexOutOfBoundsException {
        _contextMenuFormList.add(index, vContextMenuForm);
    } //-- void addContextMenuForm(int, com.queplix.core.modules.config.jxb.ContextMenuForm) 

    /**
     * Method addMenuItem
     *
     * @param vMenuItem
     */
    public void addMenuItem(
            com.queplix.core.modules.config.jxb.MenuItem vMenuItem)
            throws java.lang.IndexOutOfBoundsException {
        _menuItemList.add(vMenuItem);
    } //-- void addMenuItem(com.queplix.core.modules.config.jxb.MenuItem) 

    /**
     * Method addMenuItem
     *
     * @param index
     * @param vMenuItem
     */
    public void addMenuItem(int index,
                            com.queplix.core.modules.config.jxb.MenuItem vMenuItem)
            throws java.lang.IndexOutOfBoundsException {
        _menuItemList.add(index, vMenuItem);
    } //-- void addMenuItem(int, com.queplix.core.modules.config.jxb.MenuItem) 

    /**
     * Method clearContextMenuForm
     */
    public void clearContextMenuForm() {
        _contextMenuFormList.clear();
    } //-- void clearContextMenuForm() 

    /**
     * Method clearMenuItem
     */
    public void clearMenuItem() {
        _menuItemList.clear();
    } //-- void clearMenuItem() 

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

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

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

        return (com.queplix.core.modules.config.jxb.ContextMenuForm) _contextMenuFormList
                .get(index);
    } //-- com.queplix.core.modules.config.jxb.ContextMenuForm getContextMenuForm(int) 

    /**
     * Method getContextMenuForm
     *
     * @return ContextMenuForm
     */
    public com.queplix.core.modules.config.jxb.ContextMenuForm[] getContextMenuForm() {
        int size = _contextMenuFormList.size();
        com.queplix.core.modules.config.jxb.ContextMenuForm[] mArray
                = new com.queplix.core.modules.config.jxb.ContextMenuForm[size];
        for(int index = 0; index < size; index++) {
            mArray[index]
                    = (com.queplix.core.modules.config.jxb.ContextMenuForm) _contextMenuFormList
                    .get(index);
        }
        return mArray;
    } //-- com.queplix.core.modules.config.jxb.ContextMenuForm[] getContextMenuForm() 

    /**
     * Method getContextMenuFormCount
     *
     * @return int
     */
    public int getContextMenuFormCount() {
        return _contextMenuFormList.size();
    } //-- int getContextMenuFormCount() 

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

        return (com.queplix.core.modules.config.jxb.MenuItem) _menuItemList.get(
                index);
    } //-- com.queplix.core.modules.config.jxb.MenuItem getMenuItem(int) 

    /**
     * Method getMenuItem
     *
     * @return MenuItem
     */
    public com.queplix.core.modules.config.jxb.MenuItem[] getMenuItem() {
        int size = _menuItemList.size();
        com.queplix.core.modules.config.jxb.MenuItem[] mArray
                = new com.queplix.core.modules.config.jxb.MenuItem[size];
        for(int index = 0; index < size; index++) {
            mArray[index]
                    = (com.queplix.core.modules.config.jxb.MenuItem) _menuItemList
                    .get(index);
        }
        return mArray;
    } //-- com.queplix.core.modules.config.jxb.MenuItem[] getMenuItem() 

    /**
     * Method getMenuItemCount
     *
     * @return int
     */
    public int getMenuItemCount() {
        return _menuItemList.size();
    } //-- int getMenuItemCount() 

    /**
     * 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 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 removeContextMenuForm
     *
     * @param vContextMenuForm
     * @return boolean
     */
    public boolean removeContextMenuForm(
            com.queplix.core.modules.config.jxb.ContextMenuForm vContextMenuForm) {
        boolean removed = _contextMenuFormList.remove(vContextMenuForm);
        return removed;
    } //-- boolean removeContextMenuForm(com.queplix.core.modules.config.jxb.ContextMenuForm) 

    /**
     * Method removeMenuItem
     *
     * @param vMenuItem
     * @return boolean
     */
    public boolean removeMenuItem(
            com.queplix.core.modules.config.jxb.MenuItem vMenuItem) {
        boolean removed = _menuItemList.remove(vMenuItem);
        return removed;
    } //-- boolean removeMenuItem(com.queplix.core.modules.config.jxb.MenuItem) 

    /**
     * Method setContextMenuForm
     *
     * @param index
     * @param vContextMenuForm
     */
    public void setContextMenuForm(int index,
                                   com.queplix.core.modules.config.jxb.ContextMenuForm vContextMenuForm)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _contextMenuFormList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _contextMenuFormList.set(index, vContextMenuForm);
    } //-- void setContextMenuForm(int, com.queplix.core.modules.config.jxb.ContextMenuForm) 

    /**
     * Method setContextMenuForm
     *
     * @param contextMenuFormArray
     */
    public void setContextMenuForm(
            com.queplix.core.modules.config.jxb.ContextMenuForm[] contextMenuFormArray) {
        //-- copy array
        _contextMenuFormList.clear();
        for(int i = 0; i < contextMenuFormArray.length; i++) {
            _contextMenuFormList.add(contextMenuFormArray[i]);
        }
    } //-- void setContextMenuForm(com.queplix.core.modules.config.jxb.ContextMenuForm) 

    /**
     * Method setMenuItem
     *
     * @param index
     * @param vMenuItem
     */
    public void setMenuItem(int index,
                            com.queplix.core.modules.config.jxb.MenuItem vMenuItem)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _menuItemList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _menuItemList.set(index, vMenuItem);
    } //-- void setMenuItem(int, com.queplix.core.modules.config.jxb.MenuItem) 

    /**
     * Method setMenuItem
     *
     * @param menuItemArray
     */
    public void setMenuItem(
            com.queplix.core.modules.config.jxb.MenuItem[] menuItemArray) {
        //-- copy array
        _menuItemList.clear();
        for(int i = 0; i < menuItemArray.length; i++) {
            _menuItemList.add(menuItemArray[i]);
        }
    } //-- void setMenuItem(com.queplix.core.modules.config.jxb.MenuItem) 

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

}
