org.openqa.jetty.http
Class BufferedOutputStream
java.lang.Object
java.io.OutputStream
org.openqa.jetty.util.ByteBufferOutputStream
org.openqa.jetty.http.BufferedOutputStream
- All Implemented Interfaces:
- Closeable, Flushable, HttpMessage.HeaderWriter
- Direct Known Subclasses:
- AJP13OutputStream, ChunkingOutputStream
public class BufferedOutputStream
- extends ByteBufferOutputStream
- implements HttpMessage.HeaderWriter
Buffered Output Stream.
Uses ByteBufferOutputStream to allow pre and post writes.
- Version:
- $Revision: 1.8 $
- Author:
- Greg Wilkins (gregw)
Methods inherited from class org.openqa.jetty.util.ByteBufferOutputStream |
bufferSize, capacity, ensureCapacity, ensureReserve, ensureSize, ensureSize, ensureSpareCapacity, isFixed, postReserve, postwrite, postwrite, preReserve, prewrite, prewrite, prewrite, reset, setFixed, size, spareCapacity, write, writeTo |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_out
protected OutputStream _out
_httpMessageWriter
protected ByteArrayISO8859Writer _httpMessageWriter
BufferedOutputStream
public BufferedOutputStream(OutputStream out,
int capacity,
int headerReserve,
int preReserve,
int postReserve)
- Constructor.
- Parameters:
out
- the OutputStream to buffer to.capacity
- Buffer capacity.headerReserve
- The reserve of bytes for prepending to be used
for the first buffer after resetpreReserve
- The reserve of bytes for prependingpostReserve
- The reserve of bytes for appending
getOutputStream
public OutputStream getOutputStream()
getCommitObserver
public OutputObserver getCommitObserver()
- Returns:
- OutputObserver to receives commit events from this stream.
setCommitObserver
public void setCommitObserver(OutputObserver commitObserver)
- Parameters:
commitObserver
- OutputObserver to receives commit events from this stream.
isCommitted
public boolean isCommitted()
getBypassBuffer
public boolean getBypassBuffer()
- Returns:
- If true, the buffer is bypassed for large writes
to a committed stream.
setBypassBuffer
public void setBypassBuffer(boolean bypassBuffer)
- Parameters:
bypassBuffer
- If true, the buffer is bypassed for large writes
to a committed stream.
writeHeader
public void writeHeader(HttpMessage httpMessage)
throws IOException
- Specified by:
writeHeader
in interface HttpMessage.HeaderWriter
- Throws:
IOException
write
public void write(byte[] b)
throws IOException
- Overrides:
write
in class ByteBufferOutputStream
- Throws:
IOException
write
public void write(byte[] b,
int offset,
int length)
throws IOException
- Overrides:
write
in class ByteBufferOutputStream
- Throws:
IOException
bypassWrite
protected void bypassWrite(byte[] b,
int offset,
int length)
throws IOException
- Throws:
IOException
flush
public void flush()
throws IOException
- This implementation calls the commitObserver on the first flush since
construction or reset.
- Specified by:
flush
in interface Flushable
- Overrides:
flush
in class ByteBufferOutputStream
- Throws:
IOException
wrapBuffer
protected void wrapBuffer()
throws IOException
- Wrap Buffer.
Called by flush() to allow the data in the buffer to be pre and post
written for any protocol wrapping. The default implementation does
nothing.
- Throws:
IOException
close
public void close()
throws IOException
- Specified by:
close
in interface Closeable
- Overrides:
close
in class ByteBufferOutputStream
- Throws:
IOException
resetStream
public void resetStream()
- Overrides:
resetStream
in class ByteBufferOutputStream
destroy
public void destroy()
- Overrides:
destroy
in class ByteBufferOutputStream
Copyright © 2012. All Rights Reserved.