com.ibm.jusb
Class UsbConfigurationImp

java.lang.Object
  extended by com.ibm.jusb.UsbConfigurationImp
All Implemented Interfaces:
UsbConfiguration

public class UsbConfigurationImp
extends java.lang.Object
implements UsbConfiguration

UsbConfiguration implementation.

This must be set up before use.

Author:
Dan Streetman

Constructor Summary
UsbConfigurationImp(UsbDeviceImp device, UsbConfigurationDescriptor desc)
          Constructor.
 
Method Summary
 void addUsbInterfaceImp(UsbInterfaceImp setting)
          Add a UsbInterfaceImp.
 boolean containsUsbInterface(byte number)
          If the specified UsbInterface is contained in this UsbConfiguration.
 java.lang.String getConfigurationString()
          Get the configuration String.
 UsbConfigurationDescriptor getUsbConfigurationDescriptor()
          Get the configuration descriptor.
 UsbDevice getUsbDevice()
          Get the parent UsbDevice that this UsbConfiguration belongs to.
 UsbDeviceImp getUsbDeviceImp()
           
 UsbInterface getUsbInterface(byte number)
          Get a UsbInterface.
 UsbInterfaceImp getUsbInterfaceImp(byte number)
          Get a UsbInterfaceImp.
 java.util.List getUsbInterfaces()
          Get all UsbInterfaces for this configuration.
 java.util.List getUsbInterfaceSettingList(byte number)
          Get the List of settings for the specified interface numer.
 boolean isActive()
          If this UsbConfiguration is active.
 void setActiveUsbInterfaceImpSetting(UsbInterfaceImp setting)
          Change an interface setting to be the active alternate setting.
 void setUsbConfigurationDescriptor(UsbConfigurationDescriptor desc)
           
 void setUsbDeviceImp(UsbDeviceImp device)
          Set the UsbDeviceImp.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UsbConfigurationImp

public UsbConfigurationImp(UsbDeviceImp device,
                           UsbConfigurationDescriptor desc)
Constructor.

Parameters:
device - The parent device.
desc - This configuration's descriptor.
Method Detail

isActive

public boolean isActive()
Description copied from interface: UsbConfiguration
If this UsbConfiguration is active.

Specified by:
isActive in interface UsbConfiguration
Returns:
if this UsbConfiguration is active

getUsbInterfaces

public java.util.List getUsbInterfaces()
Description copied from interface: UsbConfiguration
Get all UsbInterfaces for this configuration.

The returned UsbInterface settings depend on whether this configuration (and by association its contained interfaces) is active or not:

Specified by:
getUsbInterfaces in interface UsbConfiguration
Returns:
All interfaces.

getUsbInterface

public UsbInterface getUsbInterface(byte number)
Get a UsbInterface.

Specified by:
getUsbInterface in interface UsbConfiguration
Parameters:
number - The number of the interface to get
Returns:
A UsbInterface with the given number

getUsbInterfaceImp

public UsbInterfaceImp getUsbInterfaceImp(byte number)
Get a UsbInterfaceImp.

Parameters:
number - The number of the interface to get.
Returns:
A UsbInterfaceImp with the given number.

containsUsbInterface

public boolean containsUsbInterface(byte number)
Description copied from interface: UsbConfiguration
If the specified UsbInterface is contained in this UsbConfiguration.

Specified by:
containsUsbInterface in interface UsbConfiguration
Parameters:
number - the number of the UsbInterface to check.
Returns:
if this configuration contains the specified UsbInterface.

addUsbInterfaceImp

public void addUsbInterfaceImp(UsbInterfaceImp setting)
Add a UsbInterfaceImp.

The first setting for a particular interface number will default as the active setting. If the setting being added has already been added, it will be changed to be the active setting for the interface number.

Parameters:
setting - The UsbInterfaceImp to add.

setActiveUsbInterfaceImpSetting

public void setActiveUsbInterfaceImpSetting(UsbInterfaceImp setting)
Change an interface setting to be the active alternate setting.

This behaves identical to addUsbInterfaceImp.

Parameters:
setting - The UsbInterfaceImp setting to change.

getUsbInterfaceSettingList

public java.util.List getUsbInterfaceSettingList(byte number)
Get the List of settings for the specified interface numer.

Parameters:
number - The interface number.
Returns:
The List of settings, or null if no such interface number exists.

getUsbDevice

public UsbDevice getUsbDevice()
Description copied from interface: UsbConfiguration
Get the parent UsbDevice that this UsbConfiguration belongs to.

Specified by:
getUsbDevice in interface UsbConfiguration
Returns:
The parent UsbDevice

getUsbDeviceImp

public UsbDeviceImp getUsbDeviceImp()
Returns:
The parent UsbDeviceImp

setUsbDeviceImp

public void setUsbDeviceImp(UsbDeviceImp device)
Set the UsbDeviceImp.

This will also add this to the parent UsbDeviceImp.

Parameters:
device - The parent UsbDeviceImp

getUsbConfigurationDescriptor

public UsbConfigurationDescriptor getUsbConfigurationDescriptor()
Description copied from interface: UsbConfiguration
Get the configuration descriptor.

The descriptor may be cached.

Specified by:
getUsbConfigurationDescriptor in interface UsbConfiguration
Returns:
the configuration descriptor for this configuration

getConfigurationString

public java.lang.String getConfigurationString()
                                        throws UsbException,
                                               java.io.UnsupportedEncodingException,
                                               UsbDisconnectedException
Description copied from interface: UsbConfiguration
Get the configuration String.

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

Specified by:
getConfigurationString in interface UsbConfiguration
Returns:
the String description of this configuration
Throws:
UsbException - If there was an error getting the UsbStringDescriptor.
java.io.UnsupportedEncodingException - If the string encoding is not supported.
UsbDisconnectedException - If the device has been disconnected.

setUsbConfigurationDescriptor

public void setUsbConfigurationDescriptor(UsbConfigurationDescriptor desc)
Parameters:
desc - the new configuration descriptor