public class UsbInterfaceImp extends Object implements UsbInterface
This must be set up before use.
setter.setter.setter.
If not set, it defaults to a DefaultUsbInterfaceOsImp.directly or by
setUsbConfigurationImp, it must be
set after creating the active alternate setting.added.
When changing the active alternate setting, call the setActiveSettingNumber method.
This will update the parent config's active interface setting map.
| Modifier and Type | Field and Description |
|---|---|
protected UsbInterfacePolicy |
defaultUsbInterfacePolicy |
protected boolean |
disconnected |
protected UsbInterfacePolicy |
usbClaimPolicy |
| Constructor and Description |
|---|
UsbInterfaceImp(UsbConfigurationImp config,
UsbInterfaceDescriptor desc)
Constructor.
|
UsbInterfaceImp(UsbConfigurationImp config,
UsbInterfaceDescriptor desc,
UsbInterfaceOsImp osImp)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addUsbEndpointImp(UsbEndpointImp ep) |
void |
claim()
Claim this interface.
|
void |
claim(UsbInterfacePolicy policy)
Claim this interface using a UsbInterfacePolicy.
|
boolean |
containsSetting(byte number)
If the specified alternate setting exists.
|
boolean |
containsUsbEndpoint(byte address)
If the specified UsbEndpoint is contained in this UsbInterface.
|
UsbInterface |
getActiveSetting()
Get the active alternate setting.
|
UsbInterfaceImp |
getActiveSettingImp()
Get the active alternate setting.
|
byte |
getActiveSettingNumber()
Get the number of the active alternate setting for this interface
|
String |
getInterfaceString()
Get the interface String.
|
int |
getNumSettings()
Get the number of alternate settings for this interface.
|
UsbInterface |
getSetting(byte number)
Get the alternate setting with the specified number.
|
UsbInterfaceImp |
getSettingImp(byte number)
Get the alternate setting with the specified number.
|
List |
getSettings()
Get all alternate settings for this interface.
|
UsbConfiguration |
getUsbConfiguration()
Get the parent UsbConfiguration that this UsbInterface belongs to.
|
UsbConfigurationImp |
getUsbConfigurationImp() |
UsbEndpoint |
getUsbEndpoint(byte address)
Get a specific UsbEndpoint.
|
UsbEndpointImp |
getUsbEndpointImp(byte address) |
List |
getUsbEndpoints()
Get all endpoints for this interface setting.
|
UsbInterfaceDescriptor |
getUsbInterfaceDescriptor()
Get the interface descriptor.
|
UsbInterfaceOsImp |
getUsbInterfaceOsImp() |
protected UsbInterfacePolicy |
getUsbInterfacePolicy()
Get the current UsbInterfacePolicy.
|
protected boolean |
hasUsbInterfacePolicy()
If this interface currently has a policy.
|
boolean |
isActive()
If this interface setting is active.
|
boolean |
isClaimed()
If this interface is claimed.
|
boolean |
isJavaClaimed()
If this is claimed in java.
|
void |
release()
Release this interface.
|
void |
setActiveSettingNumber(byte number)
Set the active alternate setting number for ALL UsbInterfaces
on the AlternateSettings list
|
void |
setUsbConfigurationImp(UsbConfigurationImp config)
Set the UsbConfigurationImp.
|
void |
setUsbInterfaceDescriptor(UsbInterfaceDescriptor desc) |
void |
setUsbInterfaceOsImp(UsbInterfaceOsImp iface) |
protected UsbInterfacePolicy usbClaimPolicy
protected UsbInterfacePolicy defaultUsbInterfacePolicy
protected boolean disconnected
public UsbInterfaceImp(UsbConfigurationImp config, UsbInterfaceDescriptor desc)
config - The parent config. If this is not null, the UsbInterfaceDescriptor cannot be null.desc - This interface's descriptor. This cannot be null if the parent config is not null.public UsbInterfaceImp(UsbConfigurationImp config, UsbInterfaceDescriptor desc, UsbInterfaceOsImp osImp)
config - The parent config. If this is not null, the UsbInterfaceDescriptor cannot be null.desc - This interface's descriptor. This cannot be null if the parent config is not null.osImp - The UsbInterfaceOsImp.public void claim()
throws UsbClaimException,
UsbException,
UsbNotActiveException,
UsbDisconnectedException
This calls the other claim
with a default policy.
claim in interface UsbInterfaceUsbClaimException - If the interface is already claimed.UsbException - if the interface could not be claimed.UsbNotActiveException - if the interface setting is not active.UsbDisconnectedException - If this device has been disconnected.public void claim(UsbInterfacePolicy policy) throws UsbClaimException, UsbException, UsbNotActiveException, UsbDisconnectedException
This will claim all alternate settings using the provided UsbInterfacePolicy. If the interface is already claimed this will fail.
This can only be called from an
active alternate setting.
claim in interface UsbInterfacepolicy - The UsbInterfacePolicy to use.UsbClaimException - If the interface is already claimed.UsbException - if the interface could not be claimed.UsbNotActiveException - if the interface setting is not active.UsbDisconnectedException - If this device has been disconnected.public void release()
throws UsbClaimException,
UsbException,
UsbNotActiveException,
UsbDisconnectedException
release in interface UsbInterfaceUsbClaimException - If the interface is already claimed.UsbException - if the interface could not be released.UsbNotActiveException - if the interface setting is not active.UsbDisconnectedException - If this device has been disconnected.public boolean isClaimed()
UsbInterfaceThis will return true if claimed in Java. This may, depending on implementation, return true if claimed natively (outside of Java)
If this UsbInterface is not active, this will
return if the active alternate setting is active.
isClaimed in interface UsbInterfacepublic boolean isJavaClaimed()
This should only be used by javax.usb implementations; this is not part of the javax.usb API.
public boolean isActive()
isActive in interface UsbInterfacepublic List getUsbEndpoints()
UsbInterfacegetUsbEndpoints in interface UsbInterfacepublic UsbEndpoint getUsbEndpoint(byte address)
UsbInterfaceIf this does not contain the specified endpoint, this returns null.
getUsbEndpoint in interface UsbInterfaceaddress - The address of the UsbEndpoint to get.public UsbEndpointImp getUsbEndpointImp(byte address)
address - The address of the UsbEndpointImp to get.public boolean containsUsbEndpoint(byte address)
UsbInterfacecontainsUsbEndpoint in interface UsbInterfaceaddress - the address of the UsbEndpoint to check.public UsbConfiguration getUsbConfiguration()
UsbInterfacegetUsbConfiguration in interface UsbInterfacepublic UsbConfigurationImp getUsbConfigurationImp()
public void setUsbConfigurationImp(UsbConfigurationImp config)
This also adds this to the parent UsbConfigurationImp. The
UsbInterfaceDescriptor must be set
before calling this.
config - The parent configpublic int getNumSettings()
UsbInterfacegetNumSettings in interface UsbInterfacepublic byte getActiveSettingNumber()
throws UsbNotActiveException
getActiveSettingNumber in interface UsbInterfaceUsbNotActiveException - if the interface is inactive.public UsbInterface getActiveSetting() throws UsbNotActiveException
getActiveSetting in interface UsbInterfaceUsbNotActiveException - if the interface (not setting) is inactive.public UsbInterfaceImp getActiveSettingImp() throws UsbNotActiveException
UsbNotActiveException - if the interface (not setting) is inactive.public UsbInterface getSetting(byte number)
getSetting in interface UsbInterfacepublic UsbInterfaceImp getSettingImp(byte number)
public boolean containsSetting(byte number)
UsbInterfacecontainsSetting in interface UsbInterfacenumber - the number of the alternate setting to check.public List getSettings()
getSettings in interface UsbInterfacepublic UsbInterfaceDescriptor getUsbInterfaceDescriptor()
UsbInterfaceThe descriptor may be cached.
getUsbInterfaceDescriptor in interface UsbInterfacepublic String getInterfaceString() throws UsbException, UsbEncodingException, UsbDisconnectedException
UsbInterfaceThis is a convienence method. The String may be cached. If the device does not support strings or does not define the interface string, this returns null.
getInterfaceString in interface UsbInterfaceUsbException - If there was an error getting the UsbStringDescriptor.UsbEncodingException - If the string encoding is not supported.UsbDisconnectedException - If this interface (device) has been disconnected.public UsbInterfaceOsImp getUsbInterfaceOsImp()
public void setUsbInterfaceOsImp(UsbInterfaceOsImp iface)
iface - The UsbInterfaceOsImp to usepublic void setUsbInterfaceDescriptor(UsbInterfaceDescriptor desc)
desc - the new interface descriptorpublic void setActiveSettingNumber(byte number)
throws IllegalArgumentException
number - The number of the active alternate settingIllegalArgumentException - If the specified setting does not exist in this interface.public void addUsbEndpointImp(UsbEndpointImp ep)
ep - the endpoint to addprotected UsbInterfacePolicy getUsbInterfacePolicy()
protected boolean hasUsbInterfacePolicy()
Copyright © 2014 LSST. All Rights Reserved.