Class PageOutputStream

  • All Implemented Interfaces:
    OutputBuffer, java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class PageOutputStream
    extends javax.servlet.ServletOutputStream
    implements OutputBuffer
    Implementation of ServletOutputStream that stores all data written to it in a temporary buffer accessible from getBuffer(java.lang.String) .
    Version:
    $Revision: 1.4 $
    Author:
    Scott Farquhar, Hani Suleiman
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.ByteArrayOutputStream buffer  
      private static java.lang.String DEFAULT_ENCODING  
      private static boolean JDK14  
      private javax.servlet.ServletResponse response
      The reason we use a response, rather than just getting the outputstream directly is that under Tomcat, when serving static resources, we need to avoid calling getOutputStream() if we are going to use a decorator.
      private java.io.OutputStream target  
    • Constructor Summary

      Constructors 
      Constructor Description
      PageOutputStream​(javax.servlet.ServletResponse response)
      Construct an OutputStream that will buffer the content written to it.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void discardBuffer()  
      void flush()  
      char[] get14Buffer​(java.lang.String encoding)  
      char[] getBuffer​(java.lang.String encoding)  
      private static char[] trim​(char[] ca, 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.io.OutputStream

        close, nullOutputStream, write, write
      • Methods inherited from class java.lang.Object

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

      • buffer

        private java.io.ByteArrayOutputStream buffer
      • target

        private java.io.OutputStream target
      • DEFAULT_ENCODING

        private static final java.lang.String DEFAULT_ENCODING
      • JDK14

        private static final boolean JDK14
      • response

        private final javax.servlet.ServletResponse response
        The reason we use a response, rather than just getting the outputstream directly is that under Tomcat, when serving static resources, we need to avoid calling getOutputStream() if we are going to use a decorator.

        More information: http://marc.theaimsgroup.com/?l=tomcat-user&m=107569601410973&w=2, SIM-74, SIM-82

    • Constructor Detail

      • PageOutputStream

        public PageOutputStream​(javax.servlet.ServletResponse response)
        Construct an OutputStream that will buffer the content written to it.
    • Method Detail

      • write

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

        public char[] get14Buffer​(java.lang.String encoding)
      • trim

        private static char[] trim​(char[] ca,
                                   int len)
      • getBuffer

        public char[] getBuffer​(java.lang.String encoding)
        Specified by:
        getBuffer in interface OutputBuffer
        Parameters:
        encoding - The encoding to use for decoding the buffer
      • flush

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