java.lang.Object | |||
↳ | org.apache.commons.collections.collection.SynchronizedCollection | ||
↳ | org.apache.commons.collections.buffer.SynchronizedBuffer | ||
↳ | org.apache.commons.collections.buffer.BoundedBuffer |
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.
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.collections.collection.SynchronizedCollection
|
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor that wraps (not copies) another buffer, making it bounded
waiting only up to a maximum amount of time.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Factory method to create a bounded buffer that blocks for a maximum
amount of time.
| |||||||||||
Factory method to create a bounded buffer.
| |||||||||||
Returns true if this collection is full and no new elements can be added.
| |||||||||||
Iterators must be manually synchronized.
| |||||||||||
Gets the maximum size of the collection (the bound).
| |||||||||||
Gets and removes the next object from the buffer.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.collections.buffer.SynchronizedBuffer
| |||||||||||
From class
org.apache.commons.collections.collection.SynchronizedCollection
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Iterable
| |||||||||||
From interface
java.util.Collection
| |||||||||||
From interface
org.apache.commons.collections.BoundedCollection
| |||||||||||
From interface
org.apache.commons.collections.Buffer
|
Constructor that wraps (not copies) another buffer, making it bounded waiting only up to a maximum amount of time.
buffer | the buffer to wrap, must not be null |
---|---|
maximumSize | the maximum size, must be size one or greater |
timeout | the maximum amount of time to wait |
IllegalArgumentException | if the buffer is null |
---|---|
IllegalArgumentException | if the maximum size is zero or less |
Factory method to create a bounded buffer that blocks for a maximum amount of time.
buffer | the buffer to decorate, must not be null |
---|---|
maximumSize | the maximum size, must be size one or greater |
timeout | the maximum amount of time to wait in milliseconds |
IllegalArgumentException | if the buffer is null |
---|---|
IllegalArgumentException | if the maximum size is zero or less |
Factory method to create a bounded buffer.
When the buffer is full, it will immediately throw a
BufferOverflowException
on calling add()
.
buffer | the buffer to decorate, must not be null |
---|---|
maximumSize | the maximum size, must be size one or greater |
IllegalArgumentException | if the buffer is null |
---|---|
IllegalArgumentException | if the maximum size is zero or less |
Returns true if this collection is full and no new elements can be added.
true
if the collection is full
Iterators must be manually synchronized.
synchronized (coll) { Iterator it = coll.iterator(); // do stuff with iterator }
Gets the maximum size of the collection (the bound).
Gets and removes the next object from the buffer.