Complete check of all Java code.
Reformatted dump/hashCode/equals to be clear, easy to read and compare to the list of methods available. Added missing constants to LibUsb, correctly sized some of them to be in accordance with the size of types they are compared to or used with.
This commit is contained in:
parent
069f0a24d8
commit
2e7959093e
@ -96,18 +96,38 @@ public final class BosDescriptor
|
||||
public String dump()
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append(String.format("BOS Descriptor:%n" + " bLength %18d%n"
|
||||
+ " bDescriptorType %10d%n" + " wTotalLength %13s%n"
|
||||
+ " bNumDeviceCaps %11s%n", this.bLength() & 0xff,
|
||||
this.bDescriptorType() & 0xff, this.wTotalLength() & 0xffff,
|
||||
this.bNumDeviceCaps() & 0xff));
|
||||
|
||||
builder.append(String.format(
|
||||
"BOS Descriptor:%n" +
|
||||
" bLength %18d%n" +
|
||||
" bDescriptorType %10d%n" +
|
||||
" wTotalLength %13s%n" +
|
||||
" bNumDeviceCaps %11s%n",
|
||||
this.bLength() & 0xFF,
|
||||
this.bDescriptorType() & 0xFF,
|
||||
this.wTotalLength() & 0xFFFF,
|
||||
this.bNumDeviceCaps() & 0xFF));
|
||||
|
||||
for (final BosDevCapabilityDescriptor descriptor : this.devCapability())
|
||||
{
|
||||
builder.append(descriptor.dump().replaceAll("(?m)^", " "));
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder()
|
||||
.append(this.bLength())
|
||||
.append(this.bDescriptorType())
|
||||
.append(this.wTotalLength())
|
||||
.append(this.bNumDeviceCaps())
|
||||
.append(this.devCapability())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj)
|
||||
{
|
||||
@ -123,22 +143,16 @@ public final class BosDescriptor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final BosDescriptor other = (BosDescriptor) obj;
|
||||
|
||||
return new EqualsBuilder()
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.wTotalLength(), other.wTotalLength())
|
||||
.append(this.bNumDeviceCaps(), other.bNumDeviceCaps())
|
||||
.append(this.devCapability(), other.devCapability()).isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.bLength())
|
||||
.append(this.bDescriptorType()).append(this.wTotalLength())
|
||||
.append(this.bNumDeviceCaps()).append(this.devCapability())
|
||||
.toHashCode();
|
||||
.append(this.devCapability(), other.devCapability())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -93,15 +93,27 @@ public final class BosDevCapabilityDescriptor
|
||||
public String dump()
|
||||
{
|
||||
return String.format(
|
||||
"BOS Device Capability Descriptor:%n" + " bLength %18d%n"
|
||||
+ " bDescriptorType %10d%n" + " bDevCapabilityType %7s%n"
|
||||
+ " devCapabilityData:%n%s%n",
|
||||
this.bLength() & 0xff,
|
||||
this.bDescriptorType() & 0xff,
|
||||
this.bDevCapabilityType() & 0xff,
|
||||
DescriptorUtils.dump(this.devCapabilityData()).replaceAll("(?m)^",
|
||||
" "));
|
||||
"BOS Device Capability Descriptor:%n" +
|
||||
" bLength %18d%n" +
|
||||
" bDescriptorType %10d%n" +
|
||||
" bDevCapabilityType %7s%n" +
|
||||
" devCapabilityData:%n%s%n",
|
||||
this.bLength() & 0xFF,
|
||||
this.bDescriptorType() & 0xFF,
|
||||
this.bDevCapabilityType() & 0xFF,
|
||||
DescriptorUtils.dump(this.devCapabilityData())
|
||||
.replaceAll("(?m)^", " "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder()
|
||||
.append(this.bLength())
|
||||
.append(this.bDescriptorType())
|
||||
.append(this.bDevCapabilityType())
|
||||
.append(this.devCapabilityData())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,21 +131,15 @@ public final class BosDevCapabilityDescriptor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final BosDevCapabilityDescriptor other = (BosDevCapabilityDescriptor) obj;
|
||||
return new EqualsBuilder()
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDevCapabilityType(), other.bDevCapabilityType())
|
||||
.append(this.devCapabilityData().array(),
|
||||
other.devCapabilityData().array()).isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.bLength())
|
||||
.append(this.bDescriptorType()).append(this.bDevCapabilityType())
|
||||
.append(this.devCapabilityData()).toHashCode();
|
||||
final BosDevCapabilityDescriptor other = (BosDevCapabilityDescriptor) obj;
|
||||
|
||||
return new EqualsBuilder()
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bDevCapabilityType(), other.bDevCapabilityType())
|
||||
.append(this.devCapabilityData(), other.devCapabilityData()).
|
||||
isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -116,8 +116,12 @@ public final class ConfigDescriptor implements UsbConfigurationDescriptor
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(String.format("%s%n" + " extralen %17d%n"
|
||||
+ " extra:%n" + "%s", DescriptorUtils.dump(this),
|
||||
builder.append(String.format(
|
||||
"%s%n" +
|
||||
" extralen %17d%n" +
|
||||
" extra:%n" +
|
||||
"%s",
|
||||
DescriptorUtils.dump(this),
|
||||
this.extraLength(),
|
||||
DescriptorUtils.dump(this.extra()).replaceAll("(?m)^", " ")));
|
||||
|
||||
@ -132,12 +136,19 @@ public final class ConfigDescriptor implements UsbConfigurationDescriptor
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.bLength())
|
||||
.append(this.bDescriptorType()).append(this.wTotalLength())
|
||||
.append(this.bNumInterfaces()).append(this.bConfigurationValue())
|
||||
.append(this.iConfiguration()).append(this.bmAttributes())
|
||||
.append(this.bMaxPower()).append(this.iface()).append(this.extra())
|
||||
.append(this.extraLength()).toHashCode();
|
||||
return new HashCodeBuilder()
|
||||
.append(this.bLength())
|
||||
.append(this.bDescriptorType())
|
||||
.append(this.wTotalLength())
|
||||
.append(this.bNumInterfaces())
|
||||
.append(this.bConfigurationValue())
|
||||
.append(this.iConfiguration())
|
||||
.append(this.bmAttributes())
|
||||
.append(this.bMaxPower())
|
||||
.append(this.iface())
|
||||
.append(this.extra())
|
||||
.append(this.extraLength())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -158,7 +169,8 @@ public final class ConfigDescriptor implements UsbConfigurationDescriptor
|
||||
|
||||
final ConfigDescriptor other = (ConfigDescriptor) obj;
|
||||
|
||||
return new EqualsBuilder().append(this.bLength(), other.bLength())
|
||||
return new EqualsBuilder()
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.wTotalLength(), other.wTotalLength())
|
||||
.append(this.bNumInterfaces(), other.bNumInterfaces())
|
||||
@ -168,7 +180,8 @@ public final class ConfigDescriptor implements UsbConfigurationDescriptor
|
||||
.append(this.bMaxPower(), other.bMaxPower())
|
||||
.append(this.iface(), other.iface())
|
||||
.append(this.extra(), other.extra())
|
||||
.append(this.extraLength(), other.extraLength()).isEquals();
|
||||
.append(this.extraLength(), other.extraLength())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -101,15 +101,33 @@ public final class ContainerIdDescriptor
|
||||
*/
|
||||
public String dump()
|
||||
{
|
||||
return String.format("Container Id Descriptor:%n" + " bLength %18d%n"
|
||||
+ " bDescriptorType %10d%n" + " bDevCapabilityType %7d%n"
|
||||
+ " bReserved %16d%n" + " containerId:%n%s%n",
|
||||
this.bLength() & 0xff, this.bDescriptorType() & 0xff, this
|
||||
.bDevCapabilityType() & 0xff, this.bReserved() & 0xff,
|
||||
return String.format(
|
||||
"Container ID Descriptor:%n" +
|
||||
" bLength %18d%n" +
|
||||
" bDescriptorType %10d%n" +
|
||||
" bDevCapabilityType %7d%n" +
|
||||
" bReserved %16d%n" +
|
||||
" ContainerID:%n%s%n",
|
||||
this.bLength() & 0xFF,
|
||||
this.bDescriptorType() & 0xFF,
|
||||
this.bDevCapabilityType() & 0xFF,
|
||||
this.bReserved() & 0xFF,
|
||||
DescriptorUtils.dump(this.containerId())
|
||||
.replaceAll("(?m)^", " "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder()
|
||||
.append(this.bLength())
|
||||
.append(this.bDescriptorType())
|
||||
.append(this.bDevCapabilityType())
|
||||
.append(this.bReserved())
|
||||
.append(this.containerId())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj)
|
||||
{
|
||||
@ -125,24 +143,18 @@ public final class ContainerIdDescriptor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final ContainerIdDescriptor other = (ContainerIdDescriptor) obj;
|
||||
|
||||
return new EqualsBuilder()
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bDevCapabilityType(), other.bDevCapabilityType())
|
||||
.append(this.bReserved(), other.bReserved())
|
||||
.append(this.containerId().array(), other.containerId().array())
|
||||
.append(this.containerId(), other.containerId())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.bLength())
|
||||
.append(this.bDescriptorType()).append(this.bDevCapabilityType())
|
||||
.append(this.bReserved()).append(this.containerId()).toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
||||
@ -132,14 +132,22 @@ public final class DeviceDescriptor implements UsbDeviceDescriptor
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.bLength())
|
||||
.append(this.bDescriptorType()).append(this.bcdUSB())
|
||||
.append(this.bDeviceClass()).append(this.bDeviceSubClass())
|
||||
.append(this.bDeviceProtocol()).append(this.bMaxPacketSize0())
|
||||
.append(this.idVendor()).append(this.idProduct())
|
||||
.append(this.bcdDevice()).append(this.iManufacturer())
|
||||
.append(this.iProduct()).append(this.iSerialNumber())
|
||||
.append(this.bNumConfigurations()).toHashCode();
|
||||
return new HashCodeBuilder()
|
||||
.append(this.bLength())
|
||||
.append(this.bDescriptorType())
|
||||
.append(this.bcdUSB())
|
||||
.append(this.bDeviceClass())
|
||||
.append(this.bDeviceSubClass())
|
||||
.append(this.bDeviceProtocol())
|
||||
.append(this.bMaxPacketSize0())
|
||||
.append(this.idVendor())
|
||||
.append(this.idProduct())
|
||||
.append(this.bcdDevice())
|
||||
.append(this.iManufacturer())
|
||||
.append(this.iProduct())
|
||||
.append(this.iSerialNumber())
|
||||
.append(this.bNumConfigurations())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -160,7 +168,8 @@ public final class DeviceDescriptor implements UsbDeviceDescriptor
|
||||
|
||||
final DeviceDescriptor other = (DeviceDescriptor) obj;
|
||||
|
||||
return new EqualsBuilder().append(this.bLength(), other.bLength())
|
||||
return new EqualsBuilder()
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bcdUSB(), other.bcdUSB())
|
||||
.append(this.bDeviceClass(), other.bDeviceClass())
|
||||
|
||||
@ -117,20 +117,30 @@ public final class EndpointDescriptor implements UsbEndpointDescriptor
|
||||
public String dump()
|
||||
{
|
||||
return String.format(
|
||||
"%s%n" + " extralen %17d%n" + " extra:%n" + "%s", DescriptorUtils
|
||||
.dump(this), this.extraLength(),
|
||||
"%s%n" +
|
||||
" extralen %17d%n" +
|
||||
" extra:%n" +
|
||||
"%s",
|
||||
DescriptorUtils.dump(this),
|
||||
this.extraLength(),
|
||||
DescriptorUtils.dump(this.extra()).replaceAll("(?m)^", " "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.bLength())
|
||||
.append(this.bDescriptorType()).append(this.bEndpointAddress())
|
||||
.append(this.bmAttributes()).append(this.wMaxPacketSize())
|
||||
.append(this.bInterval()).append(this.bRefresh())
|
||||
.append(this.bSynchAddress()).append(this.extra())
|
||||
.append(this.extraLength()).toHashCode();
|
||||
return new HashCodeBuilder()
|
||||
.append(this.bLength())
|
||||
.append(this.bDescriptorType())
|
||||
.append(this.bEndpointAddress())
|
||||
.append(this.bmAttributes())
|
||||
.append(this.wMaxPacketSize())
|
||||
.append(this.bInterval())
|
||||
.append(this.bRefresh())
|
||||
.append(this.bSynchAddress())
|
||||
.append(this.extra())
|
||||
.append(this.extraLength())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,7 +161,8 @@ public final class EndpointDescriptor implements UsbEndpointDescriptor
|
||||
|
||||
final EndpointDescriptor other = (EndpointDescriptor) obj;
|
||||
|
||||
return new EqualsBuilder().append(this.bLength(), other.bLength())
|
||||
return new EqualsBuilder()
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bEndpointAddress(), other.bEndpointAddress())
|
||||
.append(this.bmAttributes(), other.bmAttributes())
|
||||
@ -160,7 +171,8 @@ public final class EndpointDescriptor implements UsbEndpointDescriptor
|
||||
.append(this.bRefresh(), other.bRefresh())
|
||||
.append(this.bSynchAddress(), other.bSynchAddress())
|
||||
.append(this.extra(), other.extra())
|
||||
.append(this.extraLength(), other.extraLength()).isEquals();
|
||||
.append(this.extraLength(), other.extraLength())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -74,7 +74,9 @@ public final class Interface
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(String.format("Interface:%n" + " numAltsetting %10d",
|
||||
builder.append(String.format(
|
||||
"Interface:%n" +
|
||||
" numAltsetting %10d",
|
||||
this.numAltsetting()));
|
||||
|
||||
for (final InterfaceDescriptor intDesc : this.altsetting())
|
||||
@ -88,8 +90,10 @@ public final class Interface
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.altsetting())
|
||||
.append(this.numAltsetting()).toHashCode();
|
||||
return new HashCodeBuilder()
|
||||
.append(this.altsetting())
|
||||
.append(this.numAltsetting())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -112,7 +116,8 @@ public final class Interface
|
||||
|
||||
return new EqualsBuilder()
|
||||
.append(this.altsetting(), other.altsetting())
|
||||
.append(this.numAltsetting(), other.numAltsetting()).isEquals();
|
||||
.append(this.numAltsetting(), other.numAltsetting())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -119,8 +119,12 @@ public final class InterfaceDescriptor implements UsbInterfaceDescriptor
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(String.format("%s%n" + " extralen %17d%n"
|
||||
+ " extra:%n" + "%s", DescriptorUtils.dump(this),
|
||||
builder.append(String.format(
|
||||
"%s%n" +
|
||||
" extralen %17d%n" +
|
||||
" extra:%n" +
|
||||
"%s",
|
||||
DescriptorUtils.dump(this),
|
||||
this.extraLength(),
|
||||
DescriptorUtils.dump(this.extra()).replaceAll("(?m)^", " ")));
|
||||
|
||||
@ -135,13 +139,20 @@ public final class InterfaceDescriptor implements UsbInterfaceDescriptor
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.bLength())
|
||||
.append(this.bDescriptorType()).append(this.bInterfaceNumber())
|
||||
.append(this.bAlternateSetting()).append(this.bNumEndpoints())
|
||||
.append(this.bInterfaceClass()).append(this.bInterfaceSubClass())
|
||||
.append(this.bInterfaceProtocol()).append(this.iInterface())
|
||||
.append(this.endpoint()).append(this.extra())
|
||||
.append(this.extraLength()).toHashCode();
|
||||
return new HashCodeBuilder()
|
||||
.append(this.bLength())
|
||||
.append(this.bDescriptorType())
|
||||
.append(this.bInterfaceNumber())
|
||||
.append(this.bAlternateSetting())
|
||||
.append(this.bNumEndpoints())
|
||||
.append(this.bInterfaceClass())
|
||||
.append(this.bInterfaceSubClass())
|
||||
.append(this.bInterfaceProtocol())
|
||||
.append(this.iInterface())
|
||||
.append(this.endpoint())
|
||||
.append(this.extra())
|
||||
.append(this.extraLength())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,7 +173,8 @@ public final class InterfaceDescriptor implements UsbInterfaceDescriptor
|
||||
|
||||
final InterfaceDescriptor other = (InterfaceDescriptor) obj;
|
||||
|
||||
return new EqualsBuilder().append(this.bLength(), other.bLength())
|
||||
return new EqualsBuilder()
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bInterfaceNumber(), other.bInterfaceNumber())
|
||||
.append(this.bAlternateSetting(), other.bAlternateSetting())
|
||||
@ -173,7 +185,8 @@ public final class InterfaceDescriptor implements UsbInterfaceDescriptor
|
||||
.append(this.iInterface(), other.iInterface())
|
||||
.append(this.endpoint(), other.endpoint())
|
||||
.append(this.extra(), other.extra())
|
||||
.append(this.extraLength(), other.extraLength()).isEquals();
|
||||
.append(this.extraLength(), other.extraLength())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -105,6 +105,9 @@ public final class LibUsb
|
||||
/** Other error. */
|
||||
public static final int ERROR_OTHER = -99;
|
||||
|
||||
/** Total number of error codes */
|
||||
public static final int ERROR_COUNT = 14;
|
||||
|
||||
// Speed codes. Indicates the speed at which the device is operating.
|
||||
|
||||
/** The OS doesn't report or know the device speed. */
|
||||
@ -126,16 +129,16 @@ public final class LibUsb
|
||||
// device supports.
|
||||
|
||||
/** Low speed operation supported (1.5MBit/s). */
|
||||
public static final int LOW_SPEED_OPERATION = 1;
|
||||
public static final short LOW_SPEED_OPERATION = 1;
|
||||
|
||||
/** Full speed operation supported (12MBit/s). */
|
||||
public static final int FULL_SPEED_OPERATION = 2;
|
||||
public static final short FULL_SPEED_OPERATION = 2;
|
||||
|
||||
/** High speed operation supported (480MBit/s). */
|
||||
public static final int HIGH_SPEED_OPERATION = 4;
|
||||
public static final short HIGH_SPEED_OPERATION = 4;
|
||||
|
||||
/** Superspeed operation supported (5000MBit/s). */
|
||||
public static final int SUPER_SPEED_OPERATION = 8;
|
||||
public static final short SUPER_SPEED_OPERATION = 8;
|
||||
|
||||
// Masks for the bits of the bmAttributes field of the USB 2.0 Extension
|
||||
// descriptor.
|
||||
@ -147,21 +150,21 @@ public final class LibUsb
|
||||
// Device Capability descriptor.
|
||||
|
||||
/** Supports Latency Tolerance Messages (LTM). */
|
||||
public static final int BM_LTM_SUPPORT = 2;
|
||||
public static final byte BM_LTM_SUPPORT = 2;
|
||||
|
||||
// USB capability types.
|
||||
|
||||
/** Wireless USB device capability. */
|
||||
public static final int BT_WIRELESS_USB_DEVICE_CAPABILITY = 1;
|
||||
public static final byte BT_WIRELESS_USB_DEVICE_CAPABILITY = 1;
|
||||
|
||||
/** USB 2.0 extensions. */
|
||||
public static final int BT_USB_2_0_EXTENSION = 2;
|
||||
public static final byte BT_USB_2_0_EXTENSION = 2;
|
||||
|
||||
/** SuperSpeed USB device capability. */
|
||||
public static final int BT_SS_USB_DEVICE_CAPABILITY = 3;
|
||||
public static final byte BT_SS_USB_DEVICE_CAPABILITY = 3;
|
||||
|
||||
/** Container ID type. */
|
||||
public static final int BT_CONTAINER_ID = 4;
|
||||
public static final byte BT_CONTAINER_ID = 4;
|
||||
|
||||
// Standard requests, as defined in table 9-5 of the USB 3.0 specifications.
|
||||
|
||||
@ -406,15 +409,39 @@ public final class LibUsb
|
||||
/** Size of an interface descriptor. */
|
||||
public static final byte DT_INTERFACE_SIZE = 9;
|
||||
|
||||
/** Size of an interface descriptor. */
|
||||
/** Size of an endpoint descriptor. */
|
||||
public static final byte DT_ENDPOINT_SIZE = 7;
|
||||
|
||||
/** Size of an interface descriptor. */
|
||||
/** Size of an endpoint descriptor with audio extension. */
|
||||
public static final byte DT_ENDPOINT_AUDIO_SIZE = 9;
|
||||
|
||||
/** Size of an interface descriptor. */
|
||||
/** Size of a hub descriptor. */
|
||||
public static final byte DT_HUB_NONVAR_SIZE = 7;
|
||||
|
||||
/** Size of a SuperSpeed endpoint companion descriptor. */
|
||||
public static final byte DT_SS_ENDPOINT_COMPANION_SIZE = 6;
|
||||
|
||||
/** Size of a BOS descriptor. */
|
||||
public static final byte DT_BOS_SIZE = 5;
|
||||
|
||||
/** Size of a device capability descriptor. */
|
||||
public static final byte DT_DEVICE_CAPABILITY_SIZE = 3;
|
||||
|
||||
// BOS descriptor sizes
|
||||
|
||||
/** Size of a BOS descriptor. */
|
||||
public static final byte BT_USB_2_0_EXTENSION_SIZE = 7;
|
||||
|
||||
/** Size of a BOS descriptor. */
|
||||
public static final byte BT_SS_USB_DEVICE_CAPABILITY_SIZE = 10;
|
||||
|
||||
/** Size of a BOS descriptor. */
|
||||
public static final byte BT_CONTAINER_ID_SIZE = 20;
|
||||
|
||||
/** We unwrap the BOS => define its maximum size */
|
||||
public static final byte DT_BOS_MAX_SIZE = ((DT_BOS_SIZE)
|
||||
+ (BT_USB_2_0_EXTENSION_SIZE) + (BT_SS_USB_DEVICE_CAPABILITY_SIZE) + (BT_CONTAINER_ID_SIZE));
|
||||
|
||||
// Endpoint direction. Values for bit 7 of the endpoint address scheme.
|
||||
|
||||
/** In: device-to-host. */
|
||||
@ -564,7 +591,8 @@ public final class LibUsb
|
||||
/**
|
||||
* pollfd listeners (to support different listeners for different contexts).
|
||||
*/
|
||||
private static final ConcurrentMap<Long, ImmutablePair<PollfdListener, Object>> pollfdListeners = new ConcurrentHashMap<Long, ImmutablePair<PollfdListener, Object>>();
|
||||
private static final ConcurrentMap<Long, ImmutablePair<PollfdListener, Object>> pollfdListeners =
|
||||
new ConcurrentHashMap<Long, ImmutablePair<PollfdListener, Object>>();
|
||||
|
||||
static
|
||||
{
|
||||
|
||||
@ -101,12 +101,30 @@ public final class SsEndpointCompanionDescriptor
|
||||
*/
|
||||
public String dump()
|
||||
{
|
||||
return String.format("Device Descriptor:%n" + " bLength %18d%n"
|
||||
+ " bDescriptorType %10d%n" + " bMaxBurst %16s%n"
|
||||
+ " bmAttributes %13d%n" + " wBytesPerInterval %8d%n",
|
||||
this.bLength() & 0xff, this.bDescriptorType() & 0xff,
|
||||
this.bMaxBurst() & 0xff, this.bmAttributes() & 0xff,
|
||||
this.wBytesPerInterval() & 0xffff);
|
||||
return String.format(
|
||||
"SuperSpeed Endpoint Companion Descriptor:%n" +
|
||||
" bLength %18d%n" +
|
||||
" bDescriptorType %10d%n" +
|
||||
" bMaxBurst %16s%n" +
|
||||
" bmAttributes %13d%n" +
|
||||
" wBytesPerInterval %8d%n",
|
||||
this.bLength() & 0xFF,
|
||||
this.bDescriptorType() & 0xFF,
|
||||
this.bMaxBurst() & 0xFF,
|
||||
this.bmAttributes() & 0xFF,
|
||||
this.wBytesPerInterval() & 0xFFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder()
|
||||
.append(this.bLength())
|
||||
.append(this.bDescriptorType())
|
||||
.append(this.bMaxBurst())
|
||||
.append(this.bmAttributes())
|
||||
.append(this.wBytesPerInterval())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,25 +142,18 @@ public final class SsEndpointCompanionDescriptor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final SsEndpointCompanionDescriptor other = (SsEndpointCompanionDescriptor) obj;
|
||||
|
||||
return new EqualsBuilder()
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bMaxBurst(), other.bMaxBurst())
|
||||
.append(this.bmAttributes(), other.bmAttributes())
|
||||
.append(this.wBytesPerInterval(), other.wBytesPerInterval())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.bLength())
|
||||
.append(this.bDescriptorType()).append(this.bMaxBurst())
|
||||
.append(this.bmAttributes()).append(this.wBytesPerInterval())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
||||
@ -121,17 +121,39 @@ public final class SsUsbDeviceCapabilityDescriptor
|
||||
*/
|
||||
public String dump()
|
||||
{
|
||||
return String.format("SuperSpeed USB Device Capability descriptor:%n"
|
||||
+ " bLength %18d%n" + " bDescriptorType %10d%n"
|
||||
+ " bDevCapabilityType %7d%n" + " bmAttributes %13s%n"
|
||||
+ " wSpeedSupported %10d%n" + " bFunctionalitySupport %4d%n"
|
||||
+ " bU1DevExitLat %12d%n" + " bU2DevExitLat %12d%n",
|
||||
this.bLength() & 0xff, this.bDescriptorType() & 0xff,
|
||||
this.bDevCapabilityType() & 0xff,
|
||||
String.format("0x%02x", this.bmAttributes() & 0xff),
|
||||
this.wSpeedSupported() & 0xffff,
|
||||
this.bFunctionalitySupport() & 0xff, this.bU1DevExitLat() & 0xff,
|
||||
this.bU2DevExitLat() & 0xffff);
|
||||
return String.format(
|
||||
"SuperSpeed USB Device Capability Descriptor:%n" +
|
||||
" bLength %18d%n" +
|
||||
" bDescriptorType %10d%n" +
|
||||
" bDevCapabilityType %7d%n" +
|
||||
" bmAttributes %13s%n" +
|
||||
" wSpeedSupported %10d%n" +
|
||||
" bFunctionalitySupport %4d%n" +
|
||||
" bU1DevExitLat %12d%n" +
|
||||
" bU2DevExitLat %12d%n",
|
||||
this.bLength() & 0xFF,
|
||||
this.bDescriptorType() & 0xFF,
|
||||
this.bDevCapabilityType() & 0xFF,
|
||||
String.format("0x%02x", this.bmAttributes() & 0xFF),
|
||||
this.wSpeedSupported() & 0xFFFF,
|
||||
this.bFunctionalitySupport() & 0xFF,
|
||||
this.bU1DevExitLat() & 0xFF,
|
||||
this.bU2DevExitLat() & 0xFFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder()
|
||||
.append(this.bLength())
|
||||
.append(this.bDescriptorType())
|
||||
.append(this.bDevCapabilityType())
|
||||
.append(this.bmAttributes())
|
||||
.append(this.wSpeedSupported())
|
||||
.append(this.bFunctionalitySupport())
|
||||
.append(this.bU1DevExitLat())
|
||||
.append(this.bU2DevExitLat())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -149,26 +171,19 @@ public final class SsUsbDeviceCapabilityDescriptor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final SsUsbDeviceCapabilityDescriptor other = (SsUsbDeviceCapabilityDescriptor) obj;
|
||||
|
||||
return new EqualsBuilder()
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bDevCapabilityType(), other.bDevCapabilityType())
|
||||
.append(this.bmAttributes(), other.bmAttributes())
|
||||
.append(this.wSpeedSupported(), other.wSpeedSupported())
|
||||
.append(this.bFunctionalitySupport(), other.bFunctionalitySupport())
|
||||
.append(this.bU1DevExitLat(), other.bU1DevExitLat())
|
||||
.append(this.bU2DevExitLat(), other.bU2DevExitLat()).isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.bLength())
|
||||
.append(this.bDescriptorType()).append(this.bDevCapabilityType())
|
||||
.append(this.bmAttributes()).append(this.wSpeedSupported())
|
||||
.append(this.bFunctionalitySupport()).append(this.bU1DevExitLat())
|
||||
.append(this.bU2DevExitLat()).toHashCode();
|
||||
.append(this.bU2DevExitLat(), other.bU2DevExitLat())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -89,14 +89,29 @@ public final class Usb20ExtensionDescriptor
|
||||
*/
|
||||
public String dump()
|
||||
{
|
||||
return String.format("USB 2.0 Extension Descriptor:%n"
|
||||
+ " bLength %18d%n" + " bDescriptorType %10d%n"
|
||||
+ " bDevCapabilityType %7d%n" + " bmAttributes %13s%n",
|
||||
this.bLength() & 0xff, this.bDescriptorType() & 0xff,
|
||||
this.bDevCapabilityType() & 0xff,
|
||||
return String.format(
|
||||
"USB 2.0 Extension Descriptor:%n" +
|
||||
" bLength %18d%n" +
|
||||
" bDescriptorType %10d%n" +
|
||||
" bDevCapabilityType %7d%n" +
|
||||
" bmAttributes %13s%n",
|
||||
this.bLength() & 0xFF,
|
||||
this.bDescriptorType() & 0xFF,
|
||||
this.bDevCapabilityType() & 0xFF,
|
||||
String.format("0x%08x", this.bmAttributes()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder()
|
||||
.append(this.bLength())
|
||||
.append(this.bDescriptorType())
|
||||
.append(this.bDevCapabilityType())
|
||||
.append(this.bmAttributes())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj)
|
||||
{
|
||||
@ -112,20 +127,15 @@ public final class Usb20ExtensionDescriptor
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final Usb20ExtensionDescriptor other = (Usb20ExtensionDescriptor) obj;
|
||||
return new EqualsBuilder()
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDevCapabilityType(), other.bDevCapabilityType())
|
||||
.append(this.bmAttributes(), other.bmAttributes()).isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.bLength())
|
||||
.append(this.bDescriptorType()).append(this.bDevCapabilityType())
|
||||
.append(this.bmAttributes()).toHashCode();
|
||||
final Usb20ExtensionDescriptor other = (Usb20ExtensionDescriptor) obj;
|
||||
|
||||
return new EqualsBuilder()
|
||||
.append(this.bLength(), other.bLength())
|
||||
.append(this.bDescriptorType(), other.bDescriptorType())
|
||||
.append(this.bDevCapabilityType(), other.bDevCapabilityType())
|
||||
.append(this.bmAttributes(), other.bmAttributes())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -89,8 +89,12 @@ public final class Version implements Comparable<Version>
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(this.major()).append(this.minor())
|
||||
.append(this.micro()).append(this.nano()).append(this.rc())
|
||||
return new HashCodeBuilder()
|
||||
.append(this.major())
|
||||
.append(this.minor())
|
||||
.append(this.micro())
|
||||
.append(this.nano())
|
||||
.append(this.rc())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
@ -112,10 +116,12 @@ public final class Version implements Comparable<Version>
|
||||
|
||||
final Version other = (Version) obj;
|
||||
|
||||
return new EqualsBuilder().append(this.major(), other.major())
|
||||
return new EqualsBuilder()
|
||||
.append(this.major(), other.major())
|
||||
.append(this.minor(), other.minor())
|
||||
.append(this.micro(), other.micro())
|
||||
.append(this.nano(), other.nano()).append(this.rc(), other.rc())
|
||||
.append(this.nano(), other.nano())
|
||||
.append(this.rc(), other.rc())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@ -131,10 +137,12 @@ public final class Version implements Comparable<Version>
|
||||
return 1;
|
||||
}
|
||||
|
||||
return new CompareToBuilder().append(this.major(), other.major())
|
||||
return new CompareToBuilder()
|
||||
.append(this.major(), other.major())
|
||||
.append(this.minor(), other.minor())
|
||||
.append(this.micro(), other.micro())
|
||||
.append(this.nano(), other.nano()).append(this.rc(), other.rc())
|
||||
.append(this.nano(), other.nano())
|
||||
.append(this.rc(), other.rc())
|
||||
.toComparison();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user