Fixed checkstyle problems.

This commit is contained in:
Klaus Reimer 2011-02-02 18:13:52 +01:00 committed by k
parent 43e2ea8398
commit ddeaedb273
38 changed files with 369 additions and 373 deletions

View File

@ -179,7 +179,7 @@
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber">
<property name="ignoreNumbers" value="-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 32, 64, 128, 255, 256, 512, 1024, 2048, 4096, 8192, 16384, 32767, 65535, 65536" />
<property name="ignoreNumbers" value="-1, 0, 1, 2, 17, 37, 255, 65535" />
</module>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>

View File

@ -150,16 +150,16 @@ public final class USB
// === Request types =====================================================
/** Standard request type. */
public static final int USB_TYPE_STANDARD = 0x00 << 5;
public static final int USB_TYPE_STANDARD = 0;
/** Class request type. */
public static final int USB_TYPE_CLASS = 0x01 << 5;
public static final int USB_TYPE_CLASS = 32;
/** Vendor request type. */
public static final int USB_TYPE_VENDOR = 0x02 << 5;
public static final int USB_TYPE_VENDOR = 64;
/** Reserved request type. */
public static final int USB_TYPE_RESERVED = 0x03 << 5;
public static final int USB_TYPE_RESERVED = 96;
// === Request recipients ================================================

View File

@ -17,7 +17,7 @@ import java.util.concurrent.locks.ReentrantLock;
public final class USBLock
{
/** Synchronization mutex. */
private static final ReentrantLock lock = new ReentrantLock();
private static final ReentrantLock LOCK = new ReentrantLock();
/**
@ -39,7 +39,7 @@ public final class USBLock
public static void acquire()
{
lock.lock();
LOCK.lock();
}
@ -50,6 +50,6 @@ public final class USBLock
public static void release()
{
lock.unlock();
LOCK.unlock();
}
}

View File

@ -86,7 +86,7 @@ public final class USBUtils
public static String decodeBCD(final int bcd)
{
return String.format("%x.%02x", bcd >> 8, bcd & 0xff);
return String.format("%x.%02x", bcd >> Byte.SIZE, bcd & 0xff);
}

View File

@ -99,15 +99,15 @@ public final class USB_Bus
public String dump()
{
final USB_Device root_dev = root_dev();
final String rootDev = root_dev == null ? "None or unknown" : root_dev
final USB_Device rootDev = root_dev();
final String rootDevName = rootDev == null ? "None or unknown" : rootDev
.filename();
final StringBuilder builder = new StringBuilder();
builder.append(String.format("Bus:%n" +
" dirname %23s%n" +
" location %15d%n" +
" root_dev %22s%n",
dirname(), location(), rootDev));
builder.append(String.format("Bus:%n"
+ " dirname %23s%n"
+ " location %15d%n"
+ " root_dev %22s%n",
dirname(), location(), rootDevName));
USB_Device device = devices();
while (device != null)
{
@ -155,7 +155,7 @@ public final class USB_Bus
int result = 17;
result = 37 * result + dirname().hashCode();
final long location = location();
result = 37 * result + (int) (location ^ (location >>> 32));
result = 37 * result + (int) (location ^ (location >>> Integer.SIZE));
return result;
}
}

View File

@ -17,6 +17,10 @@ import java.nio.ByteBuffer;
public final class USB_Config_Descriptor extends USB_Descriptor_Header
{
/** The number of hex dump columns for dumping extra descriptor. */
private static final int HEX_DUMP_COLS = 16;
/**
* Constructor.
*
@ -152,21 +156,23 @@ public final class USB_Config_Descriptor extends USB_Descriptor_Header
public String dump(final USB_Dev_Handle handle)
{
final StringBuilder builder = new StringBuilder();
builder.append(String.format("Configuration Descriptor:%n" +
" bLength %5d%n" +
" bDescriptorType %5d%n" +
" wTotalLength %5d%n" +
" bNumInterfaces %5d%n" +
" bConfigurationValue %5d%n" +
" iConfiguration %5d%n" +
" bmAttributes %#04x%n" +
" MaxPower %5d mA%n" +
" extralen %10d%n" +
" extra:%n" +
"%s",
bLength(), bDescriptorType(), wTotalLength(), bNumInterfaces(),
bConfigurationValue(), iConfiguration(), bmAttributes(),
MaxPower() * 2, extralen(), USBUtils.toHexDump(extra(), 16)
builder
.append(String.format("Configuration Descriptor:%n"
+ " bLength %5d%n"
+ " bDescriptorType %5d%n"
+ " wTotalLength %5d%n"
+ " bNumInterfaces %5d%n"
+ " bConfigurationValue %5d%n"
+ " iConfiguration %5d%n"
+ " bmAttributes %#04x%n"
+ " MaxPower %5d mA%n"
+ " extralen %10d%n"
+ " extra:%n"
+ "%s",
bLength(), bDescriptorType(), wTotalLength(), bNumInterfaces(),
bConfigurationValue(), iConfiguration(), bmAttributes(),
MaxPower() * 2, extralen(), USBUtils
.toHexDump(extra(), HEX_DUMP_COLS)
.replaceAll("(?m)^", " ")));
for (final USB_Interface descriptor : iface())
{
@ -188,7 +194,8 @@ public final class USB_Config_Descriptor extends USB_Descriptor_Header
if (o == this) return true;
if (o.getClass() != getClass()) return false;
final USB_Config_Descriptor other = (USB_Config_Descriptor) o;
return super.equals(o)
return bDescriptorType() == other.bDescriptorType()
&& bLength() == other.bLength()
&& bConfigurationValue() == other.bConfigurationValue()
&& bmAttributes() == other.bmAttributes()
&& bNumInterfaces() == other.bNumInterfaces()
@ -206,7 +213,8 @@ public final class USB_Config_Descriptor extends USB_Descriptor_Header
public int hashCode()
{
int result = 17;
result = 37 * result + super.hashCode();
result = 37 * result + bDescriptorType();
result = 37 * result + bLength();
result = 37 * result + bConfigurationValue();
result = 37 * result + bmAttributes();
result = 37 * result + bNumInterfaces();

View File

@ -50,34 +50,4 @@ public abstract class USB_Descriptor_Header
*/
public final native int bDescriptorType();
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object o)
{
if (o == null) return false;
if (o == this) return true;
if (o.getClass() != getClass()) return false;
final USB_Device_Descriptor other = (USB_Device_Descriptor) o;
return bDescriptorType() == other.bDescriptorType() &&
bLength() == other.bLength();
}
/**
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode()
{
int result = 17;
result = 37 * result + bDescriptorType();
result = 37 * result + bLength();
return result;
}
}

View File

@ -130,11 +130,11 @@ public final class USB_Device
public String dump()
{
final StringBuilder builder = new StringBuilder();
builder.append(String.format("Device:%n" +
" filename %20s%n" +
" bus %25s%n" +
" num_children %5d%n" +
" devnum %5d%n",
builder.append(String.format("Device:%n"
+ " filename %20s%n"
+ " bus %25s%n"
+ " num_children %5d%n"
+ " devnum %5d%n",
filename(), bus().dirname(), num_children(), devnum()));
final USB_Dev_Handle handle = usb_open(this);
try

View File

@ -199,32 +199,32 @@ public final class USB_Device_Descriptor extends USB_Descriptor_Header
public String dump(final USB_Dev_Handle handle)
{
final int iManufacturer = iManufacturer();
String sManufacturer = handle == null || iManufacturer == 0 ? "" :
usb_get_string_simple(handle, iManufacturer);
String sManufacturer = handle == null || iManufacturer == 0
? "" : usb_get_string_simple(handle, iManufacturer);
if (sManufacturer == null) sManufacturer = "";
final int iProduct = iProduct();
String sProduct = handle == null || iProduct == 0 ? "" :
usb_get_string_simple(handle, iProduct);
String sProduct = handle == null || iProduct == 0
? "" : usb_get_string_simple(handle, iProduct);
if (sProduct == null) sProduct = "";
final int iSerialNumber = iSerialNumber();
String sSerialNumber = handle == null || iSerialNumber == 0 ? "" :
usb_get_string_simple(handle, iSerialNumber);
String sSerialNumber = handle == null || iSerialNumber == 0
? "" : usb_get_string_simple(handle, iSerialNumber);
if (sSerialNumber == null) sSerialNumber = "";
return String.format("Device Descriptor:%n" +
" bLength %5d%n" +
" bDescriptorType %5d%n" +
" bcdUSB %5s%n" +
" bDeviceClass %5d %s%n" +
" bDeviceSubClass %5d%n" +
" bDeviceProtocol %5d%n" +
" bMaxPacketSize0 %5d%n" +
" idVendor %#06x%n" +
" idProduct %#06x%n" +
" bcdDevice %5s%n" +
" iManufacturer %5d %s%n" +
" iProduct %5d %s%n" +
" iSerialNumber %5d %s%n" +
" bNumConfigurations %5d%n",
return String.format("Device Descriptor:%n"
+ " bLength %5d%n"
+ " bDescriptorType %5d%n"
+ " bcdUSB %5s%n"
+ " bDeviceClass %5d %s%n"
+ " bDeviceSubClass %5d%n"
+ " bDeviceProtocol %5d%n"
+ " bMaxPacketSize0 %5d%n"
+ " idVendor %#06x%n"
+ " idProduct %#06x%n"
+ " bcdDevice %5s%n"
+ " iManufacturer %5d %s%n"
+ " iProduct %5d %s%n"
+ " iSerialNumber %5d %s%n"
+ " bNumConfigurations %5d%n",
bLength(), bDescriptorType(), USBUtils.decodeBCD(bcdUSB()),
bDeviceClass(), USBUtils.getUSBClassName(bDeviceClass()),
bDeviceSubClass(), bDeviceProtocol(),
@ -246,9 +246,12 @@ public final class USB_Device_Descriptor extends USB_Descriptor_Header
if (o == this) return true;
if (o.getClass() != getClass()) return false;
final USB_Device_Descriptor other = (USB_Device_Descriptor) o;
return super.equals(o) && idProduct() == other.idProduct()
return bDescriptorType() == other.bDescriptorType()
&& bLength() == other.bLength()
&& idProduct() == other.idProduct()
&& idVendor() == other.idVendor()
&& bcdDevice() == other.bcdDevice() && bcdUSB() == other.bcdUSB()
&& bcdDevice() == other.bcdDevice()
&& bcdUSB() == other.bcdUSB()
&& bDescriptorType() == other.bDescriptorType()
&& bDeviceClass() == other.bDeviceClass()
&& bDeviceProtocol() == other.bDeviceProtocol()
@ -270,7 +273,8 @@ public final class USB_Device_Descriptor extends USB_Descriptor_Header
public int hashCode()
{
int result = 17;
result = 37 * result + super.hashCode();
result = 37 * result + bDescriptorType();
result = 37 * result + bLength();
result = 37 * result + idProduct();
result = 37 * result + idVendor();
result = 37 * result + bcdDevice();

View File

@ -16,6 +16,10 @@ import java.nio.ByteBuffer;
public final class USB_Endpoint_Descriptor extends USB_Descriptor_Header
{
/** The number of hex dump columns for dumping extra descriptor. */
private static final int HEX_DUMP_COLS = 16;
/**
* Constructor.
*
@ -136,19 +140,20 @@ public final class USB_Endpoint_Descriptor extends USB_Descriptor_Header
public String dump()
{
return String.format("Endpoint Descriptor:%n" +
" bLength %5d%n" +
" bDecsriptorType %5d%n" +
" bEndpointAddress 0x%02x%n" +
" bmAttributes 0x%02x%n" +
" wMaxPacketSize %5d%n" +
" bInterval %5d%n" +
" extralen %10d%n" +
" extra:%n" +
"%s",
return String.format("Endpoint Descriptor:%n"
+ " bLength %5d%n"
+ " bDecsriptorType %5d%n"
+ " bEndpointAddress 0x%02x%n"
+ " bmAttributes 0x%02x%n"
+ " wMaxPacketSize %5d%n"
+ " bInterval %5d%n"
+ " extralen %10d%n"
+ " extra:%n"
+ "%s",
bLength(), bDescriptorType(), bEndpointAddress(), bmAttributes(),
wMaxPacketSize(), bInterval(), extralen(),
USBUtils.toHexDump(extra(), 16).replaceAll("(?m)^", " "));
USBUtils.toHexDump(extra(), HEX_DUMP_COLS)
.replaceAll("(?m)^", " "));
}
@ -163,7 +168,8 @@ public final class USB_Endpoint_Descriptor extends USB_Descriptor_Header
if (o == this) return true;
if (o.getClass() != getClass()) return false;
final USB_Endpoint_Descriptor other = (USB_Endpoint_Descriptor) o;
return super.equals(o)
return bDescriptorType() == other.bDescriptorType()
&& bLength() == other.bLength()
&& bEndpointAddress() == other.bEndpointAddress()
&& bmAttributes() == other.bmAttributes()
&& bInterval() == other.bInterval()
@ -182,7 +188,8 @@ public final class USB_Endpoint_Descriptor extends USB_Descriptor_Header
public int hashCode()
{
int result = 17;
result = 37 * result + super.hashCode();
result = 37 * result + bDescriptorType();
result = 37 * result + bLength();
result = 37 * result + bEndpointAddress();
result = 37 * result + bInterval();
result = 37 * result + bRefresh();

View File

@ -19,6 +19,10 @@ import java.nio.ByteBuffer;
public final class USB_Interface_Descriptor extends USB_Descriptor_Header
{
/** The number of hex dump columns for dumping extra descriptor. */
private static final int HEX_DUMP_COLS = 16;
/**
* Constructor.
*
@ -163,24 +167,25 @@ public final class USB_Interface_Descriptor extends USB_Descriptor_Header
String sInterface = iInterface == 0 || handle == null ? ""
: usb_get_string_simple(handle, iInterface);
if (sInterface == null) sInterface = "";
builder.append(String.format("Interface Descriptor:%n" +
" bLength %5d%n" +
" bDescriptorType %5d%n" +
" bInterfaceNumber %5d%n" +
" bAlternateSetting %5d%n" +
" bNumEndpoints %5d%n" +
" bInterfaceClass %5d %s%n" +
" bInterfaceSubClass %5d%n" +
" bInterfaceProtocol %5d%n" +
" iInterface %5d %s%n" +
" extralen %10d%n" +
" extra:%n" +
"%s",
builder.append(String.format("Interface Descriptor:%n"
+ " bLength %5d%n"
+ " bDescriptorType %5d%n"
+ " bInterfaceNumber %5d%n"
+ " bAlternateSetting %5d%n"
+ " bNumEndpoints %5d%n"
+ " bInterfaceClass %5d %s%n"
+ " bInterfaceSubClass %5d%n"
+ " bInterfaceProtocol %5d%n"
+ " iInterface %5d %s%n"
+ " extralen %10d%n"
+ " extra:%n"
+ "%s",
bLength(), bDescriptorType(), bInterfaceNumber(),
bAlternateSetting(), bNumEndpoints(), bInterfaceClass(),
USBUtils.getUSBClassName(bInterfaceClass()), bInterfaceSubClass(),
bInterfaceProtocol(), iInterface(), sInterface, extralen(),
USBUtils.toHexDump(extra(), 16).replaceAll("(?m)^", " ")));
USBUtils.toHexDump(extra(), HEX_DUMP_COLS)
.replaceAll("(?m)^", " ")));
if (extralen() != 0) return builder.toString();
for (final USB_Endpoint_Descriptor edesc : endpoint())
{
@ -201,7 +206,8 @@ public final class USB_Interface_Descriptor extends USB_Descriptor_Header
if (o == this) return true;
if (o.getClass() != getClass()) return false;
final USB_Interface_Descriptor other = (USB_Interface_Descriptor) o;
return super.equals(o)
return bDescriptorType() == other.bDescriptorType()
&& bLength() == other.bLength()
&& bAlternateSetting() == other.bAlternateSetting()
&& bInterfaceClass() == other.bInterfaceClass()
&& bInterfaceNumber() == other.bInterfaceNumber()
@ -222,7 +228,8 @@ public final class USB_Interface_Descriptor extends USB_Descriptor_Header
public int hashCode()
{
int result = 17;
result = 37 * result + super.hashCode();
result = 37 * result + bDescriptorType();
result = 37 * result + bLength();
result = 37 * result + bAlternateSetting();
result = 37 * result + bInterfaceClass();
result = 37 * result + bInterfaceProtocol();

View File

@ -71,7 +71,8 @@ public final class USB_String_Descriptor extends USB_Descriptor_Header
if (o == this) return true;
if (o.getClass() != getClass()) return false;
final USB_String_Descriptor other = (USB_String_Descriptor) o;
return super.equals(o)
return bDescriptorType() == other.bDescriptorType()
&& bLength() == other.bLength()
&& Arrays.equals(wData(), other.wData());
}
@ -84,7 +85,8 @@ public final class USB_String_Descriptor extends USB_Descriptor_Header
public int hashCode()
{
int result = 17;
result = 37 * result + super.hashCode();
result = 37 * result + bDescriptorType();
result = 37 * result + bLength();
result = 37 * result + Arrays.hashCode(wData());
return result;
}

View File

@ -46,10 +46,10 @@ import de.ailis.usb4java.USB_String_Descriptor;
* @author Klaus Reimer (k@ailis.de)
*/
public class UsbDeviceImpl implements UsbDevice
abstract class AbstractDevice implements UsbDevice
{
/** The low-level USB device. */
private final USB_Device device;
protected final USB_Device device;
/** The device descriptor. */
private final UsbDeviceDescriptorImpl descriptor;
@ -77,14 +77,14 @@ public class UsbDeviceImpl implements UsbDevice
* The low-level USB device.
*/
public UsbDeviceImpl(final USB_Device device)
public AbstractDevice(final USB_Device device)
{
this.device = device;
this.descriptor = new UsbDeviceDescriptorImpl(device.descriptor());
final USB_Config_Descriptor[] configs = device.config();
final List<UsbConfiguration> configurations = new ArrayList<UsbConfiguration>(
configs.length);
final List<UsbConfiguration> configurations =
new ArrayList<UsbConfiguration>(configs.length);
for (final USB_Config_Descriptor config : configs)
configurations.add(new UsbConfigurationImpl(this, config));
this.configurations = Collections.unmodifiableList(configurations);
@ -100,7 +100,7 @@ public class UsbDeviceImpl implements UsbDevice
* When USB device could not be opened.
*/
USB_Dev_Handle open() throws UsbException
final USB_Dev_Handle open() throws UsbException
{
if (this.handle == null)
{
@ -130,7 +130,7 @@ public class UsbDeviceImpl implements UsbDevice
* When device could not be closed.
*/
void close() throws UsbException
final void close() throws UsbException
{
if (this.handle != null)
{
@ -156,7 +156,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public UsbPort getParentUsbPort() throws UsbDisconnectedException
public final UsbPort getParentUsbPort()
{
if (this.port == null) throw new UsbDisconnectedException();
return this.port;
@ -171,7 +171,7 @@ public class UsbDeviceImpl implements UsbDevice
* The port to set. Null to unset.
*/
void setParentUsbPort(final UsbPort port)
final void setParentUsbPort(final UsbPort port)
{
if (this.port == null && port == null)
throw new IllegalStateException("Device already detached");
@ -182,7 +182,7 @@ public class UsbDeviceImpl implements UsbDevice
if (port == null && isUsbHub())
{
final UsbPorts hub = (UsbPorts) this;
for (final UsbDevice device: hub.getAttachedUsbDevices())
for (final UsbDevice device : hub.getAttachedUsbDevices())
hub.disconnectUsbDevice(device);
}
@ -212,23 +212,12 @@ public class UsbDeviceImpl implements UsbDevice
}
/**
* @see UsbDevice#isUsbHub()
*/
@Override
public boolean isUsbHub()
{
return false;
}
/**
* @see UsbDevice#getManufacturerString()
*/
@Override
public String getManufacturerString() throws UsbException,
public final String getManufacturerString() throws UsbException,
UnsupportedEncodingException
{
final byte index = this.descriptor.iManufacturer();
@ -242,7 +231,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public String getSerialNumberString() throws UsbException,
public final String getSerialNumberString() throws UsbException,
UnsupportedEncodingException
{
final byte index = this.descriptor.iSerialNumber();
@ -256,7 +245,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public String getProductString() throws UsbException,
public final String getProductString() throws UsbException,
UnsupportedEncodingException
{
final byte index = this.descriptor.iProduct();
@ -270,7 +259,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public Object getSpeed()
public final Object getSpeed()
{
return UsbConst.DEVICE_SPEED_UNKNOWN;
}
@ -281,7 +270,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public List<UsbConfiguration> getUsbConfigurations()
public final List<UsbConfiguration> getUsbConfigurations()
{
return this.configurations;
}
@ -292,7 +281,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public UsbConfiguration getUsbConfiguration(final byte number)
public final UsbConfiguration getUsbConfiguration(final byte number)
{
for (final UsbConfiguration configuration : this.configurations)
{
@ -311,7 +300,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public boolean containsUsbConfiguration(final byte number)
public final boolean containsUsbConfiguration(final byte number)
{
return getUsbConfiguration(number) != null;
}
@ -322,7 +311,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public byte getActiveUsbConfigurationNumber()
public final byte getActiveUsbConfigurationNumber()
{
return this.activeConfigurationNumber;
}
@ -344,7 +333,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public boolean isConfigured()
public final boolean isConfigured()
{
return this.activeConfigurationNumber != 0;
}
@ -355,7 +344,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public UsbDeviceDescriptor getUsbDeviceDescriptor()
public final UsbDeviceDescriptor getUsbDeviceDescriptor()
{
return this.descriptor;
}
@ -366,8 +355,8 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public UsbStringDescriptor getUsbStringDescriptor(final byte index)
throws UsbException, UsbDisconnectedException
public final UsbStringDescriptor getUsbStringDescriptor(final byte index)
throws UsbException
{
USBLock.acquire();
try
@ -396,7 +385,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public String getString(final byte index) throws UsbException,
public final String getString(final byte index) throws UsbException,
UnsupportedEncodingException
{
return getUsbStringDescriptor(index).getString();
@ -418,7 +407,8 @@ public class UsbDeviceImpl implements UsbDevice
{
final USB_Dev_Handle handle = open();
final ByteBuffer buffer = ByteBuffer.allocateDirect(256);
final int len = usb_get_descriptor(handle, USB_DT_STRING, 0, buffer);
final int len = usb_get_descriptor(handle, USB_DT_STRING, 0,
buffer);
if (len < 0)
throw new UsbException(
"Unable to get string descriptor languages: "
@ -445,8 +435,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public void syncSubmit(final UsbControlIrp irp) throws UsbException,
IllegalArgumentException, UsbDisconnectedException
public final void syncSubmit(final UsbControlIrp irp) throws UsbException
{
// TODO
throw new UnsupportedOperationException();
@ -458,8 +447,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public void asyncSubmit(final UsbControlIrp irp) throws UsbException,
IllegalArgumentException, UsbDisconnectedException
public final void asyncSubmit(final UsbControlIrp irp) throws UsbException
{
// TODO
throw new UnsupportedOperationException();
@ -471,10 +459,10 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public void syncSubmit(@SuppressWarnings("rawtypes") final List list)
throws UsbException, IllegalArgumentException, UsbDisconnectedException
public final void syncSubmit(@SuppressWarnings("rawtypes") final List list)
throws UsbException
{
for (final Object item: list)
for (final Object item : list)
{
syncSubmit((UsbControlIrp) item);
}
@ -486,10 +474,10 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public void asyncSubmit(@SuppressWarnings("rawtypes") final List list)
throws UsbException, IllegalArgumentException, UsbDisconnectedException
public final void asyncSubmit(@SuppressWarnings("rawtypes") final List list)
throws UsbException
{
for (final Object item: list)
for (final Object item : list)
{
asyncSubmit((UsbControlIrp) item);
}
@ -501,10 +489,11 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public UsbControlIrp createUsbControlIrp(final byte bmRequestType,
public final UsbControlIrp createUsbControlIrp(final byte bmRequestType,
final byte bRequest, final short wValue, final short wIndex)
{
return new DefaultUsbControlIrp(bmRequestType, bRequest, wValue, wIndex);
return new DefaultUsbControlIrp(bmRequestType, bRequest, wValue,
wIndex);
}
@ -513,7 +502,7 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public void addUsbDeviceListener(final UsbDeviceListener listener)
public final void addUsbDeviceListener(final UsbDeviceListener listener)
{
this.listeners.add(listener);
}
@ -524,34 +513,8 @@ public class UsbDeviceImpl implements UsbDevice
*/
@Override
public void removeUsbDeviceListener(final UsbDeviceListener listener)
public final void removeUsbDeviceListener(final UsbDeviceListener listener)
{
this.listeners.remove(listener);
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object obj)
{
if (obj == null) return false;
if (obj == this) return true;
if (obj.getClass() != getClass()) return false;
final UsbDeviceImpl other = (UsbDeviceImpl) obj;
return this.device.equals(other.device);
}
/**
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode()
{
return this.device.hashCode();
}
}

View File

@ -27,7 +27,8 @@ public final class UsbConfigurationDescriptorImpl extends
* The low-level USB configuration descriptor.
*/
public UsbConfigurationDescriptorImpl(final USB_Config_Descriptor descriptor)
public UsbConfigurationDescriptorImpl(final USB_Config_Descriptor
descriptor)
{
super(descriptor);
}
@ -38,7 +39,7 @@ public final class UsbConfigurationDescriptorImpl extends
*/
@Override
public final short wTotalLength()
public short wTotalLength()
{
return (short) (this.descriptor.wTotalLength() & 0xffff);
}
@ -49,7 +50,7 @@ public final class UsbConfigurationDescriptorImpl extends
*/
@Override
public final byte bNumInterfaces()
public byte bNumInterfaces()
{
return (byte) (this.descriptor.bNumInterfaces() & 0xff);
}
@ -60,7 +61,7 @@ public final class UsbConfigurationDescriptorImpl extends
*/
@Override
public final byte bConfigurationValue()
public byte bConfigurationValue()
{
return (byte) (this.descriptor.bConfigurationValue() & 0xff);
}
@ -71,7 +72,7 @@ public final class UsbConfigurationDescriptorImpl extends
*/
@Override
public final byte iConfiguration()
public byte iConfiguration()
{
return (byte) (this.descriptor.iConfiguration() & 0xff);
}
@ -82,7 +83,7 @@ public final class UsbConfigurationDescriptorImpl extends
*/
@Override
public final byte bmAttributes()
public byte bmAttributes()
{
return (byte) (this.descriptor.bmAttributes() & 0xff);
}
@ -93,7 +94,7 @@ public final class UsbConfigurationDescriptorImpl extends
*/
@Override
public final byte bMaxPower()
public byte bMaxPower()
{
return (byte) (this.descriptor.MaxPower() & 0xff);
}
@ -109,7 +110,8 @@ public final class UsbConfigurationDescriptorImpl extends
if (o == null) return false;
if (this == o) return true;
if (o.getClass() != getClass()) return false;
final UsbConfigurationDescriptorImpl other = (UsbConfigurationDescriptorImpl) o;
final UsbConfigurationDescriptorImpl other =
(UsbConfigurationDescriptorImpl) o;
return this.descriptor.equals(other.descriptor);
}

View File

@ -5,13 +5,11 @@
package de.ailis.usb4java.jsr80;
import java.io.UnsupportedEncodingException;
import java.util.List;
import javax.usb.UsbConfiguration;
import javax.usb.UsbConfigurationDescriptor;
import javax.usb.UsbDevice;
import javax.usb.UsbDisconnectedException;
import javax.usb.UsbException;
import javax.usb.UsbInterface;
@ -24,7 +22,7 @@ import de.ailis.usb4java.USB_Config_Descriptor;
* @author Klaus Reimer (k@ailis.de)
*/
public class UsbConfigurationImpl implements UsbConfiguration
public final class UsbConfigurationImpl implements UsbConfiguration
{
/** The low-level USB configuration descriptor. */
private final USB_Config_Descriptor lowLevelDescriptor;
@ -50,7 +48,8 @@ public class UsbConfigurationImpl implements UsbConfiguration
{
this.device = device;
this.lowLevelDescriptor = lowLevelDescriptor;
this.descriptor = new UsbConfigurationDescriptorImpl(lowLevelDescriptor);
this.descriptor = new UsbConfigurationDescriptorImpl(
lowLevelDescriptor);
}
@ -128,8 +127,7 @@ public class UsbConfigurationImpl implements UsbConfiguration
*/
@Override
public String getConfigurationString() throws UsbException,
UnsupportedEncodingException, UsbDisconnectedException
public String getConfigurationString() throws UsbException
{
// TODO
throw new UnsupportedOperationException();

View File

@ -58,30 +58,4 @@ public abstract class UsbDescriptorImpl<T extends USB_Descriptor_Header>
{
return (byte) (this.descriptor.bDescriptorType() & 0xff);
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object o)
{
if (o == null) return false;
if (this == o) return true;
if (o.getClass() != getClass()) return false;
final UsbDescriptorImpl<?> other = (UsbDescriptorImpl<?>) o;
return this.descriptor.equals(other.descriptor);
}
/**
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode()
{
return this.descriptor.hashCode();
}
}

View File

@ -37,7 +37,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final short bcdUSB()
public short bcdUSB()
{
return (short) (this.descriptor.bcdUSB() & 0xffff);
}
@ -48,7 +48,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final byte bDeviceClass()
public byte bDeviceClass()
{
return (byte) (this.descriptor.bDeviceClass() & 0xff);
}
@ -59,7 +59,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final byte bDeviceSubClass()
public byte bDeviceSubClass()
{
return (byte) (this.descriptor.bDeviceSubClass() & 0xff);
}
@ -70,7 +70,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final byte bDeviceProtocol()
public byte bDeviceProtocol()
{
return (byte) (this.descriptor.bDeviceProtocol() & 0xff);
}
@ -81,7 +81,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final byte bMaxPacketSize0()
public byte bMaxPacketSize0()
{
return (byte) (this.descriptor.bMaxPacketSize0() & 0xff);
}
@ -92,7 +92,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final short idVendor()
public short idVendor()
{
return (short) (this.descriptor.idVendor() & 0xffff);
}
@ -103,7 +103,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final short idProduct()
public short idProduct()
{
return (short) (this.descriptor.idProduct() & 0xffff);
}
@ -114,7 +114,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final short bcdDevice()
public short bcdDevice()
{
return (short) (this.descriptor.bcdDevice() & 0xffff);
}
@ -125,7 +125,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final byte iManufacturer()
public byte iManufacturer()
{
return (byte) (this.descriptor.iManufacturer() & 0xff);
}
@ -136,7 +136,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final byte iProduct()
public byte iProduct()
{
return (byte) (this.descriptor.iProduct() & 0xff);
}
@ -147,7 +147,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final byte iSerialNumber()
public byte iSerialNumber()
{
return (byte) (this.descriptor.iSerialNumber() & 0xff);
}
@ -158,7 +158,7 @@ public final class UsbDeviceDescriptorImpl extends
*/
@Override
public final byte bNumConfigurations()
public byte bNumConfigurations()
{
return (byte) (this.descriptor.bNumConfigurations() & 0xff);
}

View File

@ -25,7 +25,7 @@ public final class UsbDeviceListenerList extends
*/
@Override
public final UsbDeviceListener[] toArray()
public UsbDeviceListener[] toArray()
{
return this.listeners.toArray(new UsbDeviceListener[this.listeners
.size()]);
@ -37,7 +37,7 @@ public final class UsbDeviceListenerList extends
*/
@Override
public final void usbDeviceDetached(final UsbDeviceEvent event)
public void usbDeviceDetached(final UsbDeviceEvent event)
{
for (final UsbDeviceListener listener : toArray())
listener.usbDeviceDetached(event);
@ -49,7 +49,7 @@ public final class UsbDeviceListenerList extends
*/
@Override
public final void errorEventOccurred(final UsbDeviceErrorEvent event)
public void errorEventOccurred(final UsbDeviceErrorEvent event)
{
for (final UsbDeviceListener listener : toArray())
listener.errorEventOccurred(event);
@ -61,7 +61,7 @@ public final class UsbDeviceListenerList extends
*/
@Override
public final void dataEventOccurred(final UsbDeviceDataEvent event)
public void dataEventOccurred(final UsbDeviceDataEvent event)
{
for (final UsbDeviceListener listener : toArray())
listener.dataEventOccurred(event);

View File

@ -28,6 +28,9 @@ import de.ailis.usb4java.USB_Device;
class UsbDeviceScanner
{
/** The scan interval in milliseconds. */
private static final int DEFAULT_SCAN_INTERVAL = 500;
/** The virtual USB root hub. */
private final VirtualRootHub rootHub;
@ -169,11 +172,11 @@ class UsbDeviceScanner
{
try
{
Thread.sleep(500);
Thread.sleep(DEFAULT_SCAN_INTERVAL);
}
catch (final InterruptedException e)
{
// Ignored
Thread.currentThread().interrupt();
}
scan();
}

View File

@ -38,7 +38,7 @@ public final class UsbEndpointDescriptorImpl extends
*/
@Override
public final byte bEndpointAddress()
public byte bEndpointAddress()
{
return (byte) (this.descriptor.bEndpointAddress() & 0xff);
}
@ -49,7 +49,7 @@ public final class UsbEndpointDescriptorImpl extends
*/
@Override
public final byte bmAttributes()
public byte bmAttributes()
{
return (byte) (this.descriptor.bmAttributes() & 0xff);
}
@ -60,7 +60,7 @@ public final class UsbEndpointDescriptorImpl extends
*/
@Override
public final short wMaxPacketSize()
public short wMaxPacketSize()
{
return (short) (this.descriptor.wMaxPacketSize() & 0xffff);
}
@ -71,7 +71,7 @@ public final class UsbEndpointDescriptorImpl extends
*/
@Override
public final byte bInterval()
public byte bInterval()
{
return (byte) (this.descriptor.bInterval() & 0xff);
}

View File

@ -20,7 +20,8 @@ import de.ailis.usb4java.USB_Device;
* @author Klaus Reimer (k@ailis.de)
*/
public final class UsbHubImpl extends UsbDeviceImpl implements UsbHub, UsbPorts
public final class UsbHubImpl extends AbstractDevice implements UsbHub,
UsbPorts
{
/** The hub ports. */
private final UsbPortsImpl ports = new UsbPortsImpl(this);
@ -123,7 +124,7 @@ public final class UsbHubImpl extends UsbDeviceImpl implements UsbHub, UsbPorts
/**
* @see de.ailis.usb4java.jsr80.UsbDeviceImpl#isUsbHub()
* @see UsbDevice#isUsbHub()
*/
@Override
@ -131,4 +132,30 @@ public final class UsbHubImpl extends UsbDeviceImpl implements UsbHub, UsbPorts
{
return true;
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object obj)
{
if (obj == null) return false;
if (obj == this) return true;
if (obj.getClass() != getClass()) return false;
final UsbHubImpl other = (UsbHubImpl) obj;
return this.device.equals(other.device);
}
/**
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode()
{
return this.device.hashCode();
}
}

View File

@ -38,7 +38,7 @@ public final class UsbInterfaceDescriptorImpl extends
*/
@Override
public final byte bInterfaceNumber()
public byte bInterfaceNumber()
{
return (byte) (this.descriptor.bInterfaceNumber() & 0xff);
}
@ -49,7 +49,7 @@ public final class UsbInterfaceDescriptorImpl extends
*/
@Override
public final byte bAlternateSetting()
public byte bAlternateSetting()
{
return (byte) (this.descriptor.bAlternateSetting() & 0xff);
}
@ -60,7 +60,7 @@ public final class UsbInterfaceDescriptorImpl extends
*/
@Override
public final byte bNumEndpoints()
public byte bNumEndpoints()
{
return (byte) (this.descriptor.bNumEndpoints() & 0xff);
}
@ -71,7 +71,7 @@ public final class UsbInterfaceDescriptorImpl extends
*/
@Override
public final byte bInterfaceClass()
public byte bInterfaceClass()
{
return (byte) (this.descriptor.bInterfaceClass() & 0xff);
}
@ -82,7 +82,7 @@ public final class UsbInterfaceDescriptorImpl extends
*/
@Override
public final byte bInterfaceSubClass()
public byte bInterfaceSubClass()
{
return (byte) (this.descriptor.bInterfaceSubClass() & 0xff);
}
@ -93,7 +93,7 @@ public final class UsbInterfaceDescriptorImpl extends
*/
@Override
public final byte bInterfaceProtocol()
public byte bInterfaceProtocol()
{
return (byte) (this.descriptor.bInterfaceProtocol() & 0xff);
}
@ -104,7 +104,7 @@ public final class UsbInterfaceDescriptorImpl extends
*/
@Override
public final byte iInterface()
public byte iInterface()
{
return (byte) (this.descriptor.iInterface() & 0xff);
}

View File

@ -5,18 +5,13 @@
package de.ailis.usb4java.jsr80;
import java.io.UnsupportedEncodingException;
import java.util.List;
import javax.usb.UsbClaimException;
import javax.usb.UsbConfiguration;
import javax.usb.UsbDisconnectedException;
import javax.usb.UsbEndpoint;
import javax.usb.UsbException;
import javax.usb.UsbInterface;
import javax.usb.UsbInterfaceDescriptor;
import javax.usb.UsbInterfacePolicy;
import javax.usb.UsbNotActiveException;
import de.ailis.usb4java.USB_Interface;
@ -58,8 +53,7 @@ public final class UsbInterfaceImpl implements UsbInterface
*/
@Override
public final void claim() throws UsbClaimException, UsbException,
UsbNotActiveException, UsbDisconnectedException
public void claim()
{
// TODO
throw new UnsupportedOperationException();
@ -72,8 +66,6 @@ public final class UsbInterfaceImpl implements UsbInterface
@Override
public void claim(final UsbInterfacePolicy policy)
throws UsbClaimException,
UsbException, UsbNotActiveException, UsbDisconnectedException
{
// TODO
throw new UnsupportedOperationException();
@ -85,8 +77,7 @@ public final class UsbInterfaceImpl implements UsbInterface
*/
@Override
public void release() throws UsbClaimException, UsbException,
UsbNotActiveException, UsbDisconnectedException
public void release()
{
// TODO
throw new UnsupportedOperationException();
@ -133,7 +124,7 @@ public final class UsbInterfaceImpl implements UsbInterface
*/
@Override
public byte getActiveSettingNumber() throws UsbNotActiveException
public byte getActiveSettingNumber()
{
// TODO
throw new UnsupportedOperationException();
@ -145,7 +136,7 @@ public final class UsbInterfaceImpl implements UsbInterface
*/
@Override
public UsbInterface getActiveSetting() throws UsbNotActiveException
public UsbInterface getActiveSetting()
{
// TODO
throw new UnsupportedOperationException();
@ -251,8 +242,7 @@ public final class UsbInterfaceImpl implements UsbInterface
*/
@Override
public String getInterfaceString() throws UsbException,
UnsupportedEncodingException, UsbDisconnectedException
public String getInterfaceString()
{
// TODO
throw new UnsupportedOperationException();

View File

@ -24,7 +24,7 @@ public final class UsbPipeListenerList extends
*/
@Override
public final UsbPipeListener[] toArray()
public UsbPipeListener[] toArray()
{
return this.listeners.toArray(new UsbPipeListener[this.listeners
.size()]);
@ -36,7 +36,7 @@ public final class UsbPipeListenerList extends
*/
@Override
public final void errorEventOccurred(final UsbPipeErrorEvent event)
public void errorEventOccurred(final UsbPipeErrorEvent event)
{
for (final UsbPipeListener listener : toArray())
listener.errorEventOccurred(event);
@ -48,7 +48,7 @@ public final class UsbPipeListenerList extends
*/
@Override
public final void dataEventOccurred(final UsbPipeDataEvent event)
public void dataEventOccurred(final UsbPipeDataEvent event)
{
for (final UsbPipeListener listener : toArray())
listener.dataEventOccurred(event);

View File

@ -49,7 +49,7 @@ public final class UsbPortImpl implements UsbPort
*/
@Override
public final byte getPortNumber()
public byte getPortNumber()
{
return this.portNumber;
}
@ -60,7 +60,7 @@ public final class UsbPortImpl implements UsbPort
*/
@Override
public final UsbHub getUsbHub()
public UsbHub getUsbHub()
{
return this.hub;
}
@ -71,7 +71,7 @@ public final class UsbPortImpl implements UsbPort
*/
@Override
public final UsbDevice getUsbDevice()
public UsbDevice getUsbDevice()
{
return this.device;
}
@ -82,7 +82,7 @@ public final class UsbPortImpl implements UsbPort
*/
@Override
public final boolean isUsbDeviceAttached()
public boolean isUsbDeviceAttached()
{
return this.device != null;
}
@ -95,7 +95,7 @@ public final class UsbPortImpl implements UsbPort
* The device to connect.
*/
final void connectUsbDevice(final UsbDevice device)
void connectUsbDevice(final UsbDevice device)
{
if (device == null)
throw new IllegalArgumentException("device must not be null");
@ -103,7 +103,7 @@ public final class UsbPortImpl implements UsbPort
throw new IllegalStateException(
"Port already has a connected device");
this.device = device;
((UsbDeviceImpl) device).setParentUsbPort(this);
((AbstractDevice) device).setParentUsbPort(this);
}
@ -111,11 +111,11 @@ public final class UsbPortImpl implements UsbPort
* Disconnects the currently connected device.
*/
final void disconnectUsbDevice()
void disconnectUsbDevice()
{
if (this.device == null)
throw new IllegalStateException("Port has no connected device");
final UsbDeviceImpl device = (UsbDeviceImpl) this.device;
final AbstractDevice device = (AbstractDevice) this.device;
this.device = null;
device.setParentUsbPort(null);
}

View File

@ -16,7 +16,7 @@ import javax.usb.event.UsbServicesListener;
/**
* usb4java implementation of JSR-80 UsbServices
* usb4java implementation of JSR-80 UsbServices.
*
* @author Klaus Reimer (k@ailis.de)
*/
@ -24,7 +24,8 @@ import javax.usb.event.UsbServicesListener;
public final class UsbServicesImpl implements UsbServices
{
/** The implementation description. */
private static final String IMP_DESCRIPTION = "usb4java JSR-80 implementation";
private static final String IMP_DESCRIPTION =
"usb4java JSR-80 implementation";
/** The implementation version. */
private static final String IMP_VERSION = "0.1.12-1";
@ -33,7 +34,8 @@ public final class UsbServicesImpl implements UsbServices
private static final String API_VERSION = "1.0.1";
/** The USB services listeners. */
private final UsbServicesListenerList listeners = new UsbServicesListenerList();
private final UsbServicesListenerList listeners =
new UsbServicesListenerList();
/** The virtual USB root hub. */
private final VirtualRootHub rootHub;
@ -60,7 +62,7 @@ public final class UsbServicesImpl implements UsbServices
*/
@Override
public UsbHub getRootUsbHub() throws UsbException, SecurityException
public UsbHub getRootUsbHub() throws UsbException
{
this.deviceScanner.firstScan();
return this.rootHub;
@ -125,7 +127,8 @@ public final class UsbServicesImpl implements UsbServices
/**
* Informs listeners about a new attached device.
*
* @param device The new attached device.
* @param device
* The new attached device.
*/
void usbDeviceAttached(final UsbDevice device)
@ -137,7 +140,8 @@ public final class UsbServicesImpl implements UsbServices
/**
* Informs listeners about a detached device.
*
* @param device The detached device.
* @param device
* The detached device.
*/
void usbDeviceDetached(final UsbDevice device)

View File

@ -23,7 +23,7 @@ public final class UsbServicesListenerList extends
*/
@Override
public final UsbServicesListener[] toArray()
public UsbServicesListener[] toArray()
{
return this.listeners.toArray(new UsbServicesListener[this.listeners
.size()]);
@ -35,7 +35,7 @@ public final class UsbServicesListenerList extends
*/
@Override
public final void usbDeviceAttached(final UsbServicesEvent event)
public void usbDeviceAttached(final UsbServicesEvent event)
{
for (final UsbServicesListener listener : toArray())
listener.usbDeviceAttached(event);
@ -47,7 +47,7 @@ public final class UsbServicesListenerList extends
*/
@Override
public final void usbDeviceDetached(final UsbServicesEvent event)
public void usbDeviceDetached(final UsbServicesEvent event)
{
for (final UsbServicesListener listener : toArray())
listener.usbDeviceDetached(event);

View File

@ -37,7 +37,7 @@ public final class UsbStringDescriptorImpl extends
*/
@Override
public final byte[] bString()
public byte[] bString()
{
return this.descriptor.toString().getBytes();
}
@ -48,7 +48,7 @@ public final class UsbStringDescriptorImpl extends
*/
@Override
public final String getString()
public String getString()
{
return this.descriptor.toString();
}

View File

@ -5,7 +5,6 @@
package de.ailis.usb4java.jsr80;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
@ -14,7 +13,6 @@ import javax.usb.UsbConst;
import javax.usb.UsbControlIrp;
import javax.usb.UsbDevice;
import javax.usb.UsbDeviceDescriptor;
import javax.usb.UsbDisconnectedException;
import javax.usb.UsbException;
import javax.usb.UsbHub;
import javax.usb.UsbPort;
@ -45,7 +43,8 @@ final class VirtualRootHub implements UsbHub, UsbPorts
new ArrayList<UsbConfiguration>(1);
/** The device descriptor. */
private final UsbDeviceDescriptor descriptor = new VirtualUsbDeviceDescriptor();
private final UsbDeviceDescriptor descriptor =
new VirtualUsbDeviceDescriptor();
/** The device listeners. */
private final UsbDeviceListenerList listeners = new UsbDeviceListenerList();
@ -69,7 +68,7 @@ final class VirtualRootHub implements UsbHub, UsbPorts
*/
@Override
public UsbPort getParentUsbPort() throws UsbDisconnectedException
public UsbPort getParentUsbPort()
{
return null;
}
@ -91,8 +90,7 @@ final class VirtualRootHub implements UsbHub, UsbPorts
*/
@Override
public String getManufacturerString() throws UsbException,
UnsupportedEncodingException, UsbDisconnectedException
public String getManufacturerString()
{
return MANUFACTURER;
}
@ -103,8 +101,7 @@ final class VirtualRootHub implements UsbHub, UsbPorts
*/
@Override
public String getSerialNumberString() throws UsbException,
UnsupportedEncodingException, UsbDisconnectedException
public String getSerialNumberString()
{
return SERIAL_NUMBER;
}
@ -115,8 +112,7 @@ final class VirtualRootHub implements UsbHub, UsbPorts
*/
@Override
public String getProductString() throws UsbException,
UnsupportedEncodingException, UsbDisconnectedException
public String getProductString() throws UsbException
{
return PRODUCT;
}
@ -217,7 +213,7 @@ final class VirtualRootHub implements UsbHub, UsbPorts
@Override
public UsbStringDescriptor getUsbStringDescriptor(final byte index)
throws UsbException, UsbDisconnectedException
throws UsbException
{
throw new UsbException(
"Can't get USB string descriptor from virtual device");
@ -229,8 +225,7 @@ final class VirtualRootHub implements UsbHub, UsbPorts
*/
@Override
public String getString(final byte index) throws UsbException,
UnsupportedEncodingException, UsbDisconnectedException
public String getString(final byte index) throws UsbException
{
throw new UsbException("Can't get string from virtual device");
}
@ -241,8 +236,7 @@ final class VirtualRootHub implements UsbHub, UsbPorts
*/
@Override
public void syncSubmit(final UsbControlIrp irp) throws UsbException,
IllegalArgumentException, UsbDisconnectedException
public void syncSubmit(final UsbControlIrp irp) throws UsbException
{
throw new UsbException("Can't syncSubmit on virtual device");
}
@ -253,8 +247,7 @@ final class VirtualRootHub implements UsbHub, UsbPorts
*/
@Override
public void asyncSubmit(final UsbControlIrp irp) throws UsbException,
IllegalArgumentException, UsbDisconnectedException
public void asyncSubmit(final UsbControlIrp irp) throws UsbException
{
throw new UsbException("Can't asyncSubmit on virtual device");
}
@ -266,7 +259,7 @@ final class VirtualRootHub implements UsbHub, UsbPorts
@Override
public void syncSubmit(@SuppressWarnings("rawtypes") final List list)
throws UsbException, IllegalArgumentException, UsbDisconnectedException
throws UsbException
{
throw new UsbException("Can't syncSubmit on virtual device");
}
@ -278,8 +271,7 @@ final class VirtualRootHub implements UsbHub, UsbPorts
@Override
public void asyncSubmit(@SuppressWarnings("rawtypes") final List list)
throws UsbException,
IllegalArgumentException, UsbDisconnectedException
throws UsbException
{
throw new UsbException("Can't asyncSubmit on virtual device");
}
@ -294,7 +286,8 @@ final class VirtualRootHub implements UsbHub, UsbPorts
final byte bRequest,
final short wValue, final short wIndex)
{
return new DefaultUsbControlIrp(bmRequestType, bRequest, wValue, wIndex);
return new DefaultUsbControlIrp(bmRequestType, bRequest, wValue,
wIndex);
}

View File

@ -5,15 +5,12 @@
package de.ailis.usb4java.jsr80;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import javax.usb.UsbConfiguration;
import javax.usb.UsbConfigurationDescriptor;
import javax.usb.UsbDevice;
import javax.usb.UsbDisconnectedException;
import javax.usb.UsbException;
import javax.usb.UsbInterface;
@ -26,13 +23,15 @@ import javax.usb.UsbInterface;
final class VirtualUsbConfiguration implements UsbConfiguration
{
/** The virtual interfaces. */
private final List<UsbInterface> interfaces = new ArrayList<UsbInterface>();
private final List<UsbInterface> interfaces =
new ArrayList<UsbInterface>();
/** The device this configuration belongs to. */
private final UsbDevice device;
/** The USB configuration descriptor. */
private final UsbConfigurationDescriptor descriptor = new VirtualUsbConfigurationDescriptor();
private final UsbConfigurationDescriptor descriptor =
new VirtualUsbConfigurationDescriptor();
/**
@ -120,8 +119,7 @@ final class VirtualUsbConfiguration implements UsbConfiguration
*/
@Override
public String getConfigurationString() throws UsbException,
UnsupportedEncodingException, UsbDisconnectedException
public String getConfigurationString()
{
return null;
}

View File

@ -7,7 +7,6 @@ package de.ailis.usb4java.jsr80;
import javax.usb.UsbConfigurationDescriptor;
import javax.usb.UsbConst;
import javax.usb.UsbDescriptor;
/**
@ -19,8 +18,12 @@ import javax.usb.UsbDescriptor;
final class VirtualUsbConfigurationDescriptor implements
UsbConfigurationDescriptor
{
/** The configuration attributes. */
private static final byte ATTRIBUTES = (byte) 0x80;
/**
* @see UsbDescriptor#bLength()
* @see javax.usb.UsbDescriptor#bLength()
*/
@Override
@ -31,7 +34,7 @@ final class VirtualUsbConfigurationDescriptor implements
/**
* @see UsbDescriptor#bDescriptorType()
* @see javax.usb.UsbDescriptor#bDescriptorType()
*/
@Override
@ -48,7 +51,8 @@ final class VirtualUsbConfigurationDescriptor implements
@Override
public short wTotalLength()
{
return UsbConst.DESCRIPTOR_MIN_LENGTH_CONFIGURATION + UsbConst.DESCRIPTOR_MIN_LENGTH_INTERFACE;
return UsbConst.DESCRIPTOR_MIN_LENGTH_CONFIGURATION
+ UsbConst.DESCRIPTOR_MIN_LENGTH_INTERFACE;
}
@ -92,7 +96,7 @@ final class VirtualUsbConfigurationDescriptor implements
@Override
public byte bmAttributes()
{
return (byte) 0x80;
return ATTRIBUTES;
}

View File

@ -6,7 +6,6 @@
package de.ailis.usb4java.jsr80;
import javax.usb.UsbConst;
import javax.usb.UsbDescriptor;
import javax.usb.UsbDeviceDescriptor;
@ -18,8 +17,24 @@ import javax.usb.UsbDeviceDescriptor;
final class VirtualUsbDeviceDescriptor implements UsbDeviceDescriptor
{
/** The USB specification release number of the virtual usb device. */
private static final int BCD_USB = 0x101;
/** The maximum packet size of this virtual device. */
private static final byte MAX_PACKET_SIZE_0 = 8;
/** The manufacturer string descriptor index. */
private static final byte MANUFACTURER_INDEX = 1;
/** The product string descriptor index. */
private static final byte PRODUCT_INDEX = 2;
/** The serial number string descriptor index. */
private static final byte SERIAL_NUMBER_INDEX = 3;
/**
* @see UsbDescriptor#bLength()
* @see javax.usb.UsbDescriptor#bLength()
*/
@Override
@ -30,7 +45,7 @@ final class VirtualUsbDeviceDescriptor implements UsbDeviceDescriptor
/**
* @see UsbDescriptor#bDescriptorType()
* @see javax.usb.UsbDescriptor#bDescriptorType()
*/
@Override
@ -47,7 +62,7 @@ final class VirtualUsbDeviceDescriptor implements UsbDeviceDescriptor
@Override
public short bcdUSB()
{
return 0x101;
return BCD_USB;
}
@ -91,7 +106,7 @@ final class VirtualUsbDeviceDescriptor implements UsbDeviceDescriptor
@Override
public byte bMaxPacketSize0()
{
return 8;
return MAX_PACKET_SIZE_0;
}
@ -135,7 +150,7 @@ final class VirtualUsbDeviceDescriptor implements UsbDeviceDescriptor
@Override
public byte iManufacturer()
{
return 1;
return MANUFACTURER_INDEX;
}
@ -146,7 +161,7 @@ final class VirtualUsbDeviceDescriptor implements UsbDeviceDescriptor
@Override
public byte iProduct()
{
return 2;
return PRODUCT_INDEX;
}
@ -157,7 +172,7 @@ final class VirtualUsbDeviceDescriptor implements UsbDeviceDescriptor
@Override
public byte iSerialNumber()
{
return 3;
return SERIAL_NUMBER_INDEX;
}

View File

@ -5,19 +5,15 @@
package de.ailis.usb4java.jsr80;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import javax.usb.UsbClaimException;
import javax.usb.UsbConfiguration;
import javax.usb.UsbDisconnectedException;
import javax.usb.UsbEndpoint;
import javax.usb.UsbException;
import javax.usb.UsbInterface;
import javax.usb.UsbInterfaceDescriptor;
import javax.usb.UsbInterfacePolicy;
import javax.usb.UsbNotActiveException;
/**
@ -38,11 +34,12 @@ final class VirtualUsbInterface implements UsbInterface
private final UsbConfiguration configuration;
/** The interface descriptor. */
private final UsbInterfaceDescriptor descriptor = new VirtualUsbInterfaceDescriptor();
private final UsbInterfaceDescriptor descriptor =
new VirtualUsbInterfaceDescriptor();
/**
* Constructor
* Constructor.
*
* @param configuration
* The USB configuration.
@ -58,8 +55,7 @@ final class VirtualUsbInterface implements UsbInterface
*/
@Override
public void claim() throws UsbClaimException, UsbException,
UsbNotActiveException, UsbDisconnectedException
public void claim() throws UsbException
{
throw new UsbException("Virtual interfaces can't be claimed");
}
@ -70,9 +66,7 @@ final class VirtualUsbInterface implements UsbInterface
*/
@Override
public void claim(final UsbInterfacePolicy policy)
throws UsbClaimException,
UsbException, UsbNotActiveException, UsbDisconnectedException
public void claim(final UsbInterfacePolicy policy) throws UsbException
{
throw new UsbException("Virtual interfaces can't be claimed");
}
@ -83,8 +77,7 @@ final class VirtualUsbInterface implements UsbInterface
*/
@Override
public void release() throws UsbClaimException, UsbException,
UsbNotActiveException, UsbDisconnectedException
public void release() throws UsbException
{
throw new UsbException("Virtual interfaces can't be released");
}
@ -128,7 +121,7 @@ final class VirtualUsbInterface implements UsbInterface
*/
@Override
public byte getActiveSettingNumber() throws UsbNotActiveException
public byte getActiveSettingNumber()
{
return 0;
}
@ -139,7 +132,7 @@ final class VirtualUsbInterface implements UsbInterface
*/
@Override
public UsbInterface getActiveSetting() throws UsbNotActiveException
public UsbInterface getActiveSetting()
{
return this;
}
@ -238,8 +231,7 @@ final class VirtualUsbInterface implements UsbInterface
*/
@Override
public String getInterfaceString() throws UsbException,
UnsupportedEncodingException, UsbDisconnectedException
public String getInterfaceString()
{
return null;
}

View File

@ -6,7 +6,6 @@
package de.ailis.usb4java.jsr80;
import javax.usb.UsbConst;
import javax.usb.UsbDescriptor;
import javax.usb.UsbInterfaceDescriptor;
@ -19,7 +18,7 @@ import javax.usb.UsbInterfaceDescriptor;
final class VirtualUsbInterfaceDescriptor implements UsbInterfaceDescriptor
{
/**
* @see UsbDescriptor#bLength()
* @see javax.usb.UsbDescriptor#bLength()
*/
@Override
@ -30,7 +29,7 @@ final class VirtualUsbInterfaceDescriptor implements UsbInterfaceDescriptor
/**
* @see UsbDescriptor#bDescriptorType()
* @see javax.usb.UsbDescriptor#bDescriptorType()
*/
@Override

View File

@ -0,0 +1,12 @@
/*
* Copyright (C) 2011 Klaus Reimer <k@ailis.de>
* See LICENSE.txt for licensing information.
*/
/**
* JSR-80 implementation of usb4java.
*
* @author Klaus Reimer (k@ailis.de)
*/
package de.ailis.usb4java.jsr80;

View File

@ -20,8 +20,18 @@ import de.ailis.usb4java.USB_Device_Descriptor;
* @author Klaus Reimer (k@ailis.de)
*/
public class Dump
public final class Dump
{
/**
* Private constructor to prevent instantiation.
*/
private Dump()
{
// Empty
}
/**
* Dumps the device tree. Please note that the displayed tree can only
* display devices to which the user has write access. On some platforms

View File

@ -0,0 +1,12 @@
/*
* Copyright (C) 2011 Klaus Reimer <k@ailis.de>
* See LICENSE.txt for licensing information.
*/
/**
* usb4java tools.
*
* @author Klaus Reimer (k@ailis.de)
*/
package de.ailis.usb4java.tools;

View File

@ -4,10 +4,12 @@
What is usb4java?
usb4java is a Java library to access USB devices. It is based on the native
{{{http://www.libusb.org/}libusb 0.1}} shared library and reflects this
API as complete as possible. Java NIO buffers are used for data exchange
between libusb and Java.
usb4java is a Java library to access USB devices. The low-level part is
based on the native {{{http://www.libusb.org/}libusb 0.1}} shared library
and reflects this API as complete as possible. Java NIO buffers are used
for data exchange between libusb and Java. The high-level part implements
the {{{http://www.java-usb.org/}javax.usb standard (JSR-80)}} but this part
is not well tested at the moment.
Supported platforms are Linux (Intel 32/64 bit), Mac OS X (Intel 32/64 bit,
PowerPC 32 bit) and Windows (Intel 32/64 bit). But other platforms may work