jSyncManager

org.jSyncManager.Transport
Class JUSBTransport

java.lang.Object
  |
  +--org.jSyncManager.API.Transport.SLPTransportInterface
        |
        +--org.jSyncManager.API.Transport.USBTransportInterface
              |
              +--org.jSyncManager.Transport.JUSBTransport
All Implemented Interfaces:
java.util.EventListener, java.io.Serializable, usb.core.USBListener

public class JUSBTransport
extends USBTransportInterface
implements usb.core.USBListener

JUSBTransport.java USB Transport Class. This class provides a bridge between the Java USB API and the SLP Protocol class. For information on the jUSB API or to download it or its sources, please see: http://jusb.sourceforge.net

Version:
$Revision: 1.12 $
Author:
David Bartmess <dingodave@edingo.net>
Last modified by: $Author: yaztromo $ on $Date: 2003/04/15 22:33:03 $.
See Also:
Serialized Form

Fields inherited from class org.jSyncManager.API.Transport.USBTransportInterface
CLIE_VENDOR_ID, HANDSPRING_VENDOR_ID, PALM_VENDOR_ID
 
Fields inherited from class org.jSyncManager.API.Transport.SLPTransportInterface
configPanel, connected
 
Constructor Summary
JUSBTransport()
          Creates a new instance of JUSBTransport
 
Method Summary
 void busAdded(usb.core.Bus bus)
          Called when a new USB bus is added to the system.
 void busRemoved(usb.core.Bus bus)
          Called when a bus is removed from the system.
 boolean checkPDAType(usb.core.Device dev1)
          Checks to see wether or not the newly attached device is a recognised PDA.
 void close()
          Closes the implemented transport.
protected  javax.swing.JPanel constructConfigPanel()
          Constructs this transports configuration panel.
 void deviceAdded(usb.core.Device dev)
          New device added.
 void deviceRemoved(usb.core.Device dev)
          Device removed.
 void finalize()
          Completed on garbage removal of the implemented transport.
 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 TransportInitException.
 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 underlying data stream.
 void writeBytes(byte[] data)
          Write an array of bytes to the underlying data stream.
 
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, toString, wait, wait, wait
 

Constructor Detail

JUSBTransport

public JUSBTransport()
              throws TransportException
Creates a new instance of JUSBTransport
Method Detail

getResourceBundleName

public java.lang.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 class SLPTransportInterface
Returns:
a String object containing the fully qualified classname for a ResoureBundle class to use for this transport.

getTransportExceptionText

public java.lang.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 class SLPTransportInterface
Parameters:
ex - the TransportInitException to be inspected.
Returns:
a String object containing a text explaination for the exception.

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.

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 class SLPTransportInterface
Throws:
TransportException - thrown if there isn't sufficient info to setup the transport, or if another exception has occurred.

checkPDAType

public boolean checkPDAType(usb.core.Device dev1)
Checks to see wether or not the newly attached device is a recognised PDA.
Returns:
true if we recognise this device as a PDA, false otherwise.

initialize

public void initialize(java.util.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 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.

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 - any exception the underlying code may throw.

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.
Overrides:
finalize in class java.lang.Object
Throws:
TransportException - throws any required exception.

close

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

flush

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

readByte

public byte readByte()
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 class SLPTransportInterface

writeBytes

public void writeBytes(byte[] data)
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.
Overrides:
writeBytes in class SLPTransportInterface
Parameters:
data - the bytes to be written to the underlying stream.

busAdded

public void busAdded(usb.core.Bus bus)
              throws java.io.IOException
Called when a new USB bus is added to the system.
Specified by:
busAdded in interface usb.core.USBListener
Throws:
java.io.IOException - thrown if there is an IO error of any sort.

busRemoved

public void busRemoved(usb.core.Bus bus)
                throws java.io.IOException
Called when a bus is removed from the system.
Specified by:
busRemoved in interface usb.core.USBListener
Throws:
java.io.IOException - thrown if there is an IO error of any sort.

deviceAdded

public void deviceAdded(usb.core.Device dev)
New device added. This method is called by JUSB when a new USB device is added to an existing bus.
Specified by:
deviceAdded in interface usb.core.USBListener
Parameters:
dev - the Device descriptor for the USB device that was added to the bus.

deviceRemoved

public void deviceRemoved(usb.core.Device dev)
                   throws java.io.IOException
Device removed. This method is called by JUSB when a new USB device is removed from an existing bus.
Specified by:
deviceRemoved in interface usb.core.USBListener
Parameters:
dev - the Device descriptor for the USB device that was removed from the bus.

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.

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.