Class BoundedBuffer
java.lang.Object
org.apache.commons.collections.collection.SynchronizedCollection
org.apache.commons.collections.buffer.SynchronizedBuffer
org.apache.commons.collections.buffer.BoundedBuffer
- All Implemented Interfaces:
Serializable,Iterable,Collection,BoundedCollection,Buffer
@Deprecated(since="2021-04-30")
public class BoundedBuffer
extends SynchronizedBuffer
implements BoundedCollection
Deprecated.
Apache Commons Collections version 3.x is being deprecated from AEMaaCS. The upgraded version 4.4 of Commons Collections is already included as replacement. Customers are advised to upgrade to this version of the library. Please note: the package name was changed to org.apache.commons.collections4. Further note that there are AEM APIs currently exposing the old collections classes; these will be updated in upcoming releases.
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.
- Since:
- Commons Collections 3.2
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.booleanaddAll(Collection c) Deprecated.static BoundedBufferDeprecated.Factory method to create a bounded buffer.static BoundedBufferDeprecated.Factory method to create a bounded buffer that blocks for a maximum amount of time.booleanisFull()Deprecated.Returns true if this collection is full and no new elements can be added.iterator()Deprecated.Iterators must be manually synchronized.intmaxSize()Deprecated.Gets the maximum size of the collection (the bound).remove()Deprecated.Gets and removes the next object from the buffer.Methods inherited from class org.apache.commons.collections.buffer.SynchronizedBuffer
decorate, getMethods inherited from class org.apache.commons.collections.collection.SynchronizedCollection
clear, contains, containsAll, decorate, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toStringMethods inherited from interface java.util.Collection
clear, contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
-
Method Details
-
decorate
Deprecated.Factory method to create a bounded buffer.When the buffer is full, it will immediately throw a
BufferOverflowExceptionon callingadd().- Parameters:
buffer- the buffer to decorate, must not be nullmaximumSize- the maximum size, must be size one or greater- Returns:
- a new bounded buffer
- Throws:
IllegalArgumentException- if the buffer is nullIllegalArgumentException- if the maximum size is zero or less
-
decorate
Deprecated.Factory method to create a bounded buffer that blocks for a maximum amount of time.- Parameters:
buffer- the buffer to decorate, must not be nullmaximumSize- the maximum size, must be size one or greatertimeout- the maximum amount of time to wait in milliseconds- Returns:
- a new bounded buffer
- Throws:
IllegalArgumentException- if the buffer is nullIllegalArgumentException- if the maximum size is zero or less
-
remove
Deprecated.Description copied from interface:BufferGets and removes the next object from the buffer.- Specified by:
removein interfaceBuffer- Overrides:
removein classSynchronizedBuffer- Returns:
- the next object in the buffer, which is also removed
-
add
Deprecated.- Specified by:
addin interfaceCollection- Overrides:
addin classSynchronizedCollection
-
addAll
Deprecated.- Specified by:
addAllin interfaceCollection- Overrides:
addAllin classSynchronizedCollection
-
iterator
Deprecated.Description copied from class:SynchronizedCollectionIterators must be manually synchronized.synchronized (coll) { Iterator it = coll.iterator(); // do stuff with iterator }- Specified by:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable- Overrides:
iteratorin classSynchronizedCollection- Returns:
- an iterator that must be manually synchronized on the collection
-
isFull
public boolean isFull()Deprecated.Description copied from interface:BoundedCollectionReturns true if this collection is full and no new elements can be added.- Specified by:
isFullin interfaceBoundedCollection- Returns:
trueif the collection is full
-
maxSize
public int maxSize()Deprecated.Description copied from interface:BoundedCollectionGets the maximum size of the collection (the bound).- Specified by:
maxSizein interfaceBoundedCollection- Returns:
- the maximum number of elements the collection can hold
-