KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > util > collection > Queue


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.util.collection;
23
24 import java.util.Collection JavaDoc;
25
26 /**
27  * An iterface used to implement a first-in, first-out container.
28  *
29  * @version <tt>$Revision: 1958 $</tt>
30  * @author <a HREF="mailto:jason@planet57.com">Jason Dillon</a>
31  */

32 public interface Queue
33    extends Collection JavaDoc
34 {
35    /** Unlimited maximum queue size identifier. */
36    int UNLIMITED_MAXIMUM_SIZE = -1;
37
38    /**
39     * Get the maximum size of the queue.
40     *
41     * @return Maximum pool size or {@link #UNLIMITED_MAXIMUM_SIZE}.
42     */

43    int getMaximumSize();
44
45    /**
46     * Set the maximum size of the queue.
47     *
48     * @param size New maximim pool size or {@link #UNLIMITED_MAXIMUM_SIZE}.
49     *
50     * @exception IllegalArgumentException Illegal size.
51     */

52    void setMaximumSize(int size) throws IllegalArgumentException JavaDoc;
53
54    /**
55     * Check if the queue is full.
56     *
57     * @return True if the queue is full.
58     */

59    boolean isFull();
60
61    /**
62     * Check if the queue is empty.
63     *
64     * @return True if the queue is empty.
65     */

66    boolean isEmpty();
67
68    /**
69     * Enqueue an object onto the queue.
70     *
71     * @param obj Object to enqueue.
72     * @return True if collection was modified.
73     *
74     * @exception FullCollectionException The queue is full.
75     */

76    boolean add(Object JavaDoc obj) throws FullCollectionException;
77
78    /**
79     * Dequeue an object from the queue.
80     *
81     * @return Dequeued object.
82     *
83     * @exception EmptyCollectionException The queue is empty.
84     */

85    Object JavaDoc remove() throws EmptyCollectionException;
86
87    /**
88     * Get the object at the front of the queue.
89     *
90     * @return Object at the front of the queue.
91     *
92     * @exception EmptyCollectionException The queue is empty.
93     */

94    Object JavaDoc getFront() throws EmptyCollectionException;
95
96    /**
97     * Get the object at the back of the queue.
98     *
99     * @return Object at the back of the queue.
100     *
101     * @exception EmptyCollectionException The queue is empty.
102     */

103    Object JavaDoc getBack() throws EmptyCollectionException;
104 }
105
Popular Tags