| org.apache.commons.collections.buffer.SynchronizedBuffer org.apache.commons.collections.buffer.BoundedBuffer
BoundedBuffer | public class BoundedBuffer extends SynchronizedBuffer implements BoundedCollection(Code) | | Decorates another Buffer to ensure a fixed maximum size.
Note: This class should only be used if you need to add bounded
behaviour to another buffer. If you just want a bounded buffer then
you should use
BoundedFifoBuffer or
CircularFifoBuffer .
The decoration methods allow you to specify a timeout value.
This alters the behaviour of the add methods when the buffer is full.
Normally, when the buffer is full, the add method will throw an exception.
With a timeout, the add methods will wait for up to the timeout period
to try and add the elements.
author: James Carman author: Stephen Colebourne version: $Revision: 405927 $ $Date: 2006-05-12 23:57:03 +0100 (Fri, 12 May 2006) $ since: Commons Collections 3.2 |
Constructor Summary | |
protected | BoundedBuffer(Buffer buffer, int maximumSize, long timeout) Constructor that wraps (not copies) another buffer, making it bounded
waiting only up to a maximum amount of time. |
BoundedBuffer | protected BoundedBuffer(Buffer buffer, int maximumSize, long timeout)(Code) | | Constructor that wraps (not copies) another buffer, making it bounded
waiting only up to a maximum amount of time.
Parameters: buffer - the buffer to wrap, must not be null Parameters: maximumSize - the maximum size, must be size one or greater Parameters: timeout - the maximum amount of time to wait throws: IllegalArgumentException - if the buffer is null throws: IllegalArgumentException - if the maximum size is zero or less |
decorate | public static BoundedBuffer decorate(Buffer buffer, int maximumSize)(Code) | | Factory method to create a bounded buffer.
When the buffer is full, it will immediately throw a
BufferOverflowException on calling add() .
Parameters: buffer - the buffer to decorate, must not be null Parameters: maximumSize - the maximum size, must be size one or greater a new bounded buffer throws: IllegalArgumentException - if the buffer is null throws: IllegalArgumentException - if the maximum size is zero or less |
decorate | public static BoundedBuffer decorate(Buffer buffer, int maximumSize, long timeout)(Code) | | Factory method to create a bounded buffer that blocks for a maximum
amount of time.
Parameters: buffer - the buffer to decorate, must not be null Parameters: maximumSize - the maximum size, must be size one or greater Parameters: timeout - the maximum amount of time to wait in milliseconds a new bounded buffer throws: IllegalArgumentException - if the buffer is null throws: IllegalArgumentException - if the maximum size is zero or less |
isFull | public boolean isFull()(Code) | | |
maxSize | public int maxSize()(Code) | | |
|
|