public class

SharedOutputBuffer

extends ExpandableBuffer
implements ContentOutputBuffer
java.lang.Object
   ↳ org.apache.http.nio.util.ExpandableBuffer
     ↳ org.apache.http.nio.util.SharedOutputBuffer

Class Overview

Implementation of the ContentOutputBuffer interface that can be shared by multiple threads, usually the I/O dispatch of an I/O reactor and a worker thread.

The I/O dispatch thread is expected to transfer data from the buffer to ContentEncoder by calling produceContent(ContentEncoder).

The worker thread is expected to write data to the buffer by calling write(int), write(byte[], int, int) or writeCompleted()

In case of an abnormal situation or when no longer needed the buffer must be shut down using shutdown() method.

Summary

[Expand]
Inherited Constants
From class org.apache.http.nio.util.ExpandableBuffer
[Expand]
Inherited Fields
From class org.apache.http.nio.util.ExpandableBuffer
Public Constructors
SharedOutputBuffer(int buffersize, IOControl ioctrl, ByteBufferAllocator allocator)
Public Methods
int available()
Returns available capacity of this buffer.
int capacity()
Returns the total capacity of this buffer.
void close()
void flush()
boolean hasData()
Determines if the buffer contains data.
int length()
Returns the length of this buffer.
int produceContent(ContentEncoder encoder)
Writes content from this buffer to the given ContentEncoder.
void reset()
Resets the buffer by clearing its state and stored content.
void shutdown()
void write(int b)
Writes the specified byte to this buffer.
void write(byte[] b, int off, int len)
Writes len bytes from the specified byte array starting at offset off to this buffer.
void write(byte[] b)
void writeCompleted()
Indicates the content has been fully written.
[Expand]
Inherited Methods
From class org.apache.http.nio.util.ExpandableBuffer
From class java.lang.Object
From interface org.apache.http.io.BufferInfo
From interface org.apache.http.nio.util.BufferInfo
From interface org.apache.http.nio.util.ContentOutputBuffer

Public Constructors

public SharedOutputBuffer (int buffersize, IOControl ioctrl, ByteBufferAllocator allocator)

Public Methods

public int available ()

Returns available capacity of this buffer.

Returns
  • buffer length.

public int capacity ()

Returns the total capacity of this buffer.

Returns
  • total capacity.

public void close ()

public void flush ()

Throws
IOException

public boolean hasData ()

Determines if the buffer contains data.

Returns
  • true if there is data in the buffer, false otherwise.

public int length ()

Returns the length of this buffer.

Returns
  • buffer length.

public int produceContent (ContentEncoder encoder)

Writes content from this buffer to the given ContentEncoder.

Parameters
encoder content encoder.
Returns
  • number of bytes written.
Throws
IOException

public void reset ()

Resets the buffer by clearing its state and stored content.

public void shutdown ()

public void write (int b)

Writes the specified byte to this buffer.

Parameters
b the byte.
Throws
IOException

public void write (byte[] b, int off, int len)

Writes len bytes from the specified byte array starting at offset off to this buffer.

If off is negative, or len is negative, or off+len is greater than the length of the array b, this method can throw a runtime exception. The exact type of runtime exception thrown by this method depends on implementation.

Parameters
b the data.
off the start offset in the data.
len the number of bytes to write.
Throws
IOException

public void write (byte[] b)

Throws
IOException

public void writeCompleted ()

Indicates the content has been fully written.

Throws
IOException