com.gargoylesoftware.base.trace
Class BlockingCircularQueue

java.lang.Object
  extended bycom.gargoylesoftware.base.trace.BlockingCircularQueue
All Implemented Interfaces:
Serializable

public class BlockingCircularQueue
extends Object
implements Serializable

Internal use only.

.

A circular queue with blocking semantics.

Version:
$Revision: 1.8 $
Author:
Mike Bowler
See Also:
Serialized Form

Constructor Summary
BlockingCircularQueue()
          Create the queue with a capacity of 20
BlockingCircularQueue(int capacity)
          Create the queue with the specified capacity
 
Method Summary
 boolean add(Object object)
          Add an object to the queue.
protected  void assertNotNull(String fieldName, Object fieldValue)
          Verify that the specified value is not null.
 void clear()
          Remove all items from the queue
 boolean isEmpty()
          Return true if the collection is empty.
 Object next()
          Return the next item in the queue.
 int size()
          Return the number of objects currently in the collection.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BlockingCircularQueue

public BlockingCircularQueue()
Create the queue with a capacity of 20


BlockingCircularQueue

public BlockingCircularQueue(int capacity)
Create the queue with the specified capacity

Parameters:
capacity - The size of the queue
Method Detail

clear

public void clear()
Remove all items from the queue


add

public boolean add(Object object)
Add an object to the queue. If the collection is currently full then block until an object is removed.

Parameters:
object - The object to add.
Returns:
true if the object was successfully added.

next

public Object next()
Return the next item in the queue. The returned item is removed from the collection. If no objects are present then block until an object has been added.

Returns:
The next item.

size

public int size()
Return the number of objects currently in the collection.

Returns:
The object count.

isEmpty

public boolean isEmpty()
Return true if the collection is empty.

Returns:
true if the collection is empty.

toString

public String toString()
Return a string representation of this object.

Returns:
a string representation of this object.

assertNotNull

protected final void assertNotNull(String fieldName,
                                   Object fieldValue)
                            throws DetailedNullPointerException
Verify that the specified value is not null. If it is then throw an exception

Parameters:
fieldName - The name of the field to check
fieldValue - The value of the field to check
Throws:
DetailedNullPointerException - If fieldValue is null


Copyright © 1998-2005 Gargoyle Software Inc.. All Rights Reserved.