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

java.lang.Object
  extended by java.io.Writer
      extended by org.glassfish.grizzly.http.server.io.NIOWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, NIOOutputSink

public class NIOWriter
extends Writer
implements NIOOutputSink

Stream implementation for writing character content to an HTTP user-agent.

Since:
2.0

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
NIOWriter(OutputBuffer outputBuffer)
           
 
Method Summary
 boolean canWrite(int length)
           
 void close()
          
 void flush()
          
 boolean notifyCanWrite(WriteHandler handler, int length)
          Instructs the NIOOutputSink to invoke the provided WriteHandler when it is possible to write length characters.
 void write(char[] cbuf)
          
 void write(char[] cbuf, int off, int len)
          
 void write(int c)
          
 void write(String str)
          
 void write(String str, int off, int len)
          
 
Methods inherited from class java.io.Writer
append, append, append
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NIOWriter

public NIOWriter(OutputBuffer outputBuffer)
Method Detail

write

public void write(int c)
           throws IOException

Overrides:
write in class Writer
Throws:
IOException

write

public void write(char[] cbuf)
           throws IOException

Overrides:
write in class Writer
Throws:
IOException

write

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

Specified by:
write in class Writer
Throws:
IOException

write

public void write(String str)
           throws IOException

Overrides:
write in class Writer
Throws:
IOException

write

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

Overrides:
write in class Writer
Throws:
IOException

flush

public void flush()
           throws IOException

Specified by:
flush in interface Flushable
Specified by:
flush in class Writer
Throws:
IOException

close

public void close()
           throws IOException

Specified by:
close in interface Closeable
Specified by:
close in class Writer
Throws:
IOException

canWrite

public boolean canWrite(int length)
Specified by:
canWrite in interface NIOOutputSink
Parameters:
length - specifies the number of characters that require writing
Returns:
true if a write to this NIOOutputSink will succeed, otherwise returns false.

notifyCanWrite

public boolean notifyCanWrite(WriteHandler handler,
                              int length)
Instructs the NIOOutputSink to invoke the provided WriteHandler when it is possible to write length characters.

Specified by:
notifyCanWrite in interface NIOOutputSink
Parameters:
handler - the WriteHandler that should be notified when it's possible to write length characters.
length - the number of characters that require writing.
Returns:
true if the specified handler has been accepted and will be notified as it becomes possible to write, otherwise returns false which means data is currently available to write without blocking.


Copyright © 2010 Oracle Corpration. All Rights Reserved.