org.hcilab.btprinter.abstractionlayer
Interface IOHandler


public interface IOHandler

This interface provides an abstraction layer for the communication with the printer which can be done for example using com ports (J2SE) or a serial bluetooth profile (J2ME) depending on the platform and its implementation.

It encapsulates a connection which has to provide an input and an output stream.

Version:
1.0.0
Author:
Dominik Schmidt

Method Summary
 void connect(java.lang.String id)
          Establishes a connection using the given identifier.
 void disconnect()
          Closes the associated connection if connected.
 java.io.InputStream getInputStream()
          Gets an input stream of the associated connection.
 java.io.OutputStream getOutputStream()
          Gets an output stream of the associated connection.
 boolean isConnected()
           
 void setLogHandler(LogHandler logHandler)
          Sets the log handler.
 

Method Detail

connect

void connect(java.lang.String id)
             throws java.io.IOException
Establishes a connection using the given identifier.

Parameters:
id - Identifier of device to connect to (such as COMx)
Throws:
java.io.IOException - If any io error occurs

disconnect

void disconnect()
Closes the associated connection if connected.


getInputStream

java.io.InputStream getInputStream()
                                   throws java.io.IOException
Gets an input stream of the associated connection.

Returns:
Input stream
Throws:
java.io.IOException - If any io error occurs

getOutputStream

java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Gets an output stream of the associated connection.

Returns:
Output stream
Throws:
java.io.IOException - If any io error occurs

isConnected

boolean isConnected()
Returns:
True, if connected

setLogHandler

void setLogHandler(LogHandler logHandler)
Sets the log handler. This has to be done at least once.

Parameters:
logHandler - Log handler