com.planetj.servlet.filter.compression
Class CompressingServletOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by javax.servlet.ServletOutputStream
          extended by com.planetj.servlet.filter.compression.CompressingServletOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

final class CompressingServletOutputStream
extends javax.servlet.ServletOutputStream

Implementation of ServletOutputStream which will optionally compress data written to it.

Author:
Sean Owen

Nested Class Summary
private static class CompressingServletOutputStream.ResponseBufferCommitmentCallback
           
 
Field Summary
private  boolean closed
           
private  CompressingHttpServletResponse compressingResponse
           
private  CompressingStreamFactory compressingStreamFactory
           
private  CompressingFilterContext context
           
private  java.io.OutputStream rawStream
           
private  ThresholdOutputStream thresholdOutputStream
           
 
Constructor Summary
CompressingServletOutputStream(java.io.OutputStream rawStream, CompressingStreamFactory compressingStreamFactory, CompressingHttpServletResponse compressingResponse, CompressingFilterContext context)
           
 
Method Summary
(package private)  void abortCompression()
           
private  void checkClosed()
           
private  void checkWriteState()
           
 void close()
           
(package private)  void engageCompression()
           
 void flush()
           
(package private)  boolean isClosed()
           
(package private)  void reset()
           
 java.lang.String toString()
           
 void write(byte[] b)
           
 void write(byte[] b, int offset, int length)
           
 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, wait, wait, wait
 

Field Detail

rawStream

private final java.io.OutputStream rawStream

compressingStreamFactory

private final CompressingStreamFactory compressingStreamFactory

compressingResponse

private final CompressingHttpServletResponse compressingResponse

context

private final CompressingFilterContext context

thresholdOutputStream

private ThresholdOutputStream thresholdOutputStream

closed

private boolean closed
Constructor Detail

CompressingServletOutputStream

CompressingServletOutputStream(java.io.OutputStream rawStream,
                               CompressingStreamFactory compressingStreamFactory,
                               CompressingHttpServletResponse compressingResponse,
                               CompressingFilterContext context)
Method Detail

write

public void write(byte[] b)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int offset,
                  int length)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

toString

@NotNull
public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isClosed

boolean isClosed()

reset

void reset()

engageCompression

void engageCompression()
                 throws java.io.IOException
Throws:
java.io.IOException

abortCompression

void abortCompression()
                throws java.io.IOException
Throws:
java.io.IOException

checkWriteState

private void checkWriteState()

checkClosed

private void checkClosed()
                  throws java.io.IOException
Throws:
java.io.IOException