net.i2p.client.streaming
Class MessageOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by net.i2p.client.streaming.MessageOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class MessageOutputStream
extends java.io.OutputStream

A stream that we can shove data into that fires off those bytes on flush or when the buffer is full. It also blocks according to the data receiver's needs.


Nested Class Summary
static interface MessageOutputStream.DataReceiver
          Define a component to receive data flushed from this stream
static interface MessageOutputStream.WriteStatus
          Define a way to detect the status of a write
 
Constructor Summary
MessageOutputStream(I2PAppContext ctx, MessageOutputStream.DataReceiver receiver)
           
MessageOutputStream(I2PAppContext ctx, MessageOutputStream.DataReceiver receiver, int bufSize)
           
MessageOutputStream(I2PAppContext ctx, MessageOutputStream.DataReceiver receiver, int bufSize, int passiveFlushDelay)
           
 
Method Summary
 void close()
           
 void closeInternal()
          nonblocking close
(package private)  void destroy()
           
 void flush()
          Flush the data already queued up, blocking until it has been delivered.
(package private)  void flushAvailable(MessageOutputStream.DataReceiver target)
          called whenever the engine wants to push more data to the peer
(package private)  void flushAvailable(MessageOutputStream.DataReceiver target, boolean blocking)
           
 boolean getClosed()
           
 int getWriteTimeout()
           
 void setBufferSize(int size)
           
 void setWriteTimeout(int ms)
           
(package private)  void streamErrorOccurred(java.io.IOException ioe)
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageOutputStream

public MessageOutputStream(I2PAppContext ctx,
                           MessageOutputStream.DataReceiver receiver)

MessageOutputStream

public MessageOutputStream(I2PAppContext ctx,
                           MessageOutputStream.DataReceiver receiver,
                           int bufSize)

MessageOutputStream

public MessageOutputStream(I2PAppContext ctx,
                           MessageOutputStream.DataReceiver receiver,
                           int bufSize,
                           int passiveFlushDelay)
Method Detail

setWriteTimeout

public void setWriteTimeout(int ms)

getWriteTimeout

public int getWriteTimeout()

setBufferSize

public void setBufferSize(int size)

write

public void write(byte[] b)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

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

flush

public void flush()
           throws java.io.IOException
Flush the data already queued up, blocking until it has been delivered.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - if the write fails

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

closeInternal

public void closeInternal()
nonblocking close


getClosed

public boolean getClosed()

streamErrorOccurred

void streamErrorOccurred(java.io.IOException ioe)

flushAvailable

void flushAvailable(MessageOutputStream.DataReceiver target)
              throws java.io.IOException
called whenever the engine wants to push more data to the peer

Throws:
java.io.IOException

flushAvailable

void flushAvailable(MessageOutputStream.DataReceiver target,
                    boolean blocking)
              throws java.io.IOException
Throws:
java.io.IOException

destroy

void destroy()