Class CompressionResponseStream

java.lang.Object
java.io.OutputStream
jakarta.servlet.ServletOutputStream
org.jumpmind.symmetric.web.compression.CompressionResponseStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class CompressionResponseStream extends jakarta.servlet.ServletOutputStream
Implementation of ServletOutputStream that works with the CompressionServletResponseWrapper implementation. This package is derived from the Jakarta Tomcat examples compression filter and is distributed in SymmetricDS for convenience.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Has this stream been closed?
    protected OutputStream
    The underlying gzip output stream to which we should write data.
    protected jakarta.servlet.http.HttpServletResponse
    The response with which this servlet output stream is associated.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CompressionResponseStream(jakarta.servlet.http.HttpServletResponse response, int compressionLevel, int compressionStrategy)
    Construct a servlet output stream associated with the specified Response.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close this output stream, causing any buffered data to be flushed and any further output data to throw an IOException.
    boolean
    Has this response stream been closed?
    void
    Flush any buffered data for this output stream, which also causes the response to be committed.
    boolean
     
    void
    setWriteListener(jakarta.servlet.WriteListener writeListener)
     
    void
    write(byte[] b)
    Write b.length bytes from the specified byte array to our output stream.
    void
    write(byte[] b, int off, int len)
    Write len bytes from the specified byte array, starting at the specified offset, to our output stream.
    void
    write(int b)
    Write the specified byte to our output stream.

    Methods inherited from class jakarta.servlet.ServletOutputStream

    print, print, print, print, print, print, print, println, println, println, println, println, println, println, println

    Methods inherited from class java.io.OutputStream

    nullOutputStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • gzipstream

      protected OutputStream gzipstream
      The underlying gzip output stream to which we should write data.
    • closed

      protected boolean closed
      Has this stream been closed?
    • response

      protected jakarta.servlet.http.HttpServletResponse response
      The response with which this servlet output stream is associated.
  • Constructor Details

    • CompressionResponseStream

      public CompressionResponseStream(jakarta.servlet.http.HttpServletResponse response, int compressionLevel, int compressionStrategy) throws IOException
      Construct a servlet output stream associated with the specified Response.
      Parameters:
      response - The associated response
      Throws:
      IOException
  • Method Details

    • close

      public void close() throws IOException
      Close this output stream, causing any buffered data to be flushed and any further output data to throw an IOException.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException
    • flush

      public void flush() throws IOException
      Flush any buffered data for this output stream, which also causes the response to be committed.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException
    • write

      public void write(int b) throws IOException
      Write the specified byte to our output stream.
      Specified by:
      write in class OutputStream
      Parameters:
      b - The byte to be written
      Throws:
      IOException - if an input/output error occurs
    • write

      public void write(byte[] b) throws IOException
      Write b.length bytes from the specified byte array to our output stream.
      Overrides:
      write in class OutputStream
      Parameters:
      b - The byte array to be written
      Throws:
      IOException - if an input/output error occurs
    • write

      public void write(byte[] b, int off, int len) throws IOException
      Write len bytes from the specified byte array, starting at the specified offset, to our output stream.
      Overrides:
      write in class OutputStream
      Parameters:
      b - The byte array containing the bytes to be written
      off - Zero-relative starting offset of the bytes to be written
      len - The number of bytes to be written
      Throws:
      IOException - if an input/output error occurs
    • isReady

      public boolean isReady()
      Specified by:
      isReady in class jakarta.servlet.ServletOutputStream
    • closed

      public boolean closed()
      Has this response stream been closed?
    • setWriteListener

      public void setWriteListener(jakarta.servlet.WriteListener writeListener)
      Specified by:
      setWriteListener in class jakarta.servlet.ServletOutputStream