| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.common.primitives.UnsignedBytes
public final class UnsignedBytes
Static utility methods pertaining to byte primitives that interpret
 values as unsigned (that is, any negative value b is treated
 as the positive value 256 + b). The corresponding methods that treat
 the values as signed are found in SignedBytes, and the methods for
 which signedness is not an issue are in Bytes.
| Method Summary | |
|---|---|
| static byte | checkedCast(long value)Returns the bytevalue that, when treated as unsigned, is equal tovalue, if possible. | 
| static int | compare(byte a,
               byte b)Compares the two specified bytevalues, treating them as unsigned
 values between 0 and 255 inclusive. | 
| static String | join(String separator,
         byte... array)Returns a string containing the supplied bytevalues separated byseparator. | 
| static Comparator<byte[]> | lexicographicalComparator()Returns a comparator that compares two bytearrays
 lexicographically. | 
| static byte | max(byte... array)Returns the greatest value present in array. | 
| static byte | min(byte... array)Returns the least value present in array. | 
| static byte | saturatedCast(long value)Returns the bytevalue that, when treated as unsigned, is nearest
 in value tovalue. | 
| static int | toInt(byte value)Returns the value of the given byte as an integer, when treated as unsigned. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Method Detail | 
|---|
public static int toInt(byte value)
value + 256 if value is
 negative; value itself otherwise.
public static byte checkedCast(long value)
byte value that, when treated as unsigned, is equal to
 value, if possible.
value - a value between 0 and 255 inclusive
byte value that, when treated as unsigned, equals
     value
IllegalArgumentException - if value is negative or greater
     than 255public static byte saturatedCast(long value)
byte value that, when treated as unsigned, is nearest
 in value to value.
value - any long value
(byte) 255 if value >= 255, (byte) 0 if
     value <= 0, and value cast to byte otherwise
public static int compare(byte a,
                          byte b)
byte values, treating them as unsigned
 values between 0 and 255 inclusive. For example, (byte) -127 is
 considered greater than (byte) 127 because it is seen as having
 the value of positive 129.
a - the first byte to compareb - the second byte to compare
a is less than b; a positive
     value if a is greater than b; or zero if they are equalpublic static byte min(byte... array)
array.
array - a nonempty array of byte values
array that is less than or equal to
     every other value in the array
IllegalArgumentException - if array is emptypublic static byte max(byte... array)
array.
array - a nonempty array of byte values
array that is greater than or equal
     to every other value in the array
IllegalArgumentException - if array is empty
public static String join(String separator,
                          byte... array)
byte values separated by
 separator. For example, join(":", (byte) 1, (byte) 2,
 (byte) 255) returns the string "1:2:255".
separator - the text that should appear between consecutive values in
     the resulting string (but not at the start or end)array - an array of byte values, possibly emptypublic static Comparator<byte[]> lexicographicalComparator()
byte arrays
 lexicographically. That is, it compares, using compare(byte, byte)), the first pair of values that follow any common
 prefix, or when one array is a prefix of the other, treats the shorter
 array as the lesser. For example, [] < [0x01] < [0x01, 0x7F] <
 [0x01, 0x80] < [0x02]. Values are treated as unsigned.
 The returned comparator is inconsistent with Object.equals(Object) (since arrays support only identity equality), but
 it is consistent with Arrays.equals(byte[], byte[]).
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||