public class

SynchronizedBuffer

extends SynchronizedCollection
implements Buffer
java.lang.Object
   ↳ org.apache.commons.collections.collection.SynchronizedCollection
     ↳ org.apache.commons.collections.buffer.SynchronizedBuffer
Known Direct Subclasses

Class Overview

Decorates another Buffer to synchronize its behaviour for a multi-threaded environment.

Methods are synchronized, then forwarded to the decorated buffer.

This class is Serializable from Commons Collections 3.1.

Summary

[Expand]
Inherited Fields
From class org.apache.commons.collections.collection.SynchronizedCollection
Protected Constructors
SynchronizedBuffer(Buffer buffer)
Constructor that wraps (not copies).
SynchronizedBuffer(Buffer buffer, Object lock)
Constructor that wraps (not copies).
Public Methods
static Buffer decorate(Buffer buffer)
Factory method to create a synchronized buffer.
Object get()
Gets the next object from the buffer without removing it.
Object remove()
Gets and removes the next object from the buffer.
Protected Methods
Buffer getBuffer()
Gets the buffer being decorated.
[Expand]
Inherited Methods
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.Buffer

Protected Constructors

protected SynchronizedBuffer (Buffer buffer)

Constructor that wraps (not copies).

Parameters
buffer the buffer to decorate, must not be null
Throws
IllegalArgumentException if the buffer is null

protected SynchronizedBuffer (Buffer buffer, Object lock)

Constructor that wraps (not copies).

Parameters
buffer the buffer to decorate, must not be null
lock the lock object to use, must not be null
Throws
IllegalArgumentException if the buffer is null

Public Methods

public static Buffer decorate (Buffer buffer)

Factory method to create a synchronized buffer.

Parameters
buffer the buffer to decorate, must not be null
Returns
  • a new synchronized Buffer
Throws
IllegalArgumentException if buffer is null

public Object get ()

Gets the next object from the buffer without removing it.

Returns
  • the next object in the buffer, which is not removed

public Object remove ()

Gets and removes the next object from the buffer.

Returns
  • the next object in the buffer, which is also removed

Protected Methods

protected Buffer getBuffer ()

Gets the buffer being decorated.

Returns
  • the decorated buffer