com.caucho.server.connection
Class AbstractResponseStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.caucho.vfs.OutputStreamWithBuffer
          extended by com.caucho.server.connection.AbstractResponseStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
BodyResponseStream, ToByteResponseStream, ToCharResponseStream, WrapperResponseStream

public abstract class AbstractResponseStream
extends OutputStreamWithBuffer

API for handling the PrintWriter/ServletOutputStream


Constructor Summary
AbstractResponseStream()
           
 
Method Summary
 void clear()
          Clears the output buffer, including headers if possible.
abstract  void clearBuffer()
          Clears the output buffer.
 void clearClosed()
          Clears the close
 void close()
          Closes the response stream
 void finish()
          Finishes the response stream
 void flush()
          Flushes the output.
abstract  void flushBuffer()
          Flushes the output buffer.
 void flushByte()
          Flushes the output.
 void flushChar()
          Flushes the output.
abstract  int getBufferSize()
          Gets the buffer size.
abstract  char[] getCharBuffer()
          Returns the char buffer.
abstract  int getCharOffset()
          Returns the char buffer offset.
 int getContentLength()
          Returns the written content length
abstract  int getRemaining()
          Returns the remaining buffer entries.
 boolean isAutoFlush()
          Return the auto-flush.
abstract  boolean isCauchoResponseStream()
          Returns true for a Caucho response stream.
 boolean isCommitted()
          Returns true if the response is committed.
 boolean isHead()
          Set true for HEAD requests.
abstract  char[] nextCharBuffer(int offset)
          Returns the next char buffer.
abstract  void print(char[] buffer, int offset, int length)
          Writes a char array to the output.
abstract  void print(int ch)
          Writes a character to the output.
 void sendFile(Path path, long length)
          Sends a file.
 void setAutoFlush(boolean isAutoFlush)
          Sets the auto-flush
abstract  void setBufferSize(int size)
          Sets the buffer size.
 void setByteCacheStream(java.io.OutputStream cacheStream)
          Sets a byte cache stream.
 void setCharCacheStream(java.io.Writer cacheStream)
          Sets a char cache stream.
abstract  void setCharOffset(int offset)
          Sets the char buffer offset.
 void setEncoding(java.lang.String encoding)
          Sets the encoding.
 void setHead()
          Set true for HEAD requests.
 void setLocale(java.util.Locale locale)
          Sets the locale.
 void setOutputStreamOnly(boolean isOutputStreamOnly)
          Set true for output stream only request.
 void start()
          Starts the response stream.
abstract  void write(byte[] buffer, int offset, int length)
          Writes a byte array to the output.
abstract  void write(int v)
          Writes a byte to the output.
 
Methods inherited from class com.caucho.vfs.OutputStreamWithBuffer
getBuffer, getBufferOffset, nextBuffer, setBufferOffset
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractResponseStream

public AbstractResponseStream()
Method Detail

start

public void start()
Starts the response stream.


isCauchoResponseStream

public abstract boolean isCauchoResponseStream()
Returns true for a Caucho response stream.


setEncoding

public void setEncoding(java.lang.String encoding)
                 throws java.io.UnsupportedEncodingException
Sets the encoding.

Throws:
java.io.UnsupportedEncodingException

setOutputStreamOnly

public void setOutputStreamOnly(boolean isOutputStreamOnly)
Set true for output stream only request.


setLocale

public void setLocale(java.util.Locale locale)
               throws java.io.UnsupportedEncodingException
Sets the locale.

Throws:
java.io.UnsupportedEncodingException

setBufferSize

public abstract void setBufferSize(int size)
Sets the buffer size.


getBufferSize

public abstract int getBufferSize()
Gets the buffer size.


setAutoFlush

public void setAutoFlush(boolean isAutoFlush)
Sets the auto-flush


isAutoFlush

public boolean isAutoFlush()
Return the auto-flush.


getRemaining

public abstract int getRemaining()
Returns the remaining buffer entries.


getCharBuffer

public abstract char[] getCharBuffer()
                              throws java.io.IOException
Returns the char buffer.

Throws:
java.io.IOException

getCharOffset

public abstract int getCharOffset()
                           throws java.io.IOException
Returns the char buffer offset.

Throws:
java.io.IOException

setCharOffset

public abstract void setCharOffset(int offset)
                            throws java.io.IOException
Sets the char buffer offset.

Throws:
java.io.IOException

nextCharBuffer

public abstract char[] nextCharBuffer(int offset)
                               throws java.io.IOException
Returns the next char buffer.

Throws:
java.io.IOException

isCommitted

public boolean isCommitted()
Returns true if the response is committed.


setHead

public void setHead()
Set true for HEAD requests.


isHead

public boolean isHead()
Set true for HEAD requests.


setByteCacheStream

public void setByteCacheStream(java.io.OutputStream cacheStream)
Sets a byte cache stream.


setCharCacheStream

public void setCharCacheStream(java.io.Writer cacheStream)
Sets a char cache stream.


getContentLength

public int getContentLength()
Returns the written content length


write

public abstract void write(int v)
                    throws java.io.IOException
Writes a byte to the output.

Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public abstract void write(byte[] buffer,
                           int offset,
                           int length)
                    throws java.io.IOException
Writes a byte array to the output.

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

print

public abstract void print(int ch)
                    throws java.io.IOException
Writes a character to the output.

Throws:
java.io.IOException

print

public abstract void print(char[] buffer,
                           int offset,
                           int length)
                    throws java.io.IOException
Writes a char array to the output.

Throws:
java.io.IOException

clear

public void clear()
           throws java.io.IOException
Clears the output buffer, including headers if possible.

Throws:
java.io.IOException

clearBuffer

public abstract void clearBuffer()
Clears the output buffer.


flushBuffer

public abstract void flushBuffer()
                          throws java.io.IOException
Flushes the output buffer.

Throws:
java.io.IOException

flushByte

public void flushByte()
               throws java.io.IOException
Flushes the output.

Throws:
java.io.IOException

flushChar

public void flushChar()
               throws java.io.IOException
Flushes the output.

Throws:
java.io.IOException

sendFile

public void sendFile(Path path,
                     long length)
              throws java.io.IOException
Sends a file.

Parameters:
path - the path to the file
length - the length of the file (-1 if unknown)
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Flushes the output.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

finish

public void finish()
            throws java.io.IOException
Finishes the response stream

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes the response stream

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

clearClosed

public void clearClosed()
                 throws java.io.IOException
Clears the close

Throws:
java.io.IOException