|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jsh3modtool.gui.imagetable.cache.Queue
public class Queue
Active queue that threads can listen on item addition and/or removal of items.
Field Summary | |
---|---|
protected java.util.Vector |
listeners
|
protected int |
numberOfAvailablePlaces
|
protected java.util.Vector |
queueItems
|
Constructor Summary | |
---|---|
Queue()
Creates a new instance of Queue |
|
Queue(int numberOfPlaces)
Creates a new instance of Queue |
Method Summary | |
---|---|
boolean |
add(QueueItem item)
Adds the specified item to the queue. |
protected boolean |
add(QueueItem item,
int index)
|
boolean |
addFirst(QueueItem item)
Adds the specified item to the end of the queue. |
boolean |
addLast(QueueItem item)
Adds the specified item to the end of the queue. |
void |
addListener(QueueListener listener)
Add a QueueListener to this object |
protected void |
fireAdditionEvent()
Fire event that there is a new item in the queue |
protected void |
fireItemAdded(QueueItem item)
Notify all listeners that an item has been added |
protected void |
fireItemRemoved(QueueItem item)
Notify all listeners that an item has been removed |
protected void |
fireRemovalEvent()
Fire event that there is one less item in the queue |
QueueItem |
getFirst()
Returns the first item in the queue |
QueueItem |
getLast()
Returns the last item in the queue |
boolean |
isEmpty()
Returns if the queue is empty. |
protected QueueItem |
remove(int index)
Remove the item at the specified index and return it. |
QueueItem |
remove(QueueItem item)
Removes the queueitem from the queue |
void |
removeAll()
Removes all items in the queue |
QueueItem |
removeFirst()
Removes the first item and returns it. |
QueueItem |
removeLast()
Removes the last item and returns it. |
void |
removeListener(QueueListener listener)
Remove a QueueListener from this object |
int |
size()
Returns the size of the queue |
boolean |
waitForEmptyQueue()
Waits until the queue is empty for the specified timeout time This method behaves exactly as if it simply performs the call waitForEmptyQueue(0) |
boolean |
waitForEmptyQueue(long timeout)
Waits until the queue is empty for the specified timeout time |
boolean |
waitForEmptySpace()
Waits until there is an available place in the queue. |
boolean |
waitForEmptySpace(long timeout)
Waits until there is an available place in the queue for the specified timeout time |
boolean |
waitForFirstObject()
Waits until there is an object in the queue |
boolean |
waitForFirstObject(long timeout)
Waits until there is an object in the queue for the specified timeout time |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Vector listeners
protected int numberOfAvailablePlaces
protected java.util.Vector queueItems
Constructor Detail |
---|
public Queue()
public Queue(int numberOfPlaces)
numberOfPlaces
- Maximum capacityMethod Detail |
---|
public boolean waitForFirstObject()
public boolean waitForFirstObject(long timeout)
timeout
- the maximum time to wait in milliseconds.
public boolean waitForEmptySpace()
public boolean waitForEmptySpace(long timeout)
timeout
- the maximum time to wait in milliseconds.
public boolean waitForEmptyQueue()
public boolean waitForEmptyQueue(long timeout)
timeout
- the maximum time to wait in milliseconds.
protected void fireAdditionEvent()
protected void fireRemovalEvent()
public boolean add(QueueItem item)
item
- the item to add
public boolean addLast(QueueItem item)
item
- the item to add
public boolean addFirst(QueueItem item)
item
- the item to add
protected boolean add(QueueItem item, int index)
public void removeAll()
protected QueueItem remove(int index)
index
- the item index to remove
public QueueItem remove(QueueItem item)
item
- the item to remove from the queue
public QueueItem removeFirst()
public QueueItem removeLast()
public QueueItem getFirst()
public QueueItem getLast()
public int size()
public boolean isEmpty()
public void addListener(QueueListener listener)
listener
- the listenerpublic void removeListener(QueueListener listener)
listener
- the listenerprotected void fireItemAdded(QueueItem item)
item
- the itemprotected void fireItemRemoved(QueueItem item)
item
- the item
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |