jSyncManager

org.jSyncManager.Transport
Class ModemTransport

java.lang.Object
  |
  +--org.jSyncManager.API.Transport.SLPTransportInterface
        |
        +--org.jSyncManager.Transport.ModemTransport
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.io.Serializable

public class ModemTransport
extends SLPTransportInterface
implements java.awt.event.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.

Version:
$Revision: 1.16 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: dingodave $ on $Date: 2003/06/18 05:32:16 $.
See Also:
Serialized Form

Field Summary
protected  javax.swing.JComboBox comSelectBox
          A combo box to hold the communications port names.
protected  boolean connected
          Serial connectivity flag.
static java.lang.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  java.io.DataInputStream dis
          The input data stream attached to the selected serial port.
protected  java.io.DataOutputStream dos
          The output data stream attached to the selected serial port.
protected  java.lang.String initString
          The initialization string used to setup the modem.
protected  javax.swing.JTextField initStringField
          A GUI field to display/edit/modify the modem init string.
protected  boolean modemConnected
          Modem connectivity flag.
protected  javax.comm.CommPortIdentifier port
          Hold a handle to the underlying CommPortIdentifier object for the selected serial port.
protected  java.lang.String portName
          The platform-specific name of the serial port in use.
protected  javax.comm.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  javax.swing.JComboBox speedSelectBox
          A combo box to hold the serial port speeds.
 
Fields inherited from class org.jSyncManager.API.Transport.SLPTransportInterface
configPanel
 
Constructor Summary
ModemTransport()
          Creates a new instance of the ModemTransport class.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Method that is called whenever an action is performed.
 void close()
          Closes the Java COMM API port.
protected  javax.swing.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.
 java.lang.String getResourceBundleName()
          Returns the fully-qualified classname for the resources package to use for this transport.
 java.lang.String getTransportDescription()
          Returns the description for this Transport Interface.
 java.lang.String getTransportExceptionText(TransportException ex)
          Retrieves error information for a given TransportException.
 java.lang.String getTransportName()
          Returns the name of this Transport Interface.
 void initialize()
          Initialize the port.
 void initialize(java.util.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.
 java.lang.String toString()
          Returns settings information on this transport as a String.
 void writeBytes(byte[] data)
          Writes an array of bytes to the Java COMM API port.
 
Methods inherited from class org.jSyncManager.API.Transport.SLPTransportInterface
getConfigPanel, getResourceBundle, isConnected, loadResourceBundle, setConnected
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SPEED

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

DEFAULT_INIT_STRING

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

port

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

ser

protected transient javax.comm.SerialPort ser
The selected serial port object.

dis

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

dos

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

connected

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

modemConnected

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

portName

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

initString

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

serialSpeed

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

comSelectBox

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

speedSelectBox

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

initStringField

protected transient javax.swing.JTextField initStringField
A GUI field to display/edit/modify the modem init string.
Constructor Detail

ModemTransport

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

close

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

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 java.lang.Throwable
Finalizes this ModemTransport object by closing it's connection.
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - as per Object.finalize().

flush

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

getTransportName

public java.lang.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 class SLPTransportInterface
Returns:
the name of this transport interface.

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 class SLPTransportInterface
Throws:
TransportException - thrown when a problem occurs with flushing the stream.

readByte

public byte readByte()
Read a single byte from the Java COMM API port.
Overrides:
readByte in class SLPTransportInterface
Returns:
the byte read from the data input stream attached to the serial port.

writeBytes

public void writeBytes(byte[] data)
Writes an array of bytes to the Java COMM API port.
Overrides:
writeBytes in class SLPTransportInterface
Parameters:
data - the bytes to be written to the serial port.

constructConfigPanel

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

initialize

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

initialize

public void initialize(java.util.Properties properties,
                       int id)
                throws TransportException
Initialize the port.
Overrides:
initialize in class 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.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Method that is called whenever an action is performed.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - the ActionEvent object for the event to be processed.

getTransportExceptionText

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

getResourceBundleName

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

toString

public java.lang.String toString()
Returns settings information on this transport as a String.
Overrides:
toString in class java.lang.Object
Returns:
settings information on this transport as a String.

getTransportDescription

public java.lang.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 class SLPTransportInterface
Returns:
the description for this transport interface.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.