jSyncManager

org.jSyncManager.Transport
Class JSerialTransport

java.lang.Object
  extended byorg.jSyncManager.API.Transport.SLPTransportInterface
      extended byorg.jSyncManager.API.Transport.SerialTransportInterface
          extended byorg.jSyncManager.Transport.JSerialTransport
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.io.Serializable

public class JSerialTransport
extends org.jSyncManager.API.Transport.SerialTransportInterface
implements java.awt.event.ActionListener

JSerial Transport implementation of the J-HotSync SLPTransport Interface. This class defines the transport interface based on the J-HotSync Protocol stack's SLPTransportInterface Interface, providing hardware serial port access through the Java Serial Handler, written by Brad BARCLAY.

Version:
$Revision: 1.5 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>, Last modified by: $Author: yaztromo $ on $Date: 2003/11/20 19:57:08 $.
See Also:
Serialized Form

Field Summary
protected  javax.swing.JComboBox comSelectBox
          A combo box to hold the communications port names.
protected  java.lang.String portName
          The name of the port selected for I/O.
protected  javax.swing.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
JSerialTransport()
          Construct a new instance of the JSerial Transport.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Method that is called whenever an action is performed.
 void close()
          Closes the JSerial Transport.
protected  javax.swing.JPanel constructConfigPanel()
          Constructs the configuration JPanel for this transport.
 void flush()
          Flushes the input buffer of any remaining data.
 int getPreferredSyncSpeed()
          Retreives the preferred (user-specified) sync speed to use with this transport.
 java.lang.String getResourceBundleName()
          Retreives the resource bundle name for use with this transport.
 java.lang.String getTransportDescription()
          Retreives the description for this transport.
 java.lang.String getTransportExceptionText(org.jSyncManager.API.Transport.TransportException ex)
          Retreives descripitive text for a given transport exception.
 java.lang.String getTransportName()
          Returns the name of this J-Serial implementation.
 void initialize()
          Initializes this transport.
 void initialize(java.util.Properties properties, int id)
          Initializes this transport from a properties object.
 void open()
          Opens a read/write connection to the JSerial Transport.
 byte readByte()
          Read a single byte from the underlying data stream.
protected  void setSpeed(int speed)
          Changes the speed of the serial port.
 void writeBytes(byte[] data)
          Write an array of bytes to the underlying data stream.
 
Methods inherited from class org.jSyncManager.API.Transport.SerialTransportInterface
switchSpeed
 
Methods inherited from class org.jSyncManager.API.Transport.SLPTransportInterface
getConfigPanel, getResourceBundle, isConnected, loadResourceBundle, setConnected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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.


portName

protected java.lang.String portName
The name of the port selected for I/O.

Constructor Detail

JSerialTransport

public JSerialTransport()
                 throws org.jSyncManager.API.Transport.TransportException
Construct a new instance of the JSerial Transport.

Throws:
org.jSyncManager.API.Transport.TransportException - thrown if any problems occur during construction.
Method Detail

close

public void close()
           throws org.jSyncManager.API.Transport.TransportException
Closes the JSerial Transport. This method closes the JSerial Transport.

Throws:
org.jSyncManager.API.Transport.TransportException - this just throws any exceptions that occur during closure.

flush

public void flush()
           throws org.jSyncManager.API.Transport.TransportException
Flushes the input buffer of any remaining data.

Throws:
org.jSyncManager.API.Transport.TransportException - thrown when a problem occurs with flushing the stream.

getTransportName

public java.lang.String getTransportName()
Returns the name of this J-Serial implementation. This method will return the platform name string for the JSerial handler.

Returns:
the name of the local JSerial handler.

open

public void open()
          throws org.jSyncManager.API.Transport.TransportException
Opens a read/write connection to the JSerial Transport. This method will open the serial port for communications.

Throws:
org.jSyncManager.API.Transport.TransportException - throws any exceptions encountered while opening the port.

readByte

public byte readByte()
Read a single byte from the underlying data stream. This method will read and return the next available byte in the stream.

Returns:
the next byte from the underlying serial buffer/port.

setSpeed

protected void setSpeed(int speed)
                 throws org.jSyncManager.API.Transport.TransportException
Changes the speed of the serial port. This method will tell the JSerial handler to change to the specified speed.

Parameters:
speed - The speed to set the transport to.
Throws:
org.jSyncManager.API.Transport.TransportException - any exception encountered while setting the speed is rethrown.

writeBytes

public void writeBytes(byte[] data)
Write an array of bytes to the underlying data stream. This method call will write an array of bytes to the underlying serial data stream.

Parameters:
data - the array of bytes to be written.

constructConfigPanel

protected javax.swing.JPanel constructConfigPanel()
Constructs the configuration JPanel for this transport.

Returns:
the configuration JPanel for this 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 action that was performed.

initialize

public void initialize()
                throws org.jSyncManager.API.Transport.TransportException
Initializes this transport.

Throws:
org.jSyncManager.API.Transport.TransportException - thrown if any initialization problems occur.

initialize

public void initialize(java.util.Properties properties,
                       int id)
                throws org.jSyncManager.API.Transport.TransportException
Initializes this transport from a properties object.

Parameters:
properties - the Properties object containing the settings for this transport.
id - the ID number for this transports settings.
Throws:
org.jSyncManager.API.Transport.TransportException - thrown if any initialization problems occur.

getTransportExceptionText

public java.lang.String getTransportExceptionText(org.jSyncManager.API.Transport.TransportException ex)
Retreives descripitive text for a given transport exception.

Parameters:
ex - the TransportException to examine.
Returns:
descripitive text for a given transport exception.

getResourceBundleName

public java.lang.String getResourceBundleName()
Retreives the resource bundle name for use with this transport.

Returns:
the resource bundle name for use with this transport.

getTransportDescription

public java.lang.String getTransportDescription()
Retreives the description for this transport.

Returns:
the resource bundle name for use with this transport.

getPreferredSyncSpeed

public int getPreferredSyncSpeed()
Retreives the preferred (user-specified) sync speed to use with this transport.

Returns:
the user preferred sync speed.

jSyncManager

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