|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.collections.BufferUtils
public class BufferUtils
Provides utility methods and decorators for Buffer
instances.
Field Summary | |
---|---|
static Buffer |
EMPTY_BUFFER
An empty unmodifiable buffer. |
Constructor Summary | |
---|---|
BufferUtils()
BufferUtils should not normally be instantiated. |
Method Summary | ||
---|---|---|
static
|
blockingBuffer(Buffer<E> buffer)
Returns a synchronized buffer backed by the given buffer that will block on Buffer.get() and Buffer.remove() operations. |
|
static
|
predicatedBuffer(Buffer<E> buffer,
Predicate<E> predicate)
Returns a predicated (validating) buffer backed by the given buffer. |
|
static
|
synchronizedBuffer(Buffer<E> buffer)
Returns a synchronized buffer backed by the given buffer. |
|
static
|
transformedBuffer(Buffer<I> buffer,
Transformer<I,O> transformer)
Returns a transformed buffer backed by the given buffer. |
|
static
|
typedBuffer(Buffer<E> buffer,
Class<E> type)
Deprecated. No longer required with Java 1.5 Generics. |
|
static
|
unmodifiableBuffer(Buffer<E> buffer)
Returns an unmodifiable buffer backed by the given buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Buffer EMPTY_BUFFER
Constructor Detail |
---|
public BufferUtils()
BufferUtils
should not normally be instantiated.
Method Detail |
---|
public static <E> Buffer<E> synchronizedBuffer(Buffer<E> 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
IllegalArgumentException
- if the Buffer is nullpublic static <E> Buffer<E> blockingBuffer(Buffer<E> 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
IllegalArgumentException
- if the Buffer is nullpublic static <E> Buffer<E> unmodifiableBuffer(Buffer<E> buffer)
buffer
- the buffer to make unmodifiable, must not be null
IllegalArgumentException
- if the Buffer is nullpublic static <E> Buffer<E> predicatedBuffer(Buffer<E> buffer, Predicate<E> predicate)
buffer
- the buffer to predicate, must not be nullpredicate
- the predicate used to evaluate new elements, must not be null
IllegalArgumentException
- if the Buffer or Predicate is nullpublic static <E> Buffer<E> typedBuffer(Buffer<E> buffer, Class<E> type)
buffer
- the buffer to predicate, must not be nulltype
- the type to allow into the buffer, must not be null
IllegalArgumentException
- if the buffer or type is nullpublic static <I,O> Buffer<O> transformedBuffer(Buffer<I> buffer, Transformer<I,O> transformer)
buffer
- the buffer to predicate, must not be nulltransformer
- the transformer for the buffer, must not be null
IllegalArgumentException
- if the Buffer or Transformer is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |