org.jSyncManager.Transport

Class ModemTransport

Implemented Interfaces:
ActionListener, Serializable

public class ModemTransport
extends SerialTransportInterface
implements ActionListener

Modem Communications Transport. This transport, based on the Sun Communications API provides additional connection and configuration methods required for synchronizing through a modem connection. It assumes a modem with a standard response set.

Field Summary

static String
DEFAULT_INIT_STRING
The default init string to use if none is specified by the user.
static int
DEFAULT_SPEED
The default serial speed to use if none is specified.
protected JComboBox
comSelectBox
A combo box to hold the communications port names.
protected boolean
connected
Serial connectivity flag.
protected DataInputStream
dis
The input data stream attached to the selected serial port.
protected DataOutputStream
dos
The output data stream attached to the selected serial port.
protected String
initString
The initialization string used to setup the modem.
protected JTextField
initStringField
A GUI field to display/edit/modify the modem init string.
protected boolean
modemConnected
Modem connectivity flag.
protected CommPortIdentifier
port
Hold a handle to the underlying CommPortIdentifier object for the selected serial port.
protected String
portName
The platform-specific name of the serial port in use.
protected SerialPort
ser
The selected serial port object.
protected static int
serialSpeed
The serial speed to use for the serial port connected to the modem.
protected JComboBox
speedSelectBox
A combo box to hold the serial port speeds.

Fields inherited from class org.jSyncManager.API.Transport.SerialTransportInterface

INITIAL_SERIAL_SPEED, serialSpeed

Fields inherited from class org.jSyncManager.API.Transport.SLPTransportInterface

configPanel, connected

Constructor Summary

ModemTransport()
Creates a new instance of the ModemTransport class.

Method Summary

void
actionPerformed(ActionEvent e)
Method that is called whenever an action is performed.
void
close()
Closes the Java COMM API port.
protected JPanel
constructConfigPanel()
Constructs this transports configuration panel.
void
disconnect()
This method is used to flag that the modem is disconnected.
protected void
finalize()
Finalizes this ModemTransport object by closing it's connection.
void
flush()
Flushes the input buffer of any remaining data.
int
getPreferredSyncSpeed()
A method to retreive the users preferred sync speed.
String
getResourceBundleName()
Returns the fully-qualified classname for the resources package to use for this transport.
String
getTransportDescription()
Returns the description for this Transport Interface.
String
getTransportExceptionText(TransportException ex)
Retrieves error information for a given TransportException.
String
getTransportName()
Returns the name of this Transport Interface.
void
initialize()
Initialize the port.
void
initialize(Properties properties, int id)
Initialize the port.
void
open()
Opens a read/write connection to the implemented transport.
byte
readByte()
Read a single byte from the Java COMM API port.
protected void
setSpeed(int speed)
Changes the speed of the underlying transport mechanism.
String
toString()
Returns settings information on this transport as a String.
void
writeBytes(data[] )
Writes an array of bytes to the Java COMM API port.

Methods inherited from class org.jSyncManager.API.Transport.SerialTransportInterface

getPreferredSyncSpeed, setSpeed, switchSpeed

Methods inherited from class org.jSyncManager.API.Transport.SLPTransportInterface

close, constructConfigPanel, flush, getConfigPanel, getResourceBundle, getResourceBundleName, getTransportDescription, getTransportExceptionText, getTransportName, initialize, initialize, isConnected, loadResourceBundle, open, readByte, setConnected, writeBytes

Field Details

DEFAULT_INIT_STRING

public static final String DEFAULT_INIT_STRING
The default init string to use if none is specified by the user.

DEFAULT_SPEED

public static final int DEFAULT_SPEED
The default serial speed to use if none is specified.
Field Value:
57600

comSelectBox

protected JComboBox comSelectBox
A combo box to hold the communications port names.

connected

protected boolean connected
Serial connectivity flag. true if we have an active serial port connection, false otherwise.

dis

protected DataInputStream dis
The input data stream attached to the selected serial port.

dos

protected DataOutputStream dos
The output data stream attached to the selected serial port.

initString

protected String initString
The initialization string used to setup the modem.

initStringField

protected JTextField initStringField
A GUI field to display/edit/modify the modem init string.

modemConnected

protected boolean modemConnected
Modem connectivity flag. true if we have an active modem connection, false otherwise.

port

protected CommPortIdentifier port
Hold a handle to the underlying CommPortIdentifier object for the selected serial port.

portName

protected String portName
The platform-specific name of the serial port in use.

ser

protected SerialPort ser
The selected serial port object.

serialSpeed

protected static int serialSpeed
The serial speed to use for the serial port connected to the modem.

speedSelectBox

protected JComboBox speedSelectBox
A combo box to hold the serial port speeds.

Constructor Details

ModemTransport

public ModemTransport()
            throws TransportException
Creates a new instance of the ModemTransport class.
Throws:
TransportException - any exception thrown by the underlying serial handler.

Method Details

actionPerformed

public void actionPerformed(ActionEvent e)
Method that is called whenever an action is performed.
Parameters:
e - the ActionEvent object for the event to be processed.

close

public void close()
            throws TransportException
Closes the Java COMM API port.
Overrides:
close in interface SLPTransportInterface
Throws:
TransportException - any exception encountered is rethrown.

constructConfigPanel

protected JPanel constructConfigPanel()
Constructs this transports configuration panel.
Overrides:
constructConfigPanel in interface SLPTransportInterface
Returns:
a javax.swing.JPanel containing the transports settings panel.

disconnect

public void disconnect()
This method is used to flag that the modem is disconnected. NOTE: this method does not actually cause the modem to hang up. It is currently assumed that the Palm will drop the connection, and that the modem hardware will automatically hangup in response.

finalize

protected void finalize()
            throws Throwable
Finalizes this ModemTransport object by closing it's connection.

flush

public void flush()
            throws TransportException
Flushes the input buffer of any remaining data.
Overrides:
flush in interface SLPTransportInterface
Throws:
TransportException - thrown when a problem occurs with flushing the stream.

getPreferredSyncSpeed

public int getPreferredSyncSpeed()
A method to retreive the users preferred sync speed. As the transport takes care of storing user selections on its own, and as the CMP layer negotiates the speed for the transfer after connecting, it needs a way to determine at what speed the user prefers to sync at.
Overrides:
getPreferredSyncSpeed in interface SerialTransportInterface
Returns:
the maximum serial rate the user has selected to sync at.

getResourceBundleName

public String getResourceBundleName()
Returns the fully-qualified classname for the resources package to use for this transport.
Overrides:
getResourceBundleName in interface SLPTransportInterface
Returns:
a String object containing the fully qualified classname for the ResoureBundle class to use for this transport.

getTransportDescription

public String getTransportDescription()
Returns the description for this Transport Interface. This method will return a string containing the description for this transport interface.
Overrides:
getTransportDescription in interface SLPTransportInterface
Returns:
the description for this transport interface.

getTransportExceptionText

public String getTransportExceptionText(TransportException ex)
Retrieves error information for a given TransportException.
Overrides:
getTransportExceptionText in interface SLPTransportInterface
Parameters:
ex - the TransportException to be inspected.
Returns:
a String object containing a text explaination for the exception.

getTransportName

public String getTransportName()
Returns the name of this Transport Interface. This method will return a string containing the name of this transport interface. This is used when searching for and selecting from one of many available transport interfaces that are installed on the system.
Overrides:
getTransportName in interface SLPTransportInterface
Returns:
the name of this transport interface.

initialize

public void initialize()
            throws TransportException
Initialize the port.
Overrides:
initialize in interface SLPTransportInterface
Throws:
TransportException - thrown if there isn't sufficient info to setup the transport, or if another exception has occurred.

initialize

public void initialize(Properties properties,
                       int id)
            throws TransportException
Initialize the port.
Overrides:
initialize in interface SLPTransportInterface
Parameters:
properties - a reference to the properties file containing configuration information.
id - the transport ID number to load data for.
Throws:
TransportException - if there is a problem initializing the transport.

open

public void open()
            throws TransportException
Opens a read/write connection to the implemented transport. This method should open the transport device being implemented using default parameters.
Overrides:
open in interface SLPTransportInterface
Throws:
TransportException - thrown when a problem occurs with flushing the stream.

readByte

public byte readByte()
            throws TransportException
Read a single byte from the Java COMM API port.
Overrides:
readByte in interface SLPTransportInterface
Returns:
the byte read from the data input stream attached to the serial port.
Throws:
TransportException - this class won't throw any exceptions, but maintains the superclasses exception signature.

setSpeed

protected void setSpeed(int speed)
            throws TransportException
Changes the speed of the underlying transport mechanism. This method is required by the parent class, however the implementation here is null.
Overrides:
setSpeed in interface SerialTransportInterface
Parameters:
speed - - The speed to set the transport to.
Throws:
TransportException - any exception the underlying code may throw.

toString

public String toString()
Returns settings information on this transport as a String.
Returns:
settings information on this transport as a String.

writeBytes

public void writeBytes(data[] )
            throws TransportException
Writes an array of bytes to the Java COMM API port.
Overrides:
writeBytes in interface SLPTransportInterface
Parameters:
Throws:
TransportException - this class won't throw any exceptions, but maintains the superclasses exception signature.