|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
javax.servlet.ServletOutputStream
org.eclipse.jetty.http.gzip.AbstractCompressedStream
public abstract class AbstractCompressedStream
Skeletal implementation of a CompressedStream. This class adds compression features to a ServletOutputStream and takes care of setting response headers, etc. Major work and configuration is done here. Subclasses using different kinds of compression only have to implement the abstract methods doCompress() and setContentEncoding() using the desired compression and setting the appropriate Content-Encoding header string.
Field Summary | |
---|---|
protected ByteArrayOutputStream2 |
_bOut
|
protected int |
_bufferSize
|
protected boolean |
_closed
|
protected java.util.zip.DeflaterOutputStream |
_compressedOutputStream
|
protected long |
_contentLength
|
protected boolean |
_doNotCompress
|
protected int |
_minCompressSize
|
protected java.io.OutputStream |
_out
|
protected javax.servlet.http.HttpServletRequest |
_request
|
protected javax.servlet.http.HttpServletResponse |
_response
|
Constructor Summary | |
---|---|
AbstractCompressedStream(java.lang.String encoding,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
long contentLength,
int bufferSize,
int minCompressSize)
Instantiates a new compressed stream. |
Method Summary | |
---|---|
void |
close()
|
protected abstract java.util.zip.DeflaterOutputStream |
createStream()
Create the stream fitting to the underlying compression type. |
void |
doCompress()
Do compress. |
void |
doNotCompress()
Do not compress. |
void |
finish()
Finish. |
void |
flush()
|
java.io.OutputStream |
getOutputStream()
|
boolean |
isClosed()
|
protected java.io.PrintWriter |
newWriter(java.io.OutputStream out,
java.lang.String encoding)
Allows derived implementations to replace PrintWriter implementation. |
void |
resetBuffer()
Reset buffer. |
void |
setContentLength(long length)
Sets the content length. |
protected void |
setHeader(java.lang.String name,
java.lang.String value)
|
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
Methods inherited from class javax.servlet.ServletOutputStream |
---|
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected javax.servlet.http.HttpServletRequest _request
protected javax.servlet.http.HttpServletResponse _response
protected java.io.OutputStream _out
protected ByteArrayOutputStream2 _bOut
protected java.util.zip.DeflaterOutputStream _compressedOutputStream
protected boolean _closed
protected int _bufferSize
protected int _minCompressSize
protected long _contentLength
protected boolean _doNotCompress
Constructor Detail |
---|
public AbstractCompressedStream(java.lang.String encoding, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, long contentLength, int bufferSize, int minCompressSize) throws java.io.IOException
request
- the requestresponse
- the responsecontentLength
- the content lengthbufferSize
- the buffer sizeminCompressSize
- the min compress size
java.io.IOException
- Signals that an I/O exception has occurred.Method Detail |
---|
public void resetBuffer()
public void setContentLength(long length)
length
- the new content lengthpublic void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
OutputStream.flush()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.OutputStream
java.io.IOException
OutputStream.close()
public void finish() throws java.io.IOException
java.io.IOException
- Signals that an I/O exception has occurred.public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
OutputStream.write(int)
public void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
OutputStream.write(byte[])
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
OutputStream.write(byte[], int, int)
public void doCompress() throws java.io.IOException
java.io.IOException
- Signals that an I/O exception has occurred.public void doNotCompress() throws java.io.IOException
java.io.IOException
- Signals that an I/O exception has occurred.public java.io.OutputStream getOutputStream()
org.eclipse.jetty.http.gzip.CompressedStream#getOutputStream()
public boolean isClosed()
org.eclipse.jetty.http.gzip.CompressedStream#isClosed()
protected java.io.PrintWriter newWriter(java.io.OutputStream out, java.lang.String encoding) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
protected void setHeader(java.lang.String name, java.lang.String value)
protected abstract java.util.zip.DeflaterOutputStream createStream() throws java.io.IOException
java.io.IOException
- Signals that an I/O exception has occurred.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |