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

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

    /**
     * The context menu description
     */
    private java.util.ArrayList _contextMenuList;

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

    public ContextMenus() {
        super();
        _contextMenuList = new ArrayList();
    } //-- com.queplix.core.modules.config.jxb.ContextMenus()

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

    /**
     * Method addContextMenu
     *
     * @param vContextMenu
     */
    public void addContextMenu(
            com.queplix.core.modules.config.jxb.ContextMenu vContextMenu)
            throws java.lang.IndexOutOfBoundsException {
        _contextMenuList.add(vContextMenu);
    } //-- void addContextMenu(com.queplix.core.modules.config.jxb.ContextMenu) 

    /**
     * Method addContextMenu
     *
     * @param index
     * @param vContextMenu
     */
    public void addContextMenu(int index,
                               com.queplix.core.modules.config.jxb.ContextMenu vContextMenu)
            throws java.lang.IndexOutOfBoundsException {
        _contextMenuList.add(index, vContextMenu);
    } //-- void addContextMenu(int, com.queplix.core.modules.config.jxb.ContextMenu) 

    /**
     * Method clearContextMenu
     */
    public void clearContextMenu() {
        _contextMenuList.clear();
    } //-- void clearContextMenu() 

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

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

        return (com.queplix.core.modules.config.jxb.ContextMenu) _contextMenuList
                .get(index);
    } //-- com.queplix.core.modules.config.jxb.ContextMenu getContextMenu(int) 

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

    /**
     * Method getContextMenuCount
     *
     * @return int
     */
    public int getContextMenuCount() {
        return _contextMenuList.size();
    } //-- int getContextMenuCount() 

    /**
     * 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 removeContextMenu
     *
     * @param vContextMenu
     * @return boolean
     */
    public boolean removeContextMenu(
            com.queplix.core.modules.config.jxb.ContextMenu vContextMenu) {
        boolean removed = _contextMenuList.remove(vContextMenu);
        return removed;
    } //-- boolean removeContextMenu(com.queplix.core.modules.config.jxb.ContextMenu) 

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

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

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

}
