org.glassfish.grizzly.http.server.io
Class OutputBuffer

java.lang.Object
  extended by org.glassfish.grizzly.http.server.io.OutputBuffer

public class OutputBuffer
extends Object

Abstraction exposing both byte and character methods to write content to the HTTP messaging system in Grizzly.


Constructor Summary
OutputBuffer()
           
 
Method Summary
 void acknowledge()
          Acknowledge a HTTP Expect header.
 boolean canWrite(int length)
           
 boolean canWriteChar(int length)
           
 void close()
           
 void endRequest()
           
 void flush()
          Flush the response.
 int getBufferSize()
           
 void initialize(HttpResponsePacket response, FilterChainContext ctx)
           
 void notifyCanWrite(WriteHandler handler, int length)
           
 void processingChars()
           
 void recycle()
          Recycle the output buffer.
 void reset()
          Reset current response.
 void setBufferSize(int bufferSize)
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(char[] cbuf)
           
 void write(char[] cbuf, int off, int len)
           
 void write(String str)
           
 void write(String str, int off, int len)
           
 void writeBuffer(Buffer buffer)
           Writes the contents of the specified Buffer to the client.
 void writeByte(int b)
           
 void writeByteBuffer(ByteBuffer byteBuffer)
           Writes the contents of the specified ByteBuffer to the client.
 void writeChar(int c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputBuffer

public OutputBuffer()
Method Detail

initialize

public void initialize(HttpResponsePacket response,
                       FilterChainContext ctx)

processingChars

public void processingChars()

getBufferSize

public int getBufferSize()

setBufferSize

public void setBufferSize(int bufferSize)

reset

public void reset()
Reset current response.

Throws:
IllegalStateException - if the response has already been committed

recycle

public void recycle()
Recycle the output buffer. This should be called when closing the connection.


endRequest

public void endRequest()
                throws IOException
Throws:
IOException

acknowledge

public void acknowledge()
                 throws IOException
Acknowledge a HTTP Expect header. The response status code and reason phrase should be set before invoking this method.

Throws:
IOException - if an error occurs writing the acknowledgment.

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
Throws:
IOException

writeChar

public void writeChar(int c)
               throws IOException
Throws:
IOException

write

public void write(char[] cbuf)
           throws IOException
Throws:
IOException

write

public void write(String str)
           throws IOException
Throws:
IOException

write

public void write(String str,
                  int off,
                  int len)
           throws IOException
Throws:
IOException

writeByte

public void writeByte(int b)
               throws IOException
Throws:
IOException

write

public void write(byte[] b)
           throws IOException
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Throws:
IOException

flush

public void flush()
           throws IOException
Flush the response.

Throws:
IOException - an underlying I/O error occurred

writeByteBuffer

public void writeByteBuffer(ByteBuffer byteBuffer)
                     throws IOException

Writes the contents of the specified ByteBuffer to the client.

Note, that passed ByteBuffer will be directly used by underlying connection, so it could be reused only if it has been flushed.

Parameters:
byteBuffer - the ByteBuffer to write
Throws:
IOException - if an error occurs during the write

writeBuffer

public void writeBuffer(Buffer buffer)
                 throws IOException

Writes the contents of the specified Buffer to the client.

Note, that passed Buffer will be directly used by underlying connection, so it could be reused only if it has been flushed.

Parameters:
buffer - the ByteBuffer to write
Throws:
IOException - if an error occurs during the write

canWriteChar

public boolean canWriteChar(int length)

canWrite

public boolean canWrite(int length)
See Also:
AsyncQueueWriter.canWrite(org.glassfish.grizzly.Connection, int)

notifyCanWrite

public void notifyCanWrite(WriteHandler handler,
                           int length)


Copyright © 2011 Oracle Corpration. All Rights Reserved.