From 45240293533636c8603532a3ac8b05ecc7df03e6 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Tue, 15 Sep 2009 05:56:16 +0000 Subject: [PATCH] Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: ------------------------------------------------------------------------ r471166 | scolebourne | 2006-11-04 03:33:22 -0800 (Sat, 04 Nov 2006) | 1 line Removed Typed* containers such as TypedList and TypedMap as generics now provides type safety ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815033 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/collections/BufferUtils.java | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/src/java/org/apache/commons/collections/BufferUtils.java b/src/java/org/apache/commons/collections/BufferUtils.java index df57a6d94..3edf6f5e0 100644 --- a/src/java/org/apache/commons/collections/BufferUtils.java +++ b/src/java/org/apache/commons/collections/BufferUtils.java @@ -17,12 +17,11 @@ package org.apache.commons.collections; import org.apache.commons.collections.buffer.BlockingBuffer; +import org.apache.commons.collections.buffer.BoundedBuffer; import org.apache.commons.collections.buffer.PredicatedBuffer; import org.apache.commons.collections.buffer.SynchronizedBuffer; import org.apache.commons.collections.buffer.TransformedBuffer; -import org.apache.commons.collections.buffer.TypedBuffer; import org.apache.commons.collections.buffer.UnmodifiableBuffer; -import org.apache.commons.collections.buffer.BoundedBuffer; /** * Provides utility methods and decorators for {@link Buffer} instances. @@ -38,7 +37,7 @@ public class BufferUtils { /** * An empty unmodifiable buffer. */ - public static final Buffer EMPTY_BUFFER = UnmodifiableBuffer.decorate(new ArrayStack(1)); + public static final Buffer EMPTY_BUFFER = UnmodifiableBuffer.decorate(new ArrayStack(1)); /** * BufferUtils should not normally be instantiated. @@ -67,7 +66,7 @@ public class BufferUtils { * @return a synchronized buffer backed by that buffer * @throws IllegalArgumentException if the Buffer is null */ - public static Buffer synchronizedBuffer(Buffer buffer) { + public static Buffer synchronizedBuffer(Buffer buffer) { return SynchronizedBuffer.decorate(buffer); } @@ -83,7 +82,7 @@ public class BufferUtils { * @return a blocking buffer backed by that buffer * @throws IllegalArgumentException if the Buffer is null */ - public static Buffer blockingBuffer(Buffer buffer) { + public static Buffer blockingBuffer(Buffer buffer) { return BlockingBuffer.decorate(buffer); } @@ -101,7 +100,7 @@ public class BufferUtils { * @throws IllegalArgumentException if the Buffer is null * @since Commons Collections 3.2 */ - public static Buffer blockingBuffer(Buffer buffer, long timeoutMillis) { + public static Buffer blockingBuffer(Buffer buffer, long timeoutMillis) { return BlockingBuffer.decorate(buffer, timeoutMillis); } @@ -118,7 +117,7 @@ public class BufferUtils { * @throws IllegalArgumentException if the given buffer is null * @since Commons Collections 3.2 */ - public static Buffer boundedBuffer(Buffer buffer, int maximumSize) { + public static Buffer boundedBuffer(Buffer buffer, int maximumSize) { return BoundedBuffer.decorate(buffer, maximumSize); } @@ -136,7 +135,7 @@ public class BufferUtils { * @throws IllegalArgumentException if the given buffer is null * @since Commons Collections 3.2 */ - public static Buffer boundedBuffer(Buffer buffer, int maximumSize, long timeoutMillis) { + public static Buffer boundedBuffer(Buffer buffer, int maximumSize, long timeoutMillis) { return BoundedBuffer.decorate(buffer, maximumSize, timeoutMillis); } @@ -147,7 +146,7 @@ public class BufferUtils { * @return an unmodifiable buffer backed by that buffer * @throws IllegalArgumentException if the Buffer is null */ - public static Buffer unmodifiableBuffer(Buffer buffer) { + public static Buffer unmodifiableBuffer(Buffer buffer) { return UnmodifiableBuffer.decorate(buffer); } @@ -164,24 +163,10 @@ public class BufferUtils { * @return a predicated buffer * @throws IllegalArgumentException if the Buffer or Predicate is null */ - public static Buffer predicatedBuffer(Buffer buffer, Predicate predicate) { + public static Buffer predicatedBuffer(Buffer buffer, Predicate predicate) { return PredicatedBuffer.decorate(buffer, predicate); } - /** - * Returns a typed buffer backed by the given buffer. - *

- * Only elements of the specified type can be added to the buffer. - * - * @param buffer the buffer to predicate, must not be null - * @param type the type to allow into the buffer, must not be null - * @return a typed buffer - * @throws IllegalArgumentException if the buffer or type is null - */ - public static Buffer typedBuffer(Buffer buffer, Class type) { - return TypedBuffer.decorate(buffer, type); - } - /** * Returns a transformed buffer backed by the given buffer. *

@@ -197,8 +182,17 @@ public class BufferUtils { * @return a transformed buffer backed by the given buffer * @throws IllegalArgumentException if the Buffer or Transformer is null */ - public static Buffer transformedBuffer(Buffer buffer, Transformer transformer) { + public static Buffer transformedBuffer(Buffer buffer, Transformer transformer) { return TransformedBuffer.decorate(buffer, transformer); } + /** + * Get an empty Buffer. + * @param + * @return Buffer + */ + @SuppressWarnings("unchecked") + public static Buffer emptyBuffer() { + return (Buffer) EMPTY_BUFFER; + } }