com.planetj.servlet.filter.compression
Class ThresholdOutputStream
java.lang.Object
java.io.OutputStream
com.planetj.servlet.filter.compression.ThresholdOutputStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable
final class ThresholdOutputStream
- extends java.io.OutputStream
- Author:
- Sean Owen
Nested Class Summary |
(package private) static interface |
ThresholdOutputStream.BufferCommitmentCallback
Implementations of this interface are used to receive notification that this stream has either committed bytes to
the "raw" stream (without compression), or has committed bytes to a compressing stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
buffering
private boolean buffering
out1
private final java.io.OutputStream out1
out2
private java.io.OutputStream out2
compressingOutputStream
private CompressingOutputStream compressingOutputStream
compressingStreamFactory
private final CompressingStreamFactory compressingStreamFactory
context
private final CompressingFilterContext context
threshold
private final int threshold
bufferCommitmentCallback
private final ThresholdOutputStream.BufferCommitmentCallback bufferCommitmentCallback
buffer
private java.io.ByteArrayOutputStream buffer
closed
private boolean closed
forceOut1
private boolean forceOut1
ThresholdOutputStream
ThresholdOutputStream(java.io.OutputStream out1,
CompressingStreamFactory compressingStreamFactory,
CompressingFilterContext context,
ThresholdOutputStream.BufferCommitmentCallback thresholdReachedCallback)
write
public void write(int b)
throws java.io.IOException
- Specified by:
write
in class java.io.OutputStream
- Throws:
java.io.IOException
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
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
reset
void reset()
toString
@NotNull
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
continueBuffering
private boolean continueBuffering(int numAdditionalBytes)
throws java.io.IOException
- Throws:
java.io.IOException
forceOutputStream1
void forceOutputStream1()
throws java.io.IOException
- Throws:
java.io.IOException
switchToOutputStream2
void switchToOutputStream2()
throws java.io.IOException
- Throws:
java.io.IOException
flushBufferToStream
private void flushBufferToStream(java.io.OutputStream out)
throws java.io.IOException
- Throws:
java.io.IOException
checkClosed
private void checkClosed()