|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An IOHandler
wraps an underlying communications mechanism
and provides access to its IO facilities and some convinivence methods.
It is assumed that concrete implementations will implement some sort
of buffering mechanism, at least for read operations to incraese efficiency.
Implementors may prefer instead to sub-class AbstractIOHandler
which provides a number of convinience no-ops and skeletal method implementations.
Method Summary | |
void |
addIOHandlerListener(IOHandlerListener l)
Add a IOHandlerListener to receive events from this IOHandler |
void |
afterAccept()
Invoked after a server-side accept() operation |
int |
available()
Gets the number of bytes that can be read from this IOHandler
without blocking |
void |
clearBuffer()
Clears the input buffer of this IOHandler |
void |
close()
Closes this IOHandler
Should generate an IOHandlerListener.onDisconnect(IOHandler) event. |
void |
connectClient(java.util.Map parameters,
int timeout)
Connects this IOHandler to a remote implementation. |
byte[] |
currentReadBuffer()
Retreives the contents of the IOHandler 's input
that can be read without blocking. |
void |
flush()
Flushes the output of this IOHandler . |
int |
getMaximumLineLength()
Gets the maximum line length to be used for read line operations |
int |
getReadTimeOut()
Get the timeout to use for read operations on this IOHandler |
boolean |
isConnected()
Determines whether or not this IOHandler is connected. |
void |
open()
I'm not actually sure what this is here for. |
int |
read()
Reads a single byte of data from this IOHandler 's input |
int |
read(byte[] b)
Reads some bytes from this IOHandler |
int |
read(byte[] b,
int len)
Reads up to len bytes from this IOHandler |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes from this IOHandler into
b starting at off |
int |
read(byte[] b,
int off,
int len,
int timeout)
Reads up to len bytes from this IOHandler into
b starting at off waiting for up to timeout
for data. |
int |
read(int timeout)
Reads a single byte of data from this IOHandler 's input |
java.lang.String |
readLine()
Reads a line of text from the IOHandler 's input
using the properties for read timeout and maxiumum linelength |
java.lang.String |
readLine(int timeout,
int maxLine)
Reads a line of text from the IOHandler 's input. |
java.lang.String |
readLine(int timeout,
int maxLine,
java.lang.String encoding)
Reads a line of text from the IOHandler using
If encoding is null the default
character encoding for the platform will be used. |
void |
removeIOHandlerListener(IOHandlerListener l)
Remove a IOHandlerListener from this IOHandler 's
listener listl |
void |
setMaximumLineLength(int newMaximumLineLength)
Sets the maximum line length to be acceped by this IOHandler |
void |
setReadTimeOut(int newTimeout)
Sets the timeout to use for read operations on this IOHandler |
void |
write(byte[] b)
Writes some bytes to this IOHandler 's output. |
void |
write(byte[] b,
int off,
int len)
Writes some bytes to this IOHandler 's output. |
void |
write(int b)
Writes a single byte to this IOHandler 's output |
Method Detail |
public boolean isConnected()
IOHandler
is connected.true
if connected false
otherwisepublic void afterAccept()
public void close()
IOHandler
Should generate an IOHandlerListener.onDisconnect(IOHandler)
event.public int read() throws IndyIOException
IOHandler
's inputIOHandler
IndyIOException
- if an IOError occurspublic int read(int timeout) throws IndyIOException
IOHandler
's inputtimeout
- The timeout to use for this read operationIOHandler
IndyIOException
- if an IOError occurspublic void clearBuffer()
IOHandler
public byte[] currentReadBuffer() throws IndyIOException
IOHandler
's input
that can be read without blocking.IndyIOException
- If an IOError occurs.public java.lang.String readLine() throws IndyIOException
IOHandler
's input
using the properties for read timeout and maxiumum linelengthIOHandler
IndyIOException
- if an IO error occursgetReadTimeOut()
,
setReadTimeOut(int,int)
,
getMaximumLineLength()
,
setMaximumLineLength(int)
public java.lang.String readLine(int timeout, int maxLine) throws IndyIOException
IOHandler
's input.timeout
- the timeout to use for this operationmaxLine
- the maxium line length to accepyIOHandler
IndyIOException
- if an IO error occurs.public java.lang.String readLine(int timeout, int maxLine, java.lang.String encoding) throws IndyIOException
IOHandler
using
If encoding
is null
the default
character encoding for the platform will be used.timeout
- the timeout to use for this operationmaxLine
- the maximum line length to acceptencoding
- the character encoding to use.IndyIOException
- public void connectClient(java.util.Map parameters, int timeout) throws IndyIOException, ConnectException, ConnectTimedOutException
IOHandler
to a remote implementation.
The contents of map depend on the implementation in question,
so a socket may have values for host, port etc.
Concrete implementations may also find it useful to provide
a connect method with implementation specific parameters.
Concrete implementations should consider allowing map populations that are all
Strings, so as to allow easy storage of connection parameters using java.util.Properties
Successful connection should generate an IOHandlerListener.onConnect(IOHandler)
event.parameters
- A java.util.Map
containing implementation specific connection parameters.timeout
- The timeout to use for connectingIndyIOException
- If an IO error occursConnectException
- If a connection error occursConnectTimedOutException
- If connection times out.public void open()
public void flush() throws IndyIOException
IOHandler
.IndyIOException
- if an IO error occurspublic void write(byte[] b, int off, int len) throws IndyIOException
IOHandler
's output.b
- The bytes to writeoff
- The offset at which to start writinglen
- The number of bytes to writeIndyIOException
- if an IO error occurs.public void write(byte[] b) throws IndyIOException
IOHandler
's output.b
- The bytes to writeIndyIOException
- if an IO error occurs.public void write(int b) throws IndyIOException
IOHandler
's outputb
- The byte to be writtenIndyIOException
- if an IO error occurs.public int read(byte[] b) throws IndyIOException
IOHandler
b
- A buffer to read the bytes intoIndyIOException
- if an IO error occurspublic int read(byte[] b, int len) throws IndyIOException
len
bytes from this IOHandler
b
- The buffer to read the bytes intolen
- The number opf bytes to be readIndyIOException
- if an IO error occurs.public int read(byte[] b, int off, int len) throws IndyIOException
len
bytes from this IOHandler
into
b
starting at off
b
- The buffer to read intooff
- The buffer offset to start filling atlen
- The number of bytes to readIndyIOException
- if an IO error occurs.public int read(byte[] b, int off, int len, int timeout) throws IndyIOException
len
bytes from this IOHandler
into
b
starting at off
waiting for up to timeout
for data.b
- The buffer to read intooff
- The buffer offset to start filling atlen
- The number of bytes to readtimeout
- The timeout to use for this operationIndyIOException
- if an IO error occurs.public int available() throws IndyIOException
IOHandler
without blockingIndyIOException
- if an IO error occurspublic int getReadTimeOut() throws IndyIOException
IOHandler
IndyIOException
- If the IOHandler is connected and an IOError occurspublic void setReadTimeOut(int newTimeout) throws IndyIOException
IOHandler
newTimeout
- The new timeout to useIndyIOException
- If the IOHandler is connected and an IOError occurspublic int getMaximumLineLength()
IOHandler
public void setMaximumLineLength(int newMaximumLineLength)
IOHandler
newMaximumLineLength
- The new maximum line lengthjava.lang.IllegalArgumentException
- if newMaximumLineLength
is < 0public void addIOHandlerListener(IOHandlerListener l)
IOHandlerListener
to receive events from this IOHandler
l
- The IOHandlerListener
public void removeIOHandlerListener(IOHandlerListener l)
IOHandlerListener
from this IOHandler
's
listener listll
- The IOHandlerListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |