org.jSyncManager.Transport

Class JavaxUSBTransport

Implemented Interfaces:
Serializable, UsbInterfacePolicy, UsbServicesListener

public class JavaxUSBTransport
extends USBTransportInterface
implements UsbServicesListener, UsbInterfacePolicy

JavaxUSBTransport.java Javax USB Transport Class. This class provides a bridge between the JavaX USB API and the USB Protocol class.

Field Summary

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

CLIE_VENDOR_ID, HANDSPRING_DEVICE_IDS, HANDSPRING_TREO_ID, HANDSPRING_VENDOR_ID, HANDSPRING_VISOR_ID, PALM_DEVICE_IDS, PALM_I705_ID, PALM_M100_ID, PALM_M125_ID, PALM_M130_ID, PALM_M500_ID, PALM_M505_ID, PALM_M515_ID, PALM_TREO_600_ID, PALM_TUNGSTEN_T5_ID, PALM_TUNGSTEN_T_ID, PALM_TUNGSTEN_Z_ID, PALM_VENDOR_ID, PALM_ZIRE_ID, SAMSUNG_DEVICE_IDS, SAMSUNG_SCH_I330_ID, SAMSUNG_VENDOR_ID, SONY_CLIE_3_5_ID, SONY_CLIE_4_0_ID, SONY_CLIE_4_1_ID, SONY_CLIE_NX60_ID, SONY_CLIE_NZ90V_ID, SONY_CLIE_S360_ID, SONY_DEVICE_IDS

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

configPanel, connected

Constructor Summary

JavaxUSBTransport()
Creates a new instance of JavaxUSBTransport

Method Summary

void
close()
Closes the implemented transport.
protected JPanel
constructConfigPanel()
Constructs this transports configuration panel.
void
finalize()
Completed on garbage removal of the implemented transport.
void
flush()
Flushes the input buffer of any remaining data.
boolean
forceClaim(UsbInterface usbInterface)
A method to force the claim to the handheld device.
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 TransportInitException.
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 underlying data stream.
void
usbDeviceAttached(UsbServicesEvent event)
New device added.
void
usbDeviceDetached(UsbServicesEvent event)
Device removed.
void
writeBytes(byte[] data)
Write an array of bytes to the underlying data stream.

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

isKnownPDA

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

Constructor Details

JavaxUSBTransport

public JavaxUSBTransport()
            throws TransportException
Creates a new instance of JavaxUSBTransport

Method Details

close

public void close()
            throws TransportException
Closes the implemented transport. This method should close the transport device being implemented.
Overrides:
close in interface SLPTransportInterface
Throws:
TransportException - throws any required exception.

constructConfigPanel

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

finalize

public void finalize()
            throws TransportException
Completed on garbage removal of the implemented transport. This method should call close() on the transport device being implemented.
Throws:
TransportException - throws any required exception.

flush

public void flush()
            throws TransportException
Flushes the input buffer of any remaining data.
Overrides:
flush in interface SLPTransportInterface

forceClaim

public boolean forceClaim(UsbInterface usbInterface)
A method to force the claim to the handheld device.
Returns:
true.

getResourceBundleName

public String getResourceBundleName()
Returns the fully-qualified classname for the resources package to use for this transport. Your Transport implementation should return a String containing the name of your ResourceBundle class here.
Overrides:
getResourceBundleName in interface SLPTransportInterface
Returns:
a String object containing the fully qualified classname for a 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 TransportInitException. To ensure that we can keep code that uses the transport subclasses as generic as possible, this method should take a TransportInitException instance, inspect it, and provide a plaintext explaination for the error that can be shown to the user.
Overrides:
getTransportExceptionText in interface SLPTransportInterface
Parameters:
ex - the TransportInitException 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. This method is called to initialize this transport using the objects stored settings. You should perform whatever setup you require here. These objects may be serialized, however it isn't guaranteed that the underlying API classes are also serializable. As such you should store any user settings as non-transient fields, and setup the transport based on those settings here. This method will be called whenever the port requires initialization. Note you may also call this method in your event handlers for when the user changes the transport settings. Your implementation should throw a TransportInitException if there isn't sufficient information to setup the transport. Applications can catch this exception and use it to display the necessary settings dialog to the use.
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. This initializer is called when the port needs to be configured from a properties file. This is necessary for when the jConduit is constructed in a text-only or daemon application, which is unable to display the GUI configuration panel. The method accepts a transport ID number 'id', which should be used to differentiate the different ports defined in the properties file by using keys of the form "header.property.". This is necessary as such a property file may contain multiple sets of properties for different ports. Once the properties have been loaded, it is acceptable to call the initialize() method from within this method to initialize the connection, so long as the initialize() method contains no GUI code.
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 - any exception the underlying code may throw.

readByte

public byte readByte()
            throws TransportException
Read a single byte from the underlying data stream. This method call should abstract the underlying data connection stream to allow the SLP protocol to read a single byte from the stream.
Overrides:
readByte in interface SLPTransportInterface
Throws:
TransportException - thrown in the event that the connection to the remote device is lost.

usbDeviceAttached

public void usbDeviceAttached(UsbServicesEvent event)
New device added. This method is called by Javax USB when a new USB device is added to an existing bus.
Parameters:
event - the event that triggered the call to this method.

usbDeviceDetached

public void usbDeviceDetached(UsbServicesEvent event)
Device removed. This method is called by Javax USB when a new USB device is removed from an existing bus.
Parameters:
event - the event that triggered this method call.

writeBytes

public void writeBytes(byte[] data)
            throws TransportException
Write an array of bytes to the underlying data stream. This method call should abstract the underlying data connection stream to allow the SLP protocol to write an array of bytes to the stream.
Parameters:
data - the bytes to be written to the underlying stream.
Throws:
TransportException - thrown in the event that the connection to the remote device is lost.