/***********************************************************************

GECCO, a platform for command and control gaming

Copyright (C) 2001 Henrik Bäärnhielm, Andreas Enblom, Niklas
Hallenfur, Karl Hasselström, Henrik Hägerström, Oskar Linde, Jing Fu
Zi and Jon Åslund

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.

***********************************************************************/

package gecco.communication.messages;
import java.util.*;

/**
 *  A simple queue for messages to be sent, used both in the server and client
 *  part of the communication packages.
 *
 * @author     Niklas Hallenfur
 * @created    June 27, 2001
 */

public class MessageQueue {
    /**
     *  Description of the Field
     */
    LinkedList items;


    /**
     *  Constructor for the MessageQueue object
     */
    public MessageQueue() {
        items = new LinkedList();
    }


    /**
     *  Description of the Method
     *
     * @return    Description of the Returned Value
     */
    public Object get() {
        try {
            Object first = items.removeFirst();
            return first;
        } catch (Exception e) {
            return null;
        }
    }


    /**
     *  Gets the Empty attribute of the MessageQueue object
     *
     * @return    The Empty value
     */
    public boolean isEmpty() {
        return (items.size() == 0);
    }


    /**
     *  Description of the Method
     *
     * @return    Description of the Returned Value
     */
    public int size() {
        return items.size();
    }


    /**
     *  Description of the Method
     *
     * @param  mess  Description of Parameter
     */
    public void add(Object mess) {
        items.addLast(mess);
    }
}


