hiit.parser
Class BetelgeuseProtocolSocket

java.lang.Object
  extended by hiit.parser.BetelgeuseProtocolSocket
All Implemented Interfaces:
ContextParser, java.lang.Runnable

public class BetelgeuseProtocolSocket
extends java.lang.Object
implements ContextParser


Constructor Summary
BetelgeuseProtocolSocket(java.lang.String userName, java.lang.String bta, int betSession, long dbSession, Transceiver trans)
          Creates a new instance to handle a connection to the socket.
 
Method Summary
 boolean alive()
          Returns a boolean indicating if the object is alive or not.
 void close()
          Closes the connection to the BTG.
 java.lang.String getBluetoothAddress()
          Returns the bta of the handled BTG.
 int getCompression()
          Returns the value of the compression algorithm byte.
 int getDBSession()
          Returns the DB session id for the BTG handler.
 java.lang.String getParserName()
           
 java.util.Vector getRules()
           
 int getSession()
          Returns the pooled session id for the BTG handler.
 java.lang.String getUserName()
           
 void run()
          Starts the handler thread.
 void updateTransceiver(Transceiver trans)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BetelgeuseProtocolSocket

public BetelgeuseProtocolSocket(java.lang.String userName,
                                java.lang.String bta,
                                int betSession,
                                long dbSession,
                                Transceiver trans)
Creates a new instance to handle a connection to the socket.

Parameters:
bta - The bt address of the connected BTG to handle. Might change to a generic identifier in the future.
betSession - The session id assigned to the connected BTG. Pooled thread session id, unique among connected BTGs.
dbSession - The session id on the database id. Unique among all connections that ever connected to the db.
compression - sets the compression algorithm to use. Not in use at the moment.
s - The socket that was accepted and opened for the incoming connection.
out - The PrintWriter that uses the OutputStream of the socket s.
in - The InputStream from socket s.
Method Detail

run

public void run()
Starts the handler thread. Run only exits after a quit message is received from BTG or in the case of a database error.

Specified by:
run in interface java.lang.Runnable

getBluetoothAddress

public java.lang.String getBluetoothAddress()
Returns the bta of the handled BTG.

Specified by:
getBluetoothAddress in interface ContextParser
Returns:
A String containing the bluetooth address of the connected BTG.

getCompression

public int getCompression()
Returns the value of the compression algorithm byte. Not used yet.

Returns:
The value of the compression algorithm byte. Not used yet.

updateTransceiver

public void updateTransceiver(Transceiver trans)
Specified by:
updateTransceiver in interface ContextParser

alive

public boolean alive()
Returns a boolean indicating if the object is alive or not. If the object is not alive, calling close() will destroy the object. It is impossible to continue reading data from Betelgeuse after the BetelgeuseProtocolSocket has died, but it is possible to retrieve information by using the access methods.

Specified by:
alive in interface ContextParser
Returns:
true, if the object is alive, false otherwise

close

public void close()
Closes the connection to the BTG.

Specified by:
close in interface ContextParser

getSession

public int getSession()
Returns the pooled session id for the BTG handler.

Specified by:
getSession in interface ContextParser
Returns:
The session id used for identifying the BTG handled among current connections.

getDBSession

public int getDBSession()
Returns the DB session id for the BTG handler.

Specified by:
getDBSession in interface ContextParser

getRules

public java.util.Vector getRules()

getUserName

public java.lang.String getUserName()

getParserName

public java.lang.String getParserName()
Specified by:
getParserName in interface ContextParser