public abstract class

AbstractSessionOutputBuffer

extends Object
implements BufferInfo SessionOutputBuffer
java.lang.Object
   ↳ org.apache.http.impl.io.AbstractSessionOutputBuffer
Known Direct Subclasses

Class Overview

Abstract base class for session output buffers that stream data to an arbitrary OutputStream. This class buffers small chunks of output data in an internal byte array for optimal output performance.

writeLine(CharArrayBuffer) and writeLine(String) methods of this class use CR-LF as a line delimiter.

The following parameters can be used to customize the behavior of this class:

Summary

Public Constructors
AbstractSessionOutputBuffer()
Public Methods
int available()
Returns available space in the buffer.
int capacity()
Returns total capacity of the buffer
void flush()
Flushes this session buffer and forces any buffered output bytes to be written out.
HttpTransportMetrics getMetrics()
Returns HttpTransportMetrics for this session buffer.
int length()
Return length data stored in the buffer
void write(int b)
Writes the specified byte to this session buffer.
void write(byte[] b, int off, int len)
Writes len bytes from the specified byte array starting at offset off to this session buffer.
void write(byte[] b)
Writes b.length bytes from the specified byte array to this session buffer.
void writeLine(CharArrayBuffer s)
Writes characters from the specified char array followed by a line delimiter to this session buffer.
void writeLine(String s)
Writes characters from the specified string followed by a line delimiter to this session buffer.
Protected Methods
HttpTransportMetricsImpl createTransportMetrics()
void flushBuffer()
void init(OutputStream outstream, int buffersize, HttpParams params)
Initializes this session output buffer.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.io.BufferInfo
From interface org.apache.http.io.SessionOutputBuffer

Public Constructors

public AbstractSessionOutputBuffer ()

Public Methods

public int available ()

Returns available space in the buffer.

Returns
  • available space.

public int capacity ()

Returns total capacity of the buffer

Returns
  • total capacity

public void flush ()

Flushes this session buffer and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

Throws
IOException

public HttpTransportMetrics getMetrics ()

Returns HttpTransportMetrics for this session buffer.

Returns
  • transport metrics.

public int length ()

Return length data stored in the buffer

Returns
  • data length

public void write (int b)

Writes the specified byte to this session 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 session buffer.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

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)

Writes b.length bytes from the specified byte array to this session buffer.

Parameters
b the data.
Throws
IOException

public void writeLine (CharArrayBuffer s)

Writes characters from the specified char array followed by a line delimiter to this session buffer.

This method uses CR-LF as a line delimiter.

Parameters
s the buffer containing chars of the line.
Throws
IOException if an I/O error occurs.

public void writeLine (String s)

Writes characters from the specified string followed by a line delimiter to this session buffer.

This method uses CR-LF as a line delimiter.

Parameters
s the line.
Throws
IOException if an I/O error occurs.

Protected Methods

protected HttpTransportMetricsImpl createTransportMetrics ()

protected void flushBuffer ()

Throws
IOException

protected void init (OutputStream outstream, int buffersize, HttpParams params)

Initializes this session output buffer.

Parameters
outstream the destination output stream.
buffersize the size of the internal buffer.
params HTTP parameters.