Class PageOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- javax.servlet.ServletOutputStream
-
- com.opensymphony.module.sitemesh.filter.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 fromgetBuffer(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)
-
-
-
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
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
discardBuffer
public void discardBuffer()
- Specified by:
discardBuffer
in interfaceOutputBuffer
-
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 interfaceOutputBuffer
- Parameters:
encoding
- The encoding to use for decoding the buffer
-
flush
public void flush()
- Specified by:
flush
in interfacejava.io.Flushable
- Specified by:
flush
in interfaceOutputBuffer
- Overrides:
flush
in classjava.io.OutputStream
-
-