|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.collections.BufferUtils
Contains static utility methods for operating on Buffer
objects.
Method Summary | |
static Buffer |
blockingBuffer(Buffer buffer)
Returns a synchronized buffer backed by the given buffer that will block on Buffer.get() and Buffer.remove() operations. |
static Buffer |
predicatedBuffer(Buffer buffer,
Predicate predicate)
Returns a predicated buffer backed by the given buffer. |
static Buffer |
synchronizedBuffer(Buffer buffer)
Returns a synchronized buffer backed by the given buffer. |
static Buffer |
unmodifiableBuffer(Buffer buffer)
Returns an unmodifiable buffer backed by the given buffer. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static Buffer synchronizedBuffer(Buffer buffer)
Collections
, you must manually synchronize on
the returned buffer's iterator to avoid non-deterministic behavior:
Buffer b = BufferUtils.synchronizedBuffer(myBuffer); synchronized (b) { Iterator i = b.iterator(); while (i.hasNext()) { process (i.next()); } }
buffer
- the buffer to synchronize, must not be null
java.lang.IllegalArgumentException
- if the Buffer is nullpublic static Buffer blockingBuffer(Buffer buffer)
Buffer.get()
and Buffer.remove()
operations.
If the buffer is empty, then the Buffer.get()
and
Buffer.remove()
operations will block until new elements
are added to the buffer, rather than immediately throwing a
BufferUnderflowException
.
buffer
- the buffer to synchronize, must not be null
java.lang.IllegalArgumentException
- if the Buffer is nullpublic static Buffer unmodifiableBuffer(Buffer buffer)
buffer
- the buffer to make unmodifiable, must not be null
java.lang.IllegalArgumentException
- if the Buffer is nullpublic static Buffer predicatedBuffer(Buffer buffer, Predicate predicate)
buffer
- the buffer to predicate, must not be nullpredicate
- the predicate used to evaluate new elements, must not be null
java.lang.IllegalArgumentException
- if the Buffer or Predicate is null
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |