net.kano.joscar.net
Class ConnProcessor

java.lang.Object
  extended byConnProcessor
Direct Known Subclasses:
FlapProcessor

public abstract class ConnProcessor
extends java.lang.Object

A simple interface for an object that has the ability to be attached and/or detached from a stream or socket.


Constructor Summary
ConnProcessor()
           
 
Method Summary
 void attachToInput(java.io.InputStream in)
          Attaches this connection processor to the given input stream.
 void attachToOutput(java.io.OutputStream out)
          Attaches this FLAP processor to the given output stream.
 void attachToSocket(java.net.Socket socket)
          Attaches this connection processor to the given socket's input and output streams.
 void detach()
          Detaches this connection processor from any attached input and/or output stream.
protected  java.io.InputStream getInputStream()
          Returns the input stream to which this processor is currently attached, or null if none is currently set.
protected  java.io.OutputStream getOutputStream()
          Returns the output stream to which this processor is currently attached, or null if none is currently set.
protected  boolean isAttached()
          Returns whether this connection processor is currently attached to a stream (input, output, or both).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnProcessor

public ConnProcessor()
Method Detail

attachToSocket

public final void attachToSocket(java.net.Socket socket)
                          throws java.io.IOException
Attaches this connection processor to the given socket's input and output streams. Behavior is undefined if the given socket is not connected (that just means an IOException will probably be thrown).

Note that this does not begin any sort of loop or connection; it only sets the values of the input and output streams.

Parameters:
socket - the socket to attach to
Throws:
java.io.IOException - if an I/O error occurs

attachToInput

public final void attachToInput(java.io.InputStream in)
Attaches this connection processor to the given input stream. This stream is from whence packets will be read. Note that in cannot be null; to detach from a stream, use detach().

Parameters:
in - the input stream to attach to

attachToOutput

public final void attachToOutput(java.io.OutputStream out)
Attaches this FLAP processor to the given output stream. This stream is where packets sent via the send method will be written. Note that out cannot be null; to detach from a stream, use detach().

Parameters:
out - the output stream to attach to

isAttached

protected final boolean isAttached()
Returns whether this connection processor is currently attached to a stream (input, output, or both).

Returns:
whether this connection processor is currently "attached"

getInputStream

protected final java.io.InputStream getInputStream()
Returns the input stream to which this processor is currently attached, or null if none is currently set.

Returns:
this processor's input stream

getOutputStream

protected final java.io.OutputStream getOutputStream()
Returns the output stream to which this processor is currently attached, or null if none is currently set.

Returns:
this processor's output stream

detach

public final void detach()
Detaches this connection processor from any attached input and/or output stream.