public abstract class AbstractSessionOutputBuffer extends java.lang.Object implements SessionOutputBuffer
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.
Constructor and Description |
---|
AbstractSessionOutputBuffer() |
Modifier and Type | Method and Description |
---|---|
void |
flush()
Flushes this session buffer and forces any buffered output bytes
to be written out.
|
protected void |
flushBuffer() |
HttpTransportMetrics |
getMetrics()
Returns
HttpTransportMetrics for this session buffer. |
protected void |
init(java.io.OutputStream outstream,
int buffersize,
HttpParams params)
Initializes this session output buffer.
|
void |
write(byte[] b)
Writes
b.length bytes from the specified byte array
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(int b)
Writes the specified byte 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(java.lang.String s)
Writes characters from the specified string followed by a line delimiter
to this session buffer.
|
protected void init(java.io.OutputStream outstream, int buffersize, HttpParams params)
The following HTTP parameters affect the initialization:
The CoreProtocolPNames.HTTP_ELEMENT_CHARSET
parameter determines the charset to be used for encoding HTTP lines. If
not specified, US-ASCII
will be used per default.
outstream
- the destination output stream.buffersize
- the size of the internal buffer.params
- HTTP parameters.CoreProtocolPNames.HTTP_ELEMENT_CHARSET
protected void flushBuffer() throws java.io.IOException
java.io.IOException
public void flush() throws java.io.IOException
SessionOutputBuffer
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.flush
in interface SessionOutputBuffer
java.io.IOException
- if an I/O error occurs.public void write(byte[] b, int off, int len) throws java.io.IOException
SessionOutputBuffer
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.
write
in interface SessionOutputBuffer
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.java.io.IOException
- if an I/O error occurs.public void write(byte[] b) throws java.io.IOException
SessionOutputBuffer
b.length
bytes from the specified byte array
to this session buffer.write
in interface SessionOutputBuffer
b
- the data.java.io.IOException
- if an I/O error occurs.public void write(int b) throws java.io.IOException
SessionOutputBuffer
write
in interface SessionOutputBuffer
b
- the byte
.java.io.IOException
- if an I/O error occurs.public void writeLine(java.lang.String s) throws java.io.IOException
This method uses CR-LF as a line delimiter.
writeLine
in interface SessionOutputBuffer
s
- the line.java.io.IOException
- if an I/O error occurs.public void writeLine(CharArrayBuffer s) throws java.io.IOException
This method uses CR-LF as a line delimiter.
writeLine
in interface SessionOutputBuffer
s
- the buffer containing chars of the line.java.io.IOException
- if an I/O error occurs.public HttpTransportMetrics getMetrics()
SessionOutputBuffer
HttpTransportMetrics
for this session buffer.getMetrics
in interface SessionOutputBuffer