|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.usb.util.UsbUtil
General utility methods.
Nested Class Summary | |
static class |
UsbUtil.SynchronizedUsbDevice
A synchronized UsbDevice wrapper implementation. |
static class |
UsbUtil.SynchronizedUsbPipe
A synchronized UsbPipe wrapper implementation. |
Constructor Summary | |
UsbUtil()
|
Method Summary | |
static java.lang.String |
getSpeedString(java.lang.Object object)
Get a String description of the specified device-speed Object. |
static UsbDevice |
synchronizedUsbDevice(UsbDevice usbDevice)
Create a synchronized UsbDevice. |
static UsbPipe |
synchronizedUsbPipe(UsbPipe usbPipe)
Create a synchronized UsbPipe. |
static java.lang.String |
toHexString(byte b)
Format a byte into a proper length hex String. |
static java.lang.String |
toHexString(int i)
Format a int into a proper length hex String. |
static java.lang.String |
toHexString(long l)
Format a long into the specified length hex String. |
static java.lang.String |
toHexString(long l,
char c,
int min,
int max)
Format a long into the specified length hex String. |
static java.lang.String |
toHexString(short s)
Format a short into a proper length hex String. |
static java.lang.String |
toHexString(java.lang.String delimiter,
byte[] array)
Format a byte[] into a hex String. |
static java.lang.String |
toHexString(java.lang.String delimiter,
byte[] array,
int length)
Format a byte[] into a hex String. |
static java.lang.String |
toHexString(java.lang.String delimiter,
int[] array)
Format a int[] into a hex String. |
static java.lang.String |
toHexString(java.lang.String delimiter,
int[] array,
int length)
Format a int[] into a hex String. |
static java.lang.String |
toHexString(java.lang.String delimiter,
long[] array)
Format a long[] into a hex String. |
static java.lang.String |
toHexString(java.lang.String delimiter,
long[] array,
int length)
Format a long[] into a hex String. |
static java.lang.String |
toHexString(java.lang.String delimiter,
short[] array)
Format a short[] into a hex String. |
static java.lang.String |
toHexString(java.lang.String delimiter,
short[] array,
int length)
Format a short[] into a hex String. |
static int |
toInt(byte byte3,
byte byte2,
byte byte1,
byte byte0)
Convert 4 bytes into an int. |
static int |
toInt(short mss,
short lss)
Convert 2 shorts into an int. |
static long |
toLong(byte byte7,
byte byte6,
byte byte5,
byte byte4,
byte byte3,
byte byte2,
byte byte1,
byte byte0)
Convert 8 bytes into a long. |
static long |
toLong(int msi,
int lsi)
Convert 2 ints into a long. |
static long |
toLong(short short3,
short short2,
short short1,
short short0)
Convert 4 shorts into a long. |
static short |
toShort(byte msb,
byte lsb)
Convert 2 bytes into a short. |
static int |
unsignedInt(byte b)
Get the specified byte's value as an unsigned integer. |
static int |
unsignedInt(short s)
Get the specified short's value as an unsigned integer. |
static long |
unsignedLong(byte b)
Get the specified byte's value as an unsigned long. |
static long |
unsignedLong(int i)
Get the specified int's value as an unsigned long. |
static long |
unsignedLong(short s)
Get the specified short's value as an unsigned long. |
static short |
unsignedShort(byte b)
Get the specified byte's value as an unsigned short. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public UsbUtil()
Method Detail |
public static short unsignedShort(byte b)
This converts the specified byte into a short. The least significant byte (8 bits) of the short will be identical to the byte (8 bits) provided, and the most significant byte (8 bits) of the short will be zero.
For many of the values in this USB API, unsigned bytes are used. However, since Java does not include unsigned bytes in the language, those unsigned bytes must be converted to a larger storage type before being used in unsigned calculations.
b
- the byte to convert.
public static int unsignedInt(byte b)
This converts the specified byte into an integer. The least significant byte (8 bits) of the integer will be identical to the byte (8 bits) provided, and the most significant 3 bytes (24 bits) of the integer will be zero.
For many of the values in this USB API, unsigned bytes are used. However, since Java does not include unsigned bytes in the language, those unsigned bytes must be converted to a larger storage type before being used in unsigned calculations.
b
- the byte to convert.
public static int unsignedInt(short s)
This converts the specified byte into an integer. The least significant short (16 bits) of the integer will be identical to the short (16 bits) provided, and the most significant 2 bytes (16 bits) of the integer will be zero.
For many of the values in this USB API, unsigned shorts are used. However, since Java does not include unsigned short in the language, those unsigned shorts must be converted to a larger storage type before being used in unsigned calculations.
s
- the short to convert.
public static long unsignedLong(byte b)
This converts the specified byte into a long. The least significant byte (8 bits) of the long will be identical to the byte (8 bits) provided, and the most significant 7 bytes (56 bits) of the long will be zero.
For many of the values in this USB API, unsigned bytes are used. However, since Java does not include unsigned bytes in the language, those unsigned bytes must be converted to a larger storage type before being used in unsigned calculations.
b
- the byte to convert.
public static long unsignedLong(short s)
This converts the specified byte into a long. The least significant short (16 bits) of the long will be identical to the short (16 bits) provided, and the most significant 6 bytes (48 bits) of the long will be zero.
For many of the values in this USB API, unsigned shorts are used. However, since Java does not include unsigned short in the language, those unsigned shorts must be converted to a larger storage type before being used in unsigned calculations.
s
- the short to convert.
public static long unsignedLong(int i)
This converts the specified int into a long. The least significant int (32 bits) of the long will be identical to the int (32 bits) provided, and the most significant int (32 bits) of the long will be zero.
i
- the int to convert.
public static short toShort(byte msb, byte lsb)
This converts the 2 bytes into a short. The msb will be the high byte (8 bits) of the short, and the lsb will be the low byte (8 bits) of the short.
msb
- The Most Significant Byte.lsb
- The Least Significant Byte.
public static int toInt(byte byte3, byte byte2, byte byte1, byte byte0)
This converts the 4 bytes into an int.
byte3
- The byte to be left-shifted 24 bits.byte2
- The byte to be left-shifted 16 bits.byte1
- The byte to be left-shifted 8 bits.byte0
- The byte that will not be left-shifted.
public static long toLong(byte byte7, byte byte6, byte byte5, byte byte4, byte byte3, byte byte2, byte byte1, byte byte0)
This converts the 8 bytes into a long.
byte7
- The byte to be left-shifted 56 bits.byte6
- The byte to be left-shifted 48 bits.byte5
- The byte to be left-shifted 40 bits.byte4
- The byte to be left-shifted 32 bits.byte3
- The byte to be left-shifted 24 bits.byte2
- The byte to be left-shifted 16 bits.byte1
- The byte to be left-shifted 8 bits.byte0
- The byte that will not be left-shifted.
public static int toInt(short mss, short lss)
This converts the 2 shorts into an int.
mss
- The Most Significant Short.lss
- The Least Significant Short.
public static long toLong(short short3, short short2, short short1, short short0)
This converts the 4 shorts into a long.
short3
- The short to be left-shifted 48 bits.short2
- The short to be left-shifted 32 bits.short1
- The short to be left-shifted 16 bits.short0
- The short that will not be left-shifted.
public static long toLong(int msi, int lsi)
This converts the 2 ints into a long.
msi
- The Most Significant Int.lsi
- The Least Significant Int.
public static java.lang.String toHexString(byte b)
This is identical to Long.toHexString() except this pads (with 0's) to the proper size.
b
- the byte to convertpublic static java.lang.String toHexString(short s)
This is identical to Long.toHexString() except this pads (with 0's) to the proper size.
s
- the short to convertpublic static java.lang.String toHexString(int i)
This is identical to Long.toHexString() except this pads (with 0's) to the proper size.
i
- the integer to convertpublic static java.lang.String toHexString(long l)
This is identical to Long.toHexString() except this pads (with 0's) to the proper size.
l
- the long to convertpublic static java.lang.String toHexString(long l, char c, int min, int max)
This is identical to Long.toHexString() except this pads (with 0's), or truncates, to the specified size. If max < min the functionaliy is exactly as Long.toHexString().
l
- the long to convertc
- the character to use for paddingmin
- the min length of the resulting Stringmax
- the max length of the resulting Stringpublic static java.lang.String toHexString(java.lang.String delimiter, byte[] array, int length)
This creates a String by concatenating the result of
delimiter +
for each byte in the array. If the specified length is greater
than the actual array length, the array length is used.
If the specified length (or array length) is 0 or less,
the resulting String will be an empty String.
toHexString(byte)
delimiter
- The delimiter to prefix every byte with.array
- The byte[] to convert.length
- The number of bytes to use.
java.lang.NullPointerException
- If the byte[] is null.public static java.lang.String toHexString(java.lang.String delimiter, short[] array, int length)
This creates a String by concatenating the result of
delimiter +
for each short in the array. If the specified length is greater
than the actual array length, the array length is used.
If the specified length (or array length) is 0 or less,
the resulting String will be an empty String.
toHexString(short)
delimiter
- The delimiter to prefix every short with.array
- The short[] to convert.length
- The number of shorts to use.
java.lang.NullPointerException
- If the short[] is null.public static java.lang.String toHexString(java.lang.String delimiter, int[] array, int length)
This creates a String by concatenating the result of
delimiter +
for each int in the array. If the specified length is greater
than the actual array length, the array length is used.
If the specified length (or array length) is 0 or less,
the resulting String will be an empty String.
toHexString(int)
delimiter
- The delimiter to prefix every int with.array
- The int[] to convert.length
- The number of ints to use.
java.lang.NullPointerException
- If the int[] is null.public static java.lang.String toHexString(java.lang.String delimiter, long[] array, int length)
This creates a String by concatenating the result of
delimiter +
for each long in the array. If the specified length is greater
than the actual array length, the array length is used.
If the specified length (or array length) is 0 or less,
the resulting String will be an empty String.
toHexString(long)
delimiter
- The delimiter to prefix every long with.array
- The long[] to convert.length
- The number of longs to use.
java.lang.NullPointerException
- If the long[] is null.public static java.lang.String toHexString(java.lang.String delimiter, byte[] array)
This calls toHexString(delimiter, array, array.length)
.
delimiter
- The delimiter to prefix every byte with.array
- The byte[] to convert.
java.lang.NullPointerException
- If the byte[] is null.public static java.lang.String toHexString(java.lang.String delimiter, short[] array)
This calls toHexString(delimiter, array, array.length)
.
delimiter
- The delimiter to prefix every short with.array
- The short[] to convert.
java.lang.NullPointerException
- If the short[] is null.public static java.lang.String toHexString(java.lang.String delimiter, int[] array)
This calls toHexString(delimiter, array, array.length)
.
delimiter
- The delimiter to prefix every int with.array
- The int[] to convert.
java.lang.NullPointerException
- If the int[] is null.public static java.lang.String toHexString(java.lang.String delimiter, long[] array)
This calls toHexString(delimiter, array, array.length)
.
delimiter
- The delimiter to prefix every long with.array
- The long[] to convert.
java.lang.NullPointerException
- If the long[] is null.public static java.lang.String getSpeedString(java.lang.Object object)
The String will be one of:
UsbConst
.
object
- The device-speed Object.
Low Speed.
,
Full Speed.
,
Unknown Speed.
public static UsbDevice synchronizedUsbDevice(UsbDevice usbDevice)
usbDevice
- The unsynchronized UsbDevice.
public static UsbPipe synchronizedUsbPipe(UsbPipe usbPipe)
usbPipe
- The unsynchronized UsbPipe.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |