javax.usb.util
Class UsbUtil.SynchronizedUsbDevice

java.lang.Object
  extended by javax.usb.util.UsbUtil.SynchronizedUsbDevice
All Implemented Interfaces:
UsbDevice
Enclosing class:
UsbUtil

public static class UsbUtil.SynchronizedUsbDevice
extends java.lang.Object
implements UsbDevice

A synchronized UsbDevice wrapper implementation.


Field Summary
 UsbDevice usbDevice
           
 
Constructor Summary
UsbUtil.SynchronizedUsbDevice(UsbDevice usbDevice)
           
 
Method Summary
 void addUsbDeviceListener(UsbDeviceListener listener)
          Add a UsbDeviceListener to this UsbDevice.
 void asyncSubmit(java.util.List list)
          Submit a List of UsbControlIrps asynchronously to the Default Control Pipe.
 void asyncSubmit(UsbControlIrp irp)
          Submit a UsbControlIrp asynchronously to the Default Control Pipe.
 boolean containsUsbConfiguration(byte number)
          If this UsbDevice contains the specified UsbConfiguration.
 UsbControlIrp createUsbControlIrp(byte bmRequestType, byte bRequest, short wValue, short wIndex)
          Create a UsbControlIrp.
 UsbConfiguration getActiveUsbConfiguration()
          Get the active UsbConfiguration.
 byte getActiveUsbConfigurationNumber()
          Get the number of the active UsbConfiguration.
 java.lang.String getManufacturerString()
          Get the manufacturer String.
 UsbPort getParentUsbPort()
          Get the UsbPort on the parent UsbHub that this device is connected to.
 java.lang.String getProductString()
          Get the product String.
 java.lang.String getSerialNumberString()
          Get the serial number String.
 java.lang.Object getSpeed()
          Get the speed of the device.
 java.lang.String getString(byte index)
          Get the String from the specified string descriptor.
 UsbConfiguration getUsbConfiguration(byte number)
          Get the specified UsbConfiguration.
 java.util.List getUsbConfigurations()
          Get all UsbConfigurations for this device.
 UsbDeviceDescriptor getUsbDeviceDescriptor()
          Get the device descriptor.
 UsbStringDescriptor getUsbStringDescriptor(byte index)
          Get the specified string descriptor.
 boolean isConfigured()
          If this UsbDevice is configured.
 boolean isUsbHub()
          If this is a UsbHub.
 void removeUsbDeviceListener(UsbDeviceListener listener)
          Remove a UsbDeviceListener from this UsbDevice.
 void syncSubmit(java.util.List list)
          Submit a List of UsbControlIrps synchronously to the Default Control Pipe.
 void syncSubmit(UsbControlIrp irp)
          Submit a UsbControlIrp synchronously to the Default Control Pipe.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

usbDevice

public UsbDevice usbDevice
Constructor Detail

UsbUtil.SynchronizedUsbDevice

public UsbUtil.SynchronizedUsbDevice(UsbDevice usbDevice)
Method Detail

getParentUsbPort

public UsbPort getParentUsbPort()
Description copied from interface: UsbDevice
Get the UsbPort on the parent UsbHub that this device is connected to.

Specified by:
getParentUsbPort in interface UsbDevice
Returns:
The port on the parent UsbHub that this is attached to.

isUsbHub

public boolean isUsbHub()
Description copied from interface: UsbDevice
If this is a UsbHub.

Specified by:
isUsbHub in interface UsbDevice
Returns:
true if this is a UsbHub.

getManufacturerString

public java.lang.String getManufacturerString()
                                       throws UsbException,
                                              java.io.UnsupportedEncodingException
Description copied from interface: UsbDevice
Get the manufacturer String.

This is a convienence method, which uses getString.

Specified by:
getManufacturerString in interface UsbDevice
Returns:
The manufacturer String, or null.
Throws:
UsbException - If there was an error getting the UsbStringDescriptor.
java.io.UnsupportedEncodingException - If the string encoding is not supported.

getSerialNumberString

public java.lang.String getSerialNumberString()
                                       throws UsbException,
                                              java.io.UnsupportedEncodingException
Description copied from interface: UsbDevice
Get the serial number String.

This is a convienence method, which uses getString.

Specified by:
getSerialNumberString in interface UsbDevice
Returns:
The serial number String, or null.
Throws:
UsbException - If there was an error getting the UsbStringDescriptor.
java.io.UnsupportedEncodingException - If the string encoding is not supported.

getProductString

public java.lang.String getProductString()
                                  throws UsbException,
                                         java.io.UnsupportedEncodingException
Description copied from interface: UsbDevice
Get the product String.

This is a convienence method, which uses getString.

Specified by:
getProductString in interface UsbDevice
Returns:
The product String, or null.
Throws:
UsbException - If there was an error getting the UsbStringDescriptor.
java.io.UnsupportedEncodingException - If the string encoding is not supported.

getSpeed

public java.lang.Object getSpeed()
Description copied from interface: UsbDevice
Get the speed of the device.

The speed will be one of:

Specified by:
getSpeed in interface UsbDevice
Returns:
The speed of this device.

getUsbConfigurations

public java.util.List getUsbConfigurations()
Description copied from interface: UsbDevice
Get all UsbConfigurations for this device.

The List is unmodifiable.

Specified by:
getUsbConfigurations in interface UsbDevice
Returns:
All UsbConfigurations for this device.

getUsbConfiguration

public UsbConfiguration getUsbConfiguration(byte number)
Description copied from interface: UsbDevice
Get the specified UsbConfiguration.

If the specified UsbConfiguration does not exist, null is returned. Config number 0 is reserved for the Not Configured state (see the USB 1.1 specification section 9.4.2). Obviously, no UsbConfiguration exists for the Not Configured state.

Specified by:
getUsbConfiguration in interface UsbDevice
Returns:
The specified UsbConfiguration, or null.

containsUsbConfiguration

public boolean containsUsbConfiguration(byte number)
Description copied from interface: UsbDevice
If this UsbDevice contains the specified UsbConfiguration.

This will return false for zero (the Not Configured state).

Specified by:
containsUsbConfiguration in interface UsbDevice
Returns:
If the specified UsbConfiguration is contained in this UsbDevice.

getActiveUsbConfigurationNumber

public byte getActiveUsbConfigurationNumber()
Description copied from interface: UsbDevice
Get the number of the active UsbConfiguration.

If the device is in a Not Configured state, this will return zero.

Specified by:
getActiveUsbConfigurationNumber in interface UsbDevice
Returns:
The active config number.

getActiveUsbConfiguration

public UsbConfiguration getActiveUsbConfiguration()
Description copied from interface: UsbDevice
Get the active UsbConfiguration.

If this device is Not Configured, this returns null.

Specified by:
getActiveUsbConfiguration in interface UsbDevice
Returns:
The active UsbConfiguration, or null.

isConfigured

public boolean isConfigured()
Description copied from interface: UsbDevice
If this UsbDevice is configured.

This returns true if the device is in the configured state as shown in the USB 1.1 specification table 9.1.

Specified by:
isConfigured in interface UsbDevice
Returns:
If this is in the Configured state.

getUsbDeviceDescriptor

public UsbDeviceDescriptor getUsbDeviceDescriptor()
Description copied from interface: UsbDevice
Get the device descriptor.

The descriptor may be cached.

Specified by:
getUsbDeviceDescriptor in interface UsbDevice
Returns:
The device descriptor.

getUsbStringDescriptor

public UsbStringDescriptor getUsbStringDescriptor(byte index)
                                           throws UsbException
Description copied from interface: UsbDevice
Get the specified string descriptor.

This is a convienence method. The UsbStringDescriptor may be cached. If the device does not support strings or does not define the specified string descriptor, this returns null.

Specified by:
getUsbStringDescriptor in interface UsbDevice
Parameters:
index - The index of the string descriptor to get.
Returns:
The specified string descriptor.
Throws:
UsbException - If an error occurred while getting the string descriptor.

getString

public java.lang.String getString(byte index)
                           throws UsbException,
                                  java.io.UnsupportedEncodingException
Description copied from interface: UsbDevice
Get the String from the specified string descriptor.

This is a convienence method, which uses getUsbStringDescriptor(). getString().

Specified by:
getString in interface UsbDevice
Parameters:
index - The index of the string to get.
Returns:
The specified String.
Throws:
UsbException - If an error occurred while getting the String.
java.io.UnsupportedEncodingException - If the string encoding is not supported.

syncSubmit

public void syncSubmit(UsbControlIrp irp)
                throws UsbException
Description copied from interface: UsbDevice
Submit a UsbControlIrp synchronously to the Default Control Pipe.

Specified by:
syncSubmit in interface UsbDevice
Parameters:
irp - The UsbControlIrp.
Throws:
UsbException - If an error occurrs.

asyncSubmit

public void asyncSubmit(UsbControlIrp irp)
                 throws UsbException
Description copied from interface: UsbDevice
Submit a UsbControlIrp asynchronously to the Default Control Pipe.

Specified by:
asyncSubmit in interface UsbDevice
Parameters:
irp - The UsbControlIrp.
Throws:
UsbException - If an error occurrs.

syncSubmit

public void syncSubmit(java.util.List list)
                throws UsbException
Description copied from interface: UsbDevice
Submit a List of UsbControlIrps synchronously to the Default Control Pipe.

All UsbControlIrps are guaranteed to be atomically (with respect to other clients of this API) submitted to the Default Control Pipe. Atomicity on a native level is implementation-dependent.

Specified by:
syncSubmit in interface UsbDevice
Parameters:
list - The List of UsbControlIrps.
Throws:
UsbException - If an error occurrs.

asyncSubmit

public void asyncSubmit(java.util.List list)
                 throws UsbException
Description copied from interface: UsbDevice
Submit a List of UsbControlIrps asynchronously to the Default Control Pipe.

All UsbControlIrps are guaranteed to be atomically (with respect to other clients of this API) submitted to the Default Control Pipe. Atomicity on a native level is implementation-dependent.

Specified by:
asyncSubmit in interface UsbDevice
Parameters:
list - The List of UsbControlIrps.
Throws:
UsbException - If an error occurrs.

createUsbControlIrp

public UsbControlIrp createUsbControlIrp(byte bmRequestType,
                                         byte bRequest,
                                         short wValue,
                                         short wIndex)
Description copied from interface: UsbDevice
Create a UsbControlIrp.

This creates a UsbControlIrp that may be optimized for use on this UsbDevice. Using this UsbIrp instead of a DefaultUsbControlIrp may increase performance or decrease memory requirements.

The UsbDevice cannot require this UsbControlIrp to be used, all submit methods must accept any UsbControlIrp implementation.

Specified by:
createUsbControlIrp in interface UsbDevice
Parameters:
bmRequestType - The bmRequestType.
bRequest - The bRequest.
wValue - The wValue.
wIndex - The wIndex.
Returns:
A UsbControlIrp ready for use.

addUsbDeviceListener

public void addUsbDeviceListener(UsbDeviceListener listener)
Description copied from interface: UsbDevice
Add a UsbDeviceListener to this UsbDevice.

Specified by:
addUsbDeviceListener in interface UsbDevice
Parameters:
listener - The UsbDeviceListener to add.

removeUsbDeviceListener

public void removeUsbDeviceListener(UsbDeviceListener listener)
Description copied from interface: UsbDevice
Remove a UsbDeviceListener from this UsbDevice.

Specified by:
removeUsbDeviceListener in interface UsbDevice
Parameters:
listener - The listener to remove.