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

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

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

    /**
     * The sequence of server-side messages
     */
    private java.util.ArrayList _serverList;

    /**
     * The sequence of client-side messages
     */
    private java.util.ArrayList _clientList;

    /**
     * The sequence of messages for popup-menus
     */
    private java.util.ArrayList _popupList;

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

    public Messages() {
        super();
        _serverList = new ArrayList();
        _clientList = new ArrayList();
        _popupList = new ArrayList();
    } //-- com.queplix.core.modules.config.jxb.Messages()

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

    /**
     * Method addClient
     *
     * @param vClient
     */
    public void addClient(com.queplix.core.modules.config.jxb.Client vClient)
            throws java.lang.IndexOutOfBoundsException {
        _clientList.add(vClient);
    } //-- void addClient(com.queplix.core.modules.config.jxb.Client) 

    /**
     * Method addClient
     *
     * @param index
     * @param vClient
     */
    public void addClient(int index,
                          com.queplix.core.modules.config.jxb.Client vClient)
            throws java.lang.IndexOutOfBoundsException {
        _clientList.add(index, vClient);
    } //-- void addClient(int, com.queplix.core.modules.config.jxb.Client) 

    /**
     * Method addPopup
     *
     * @param vPopup
     */
    public void addPopup(com.queplix.core.modules.config.jxb.Popup vPopup)
            throws java.lang.IndexOutOfBoundsException {
        _popupList.add(vPopup);
    } //-- void addPopup(com.queplix.core.modules.config.jxb.Popup) 

    /**
     * Method addPopup
     *
     * @param index
     * @param vPopup
     */
    public void addPopup(int index,
                         com.queplix.core.modules.config.jxb.Popup vPopup)
            throws java.lang.IndexOutOfBoundsException {
        _popupList.add(index, vPopup);
    } //-- void addPopup(int, com.queplix.core.modules.config.jxb.Popup) 

    /**
     * Method addServer
     *
     * @param vServer
     */
    public void addServer(com.queplix.core.modules.config.jxb.Server vServer)
            throws java.lang.IndexOutOfBoundsException {
        _serverList.add(vServer);
    } //-- void addServer(com.queplix.core.modules.config.jxb.Server) 

    /**
     * Method addServer
     *
     * @param index
     * @param vServer
     */
    public void addServer(int index,
                          com.queplix.core.modules.config.jxb.Server vServer)
            throws java.lang.IndexOutOfBoundsException {
        _serverList.add(index, vServer);
    } //-- void addServer(int, com.queplix.core.modules.config.jxb.Server) 

    /**
     * Method clearClient
     */
    public void clearClient() {
        _clientList.clear();
    } //-- void clearClient() 

    /**
     * Method clearPopup
     */
    public void clearPopup() {
        _popupList.clear();
    } //-- void clearPopup() 

    /**
     * Method clearServer
     */
    public void clearServer() {
        _serverList.clear();
    } //-- void clearServer() 

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

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

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

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

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

        return (com.queplix.core.modules.config.jxb.Client) _clientList.get(
                index);
    } //-- com.queplix.core.modules.config.jxb.Client getClient(int) 

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

    /**
     * Method getClientCount
     *
     * @return int
     */
    public int getClientCount() {
        return _clientList.size();
    } //-- int getClientCount() 

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

        return (com.queplix.core.modules.config.jxb.Popup) _popupList.get(
                index);
    } //-- com.queplix.core.modules.config.jxb.Popup getPopup(int) 

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

    /**
     * Method getPopupCount
     *
     * @return int
     */
    public int getPopupCount() {
        return _popupList.size();
    } //-- int getPopupCount() 

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

        return (com.queplix.core.modules.config.jxb.Server) _serverList.get(
                index);
    } //-- com.queplix.core.modules.config.jxb.Server getServer(int) 

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

    /**
     * Method getServerCount
     *
     * @return int
     */
    public int getServerCount() {
        return _serverList.size();
    } //-- int getServerCount() 

    /**
     * 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 removeClient
     *
     * @param vClient
     * @return boolean
     */
    public boolean removeClient(
            com.queplix.core.modules.config.jxb.Client vClient) {
        boolean removed = _clientList.remove(vClient);
        return removed;
    } //-- boolean removeClient(com.queplix.core.modules.config.jxb.Client) 

    /**
     * Method removePopup
     *
     * @param vPopup
     * @return boolean
     */
    public boolean removePopup(
            com.queplix.core.modules.config.jxb.Popup vPopup) {
        boolean removed = _popupList.remove(vPopup);
        return removed;
    } //-- boolean removePopup(com.queplix.core.modules.config.jxb.Popup) 

    /**
     * Method removeServer
     *
     * @param vServer
     * @return boolean
     */
    public boolean removeServer(
            com.queplix.core.modules.config.jxb.Server vServer) {
        boolean removed = _serverList.remove(vServer);
        return removed;
    } //-- boolean removeServer(com.queplix.core.modules.config.jxb.Server) 

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

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

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

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

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

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

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

}
