@AnnotatedFor(value="nullness") public final class SignednessUtil extends Object
Arrays
, RandomAccessFile
, ObjectInputStream
, and DataInputStream
.
SignednessUtilExtra
has more methods that reference packages that Android does not
provide. That is, SignednessUtil
can be used anywhere, and SignednessUtilExtra
can be used anywhere except on Android.
Modifier and Type | Method and Description |
---|---|
static @Unsigned byte |
byteFromDouble(double d)
Returns an unsigned byte representing the same value as the double.
|
static @Unsigned byte |
byteFromFloat(float f)
Returns an unsigned byte representing the same value as the float.
|
static int |
compareUnsigned(@Unsigned byte x,
@Unsigned byte y)
Compares two unsigned bytes x and y.
|
static int |
compareUnsigned(@Unsigned short x,
@Unsigned short y)
Compares two unsigned shorts x and y.
|
static @Unsigned byte |
getUnsigned(ByteBuffer b)
Gets an unsigned byte from the ByteBuffer b.
|
static void |
getUnsigned(ByteBuffer b,
@Unsigned byte[] bs)
Gets an array of unsigned bytes from the ByteBuffer b and stores them in the array bs.
|
static ByteBuffer |
getUnsigned(ByteBuffer b,
byte[] bs,
int i,
int l)
Populates an unsigned byte array from the ByteBuffer b at i with l bytes.
|
static @Unsigned byte |
getUnsigned(ByteBuffer b,
int i)
Gets an unsigned byte from the ByteBuffer b at i.
|
static @Unsigned int |
getUnsigned(IntBuffer b,
int i)
Gets an unsigned int from the IntBuffer b at i.
|
static @Unsigned int |
getUnsignedInt(ByteBuffer b)
Gets an unsigned int from the ByteBuffer b.
|
static @Unsigned short |
getUnsignedShort(ByteBuffer b)
Gets an unsigned short from the ByteBuffer b.
|
static @Unsigned int |
intFromDouble(double d)
Returns an unsigned int representing the same value as the double.
|
static @Unsigned int |
intFromFloat(float f)
Returns an unsigned int representing the same value as the float.
|
static @Unsigned long |
longFromDouble(double d)
Returns an unsigned long representing the same value as the double.
|
static @Unsigned long |
longFromFloat(float f)
Returns an unsigned long representing the same value as the float.
|
static ByteBuffer |
putUnsigned(ByteBuffer b,
@Unsigned byte ubyte)
Places an unsigned byte into the ByteBuffer b.
|
static ByteBuffer |
putUnsigned(ByteBuffer b,
int i,
@Unsigned byte ubyte)
Places an unsigned byte into the ByteBuffer b at i.
|
static IntBuffer |
putUnsigned(IntBuffer b,
@Unsigned int uint)
Places an unsigned int into the IntBuffer b.
|
static IntBuffer |
putUnsigned(IntBuffer b,
@Unsigned int[] uints)
Places an unsigned int array into the IntBuffer b.
|
static IntBuffer |
putUnsigned(IntBuffer b,
@Unsigned int[] uints,
int i,
int l)
Places an unsigned int array into the IntBuffer b at i with length l.
|
static IntBuffer |
putUnsigned(IntBuffer b,
int i,
@Unsigned int uint)
Places an unsigned int into the IntBuffer b at i.
|
static ByteBuffer |
putUnsignedInt(ByteBuffer b,
@Unsigned int uint)
Places an unsigned int into the ByteBuffer b.
|
static ByteBuffer |
putUnsignedInt(ByteBuffer b,
int i,
@Unsigned int uint)
Places an unsigned int into the ByteBuffer b at i.
|
static ByteBuffer |
putUnsignedLong(ByteBuffer b,
int i,
@Unsigned long ulong)
Places an unsigned long into the ByteBuffer b at i.
|
static ByteBuffer |
putUnsignedShort(ByteBuffer b,
int i,
@Unsigned short ushort)
Places an unsigned short into the ByteBuffer b at i.
|
static ByteBuffer |
putUnsignedShort(ByteBuffer b,
@Unsigned short ushort)
Places an unsigned short into the ByteBuffer b.
|
static void |
readFullyUnsigned(RandomAccessFile f,
@Unsigned byte[] b)
Reads a file fully into an unsigned byte array.
|
static int |
readUnsigned(RandomAccessFile f,
@Unsigned byte[] b,
int off,
int len)
Reads up to
len bytes of data from this file into an unsigned array of bytes. |
static @Unsigned char |
readUnsignedChar(RandomAccessFile f)
Reads an unsigned char from the RandomAccessFile f.
|
static @Unsigned int |
readUnsignedInt(RandomAccessFile f)
Reads an unsigned int from the RandomAccessFile f.
|
static @Unsigned long |
readUnsignedLong(RandomAccessFile f)
Reads an unsigned long from the RandomAccessFile f.
|
static @Unsigned short |
shortFromDouble(double d)
Returns an unsigned short representing the same value as the double.
|
static @Unsigned short |
shortFromFloat(float f)
Returns an unsigned short representing the same value as the float.
|
static double |
toDouble(@Unsigned byte b)
Returns a double representing the same value as the unsigned byte.
|
static double |
toDouble(@Unsigned int i)
Returns a double representing the same value as the unsigned int.
|
static double |
toDouble(@Unsigned long l)
Returns a double representing the same value as the unsigned long.
|
static double |
toDouble(@Unsigned short s)
Returns a double representing the same value as the unsigned short.
|
static float |
toFloat(@Unsigned byte b)
Returns a float representing the same value as the unsigned byte.
|
static float |
toFloat(@Unsigned int i)
Returns a float representing the same value as the unsigned int.
|
static float |
toFloat(@Unsigned long l)
Returns a float representing the same value as the unsigned long.
|
static float |
toFloat(@Unsigned short s)
Returns a float representing the same value as the unsigned short.
|
static @Unsigned int |
toUnsignedInt(@Unsigned char c)
Returns an unsigned int representing the same value as an unsigned char.
|
static @Unsigned long |
toUnsignedLong(@Unsigned char c)
Returns an unsigned long representing the same value as an unsigned char.
|
static @Unsigned short |
toUnsignedShort(@Unsigned byte b)
Returns an unsigned short representing the same value as an unsigned byte.
|
static @Unsigned short |
toUnsignedShort(@Unsigned char c)
Returns an unsigned short representing the same value as an unsigned char.
|
static String |
toUnsignedString(@Unsigned byte b)
Produces a string representation of the unsigned byte b.
|
static String |
toUnsignedString(@Unsigned byte b,
int radix)
Produces a string representation of the unsigned byte b in base radix.
|
static String |
toUnsignedString(@Unsigned short s)
Produces a string representation of the unsigned short s.
|
static String |
toUnsignedString(@Unsigned short s,
int radix)
Produces a string representation of the unsigned short s in base radix.
|
static ByteBuffer |
wrapUnsigned(@Unsigned byte[] array)
Wraps an unsigned byte array into a ByteBuffer.
|
static ByteBuffer |
wrapUnsigned(@Unsigned byte[] array,
int offset,
int length)
Wraps an unsigned byte array into a ByteBuffer.
|
static void |
writeUnsigned(RandomAccessFile f,
@Unsigned byte[] bs,
int off,
int len)
Writes len unsigned bytes to the RandomAccessFile f at offset off.
|
static void |
writeUnsignedByte(RandomAccessFile f,
@Unsigned byte b)
Writes an unsigned byte to the RandomAccessFile f.
|
static void |
writeUnsignedChar(RandomAccessFile f,
@Unsigned char c)
Writes an unsigned char to the RandomAccessFile f.
|
static void |
writeUnsignedInt(RandomAccessFile f,
@Unsigned int i)
Writes an unsigned byte to the RandomAccessFile f.
|
static void |
writeUnsignedLong(RandomAccessFile f,
@Unsigned long l)
Writes an unsigned byte to the RandomAccessFile f.
|
static void |
writeUnsignedShort(RandomAccessFile f,
@Unsigned short s)
Writes an unsigned short to the RandomAccessFile f.
|
public static ByteBuffer wrapUnsigned(@Unsigned byte[] array)
wrap(byte[])
, but assumes that the input should be
interpreted as unsigned.public static ByteBuffer wrapUnsigned(@Unsigned byte[] array, int offset, int length)
wrap(byte[], int, int)
, but assumes that the input
should be interpreted as unsigned.public static @Unsigned int getUnsignedInt(ByteBuffer b)
getInt()
, but assumes that the result should be interpreted as
unsigned.public static @Unsigned short getUnsignedShort(ByteBuffer b)
getShort()
, but assumes that the result should be interpreted
as unsigned.public static @Unsigned byte getUnsigned(ByteBuffer b)
get()
, but assumes that the result should be interpreted as
unsigned.public static @Unsigned byte getUnsigned(ByteBuffer b, int i)
get(int)
, but assumes that the result should be interpreted as
unsigned.public static ByteBuffer getUnsigned(ByteBuffer b, byte[] bs, int i, int l)
get(byte[], int, int)
, but
assumes that the bytes should be interpreted as unsigned.public static ByteBuffer putUnsigned(ByteBuffer b, @Unsigned byte ubyte)
put(byte)
, but assumes that the input should be interpreted as
unsigned.public static ByteBuffer putUnsigned(ByteBuffer b, int i, @Unsigned byte ubyte)
put(int, byte)
, but assumes that the input should be
interpreted as unsigned.public static IntBuffer putUnsigned(IntBuffer b, @Unsigned int uint)
put(int)
, but assumes that the input should be interpreted as
unsigned.public static IntBuffer putUnsigned(IntBuffer b, int i, @Unsigned int uint)
put(int, int)
, but assumes that the input should be
interpreted as unsigned.public static IntBuffer putUnsigned(IntBuffer b, @Unsigned int[] uints)
put(int[])
, but assumes that the input should be interpreted as
unsigned.public static IntBuffer putUnsigned(IntBuffer b, @Unsigned int[] uints, int i, int l)
put(int[], int, int)
, but assumes that
the input should be interpreted as unsigned.public static @Unsigned int getUnsigned(IntBuffer b, int i)
get(int)
, but assumes that the output should be interpreted as
unsigned.public static ByteBuffer putUnsignedShort(ByteBuffer b, @Unsigned short ushort)
putShort(short)
, but assumes that the input should be
interpreted as unsigned.public static ByteBuffer putUnsignedShort(ByteBuffer b, int i, @Unsigned short ushort)
putShort(int, short)
, but assumes that the input
should be interpreted as unsigned.public static ByteBuffer putUnsignedInt(ByteBuffer b, @Unsigned int uint)
putInt(int)
, but assumes that the input should be interpreted
as unsigned.public static ByteBuffer putUnsignedInt(ByteBuffer b, int i, @Unsigned int uint)
putInt(int, int)
, but assumes that the input should be
interpreted as unsigned.public static ByteBuffer putUnsignedLong(ByteBuffer b, int i, @Unsigned long ulong)
putLong(int, long)
, but assumes that the input should
be interpreted as unsigned.public static @Unsigned char readUnsignedChar(RandomAccessFile f) throws IOException
readChar()
, but assumes the output should be interpreted
as unsigned.IOException
public static @Unsigned int readUnsignedInt(RandomAccessFile f) throws IOException
readInt()
, but assumes the output should be interpreted as
unsigned.IOException
public static @Unsigned long readUnsignedLong(RandomAccessFile f) throws IOException
readLong()
, but assumes the output should be interpreted
as unsigned.IOException
public static int readUnsigned(RandomAccessFile f, @Unsigned byte[] b, int off, int len) throws IOException
len
bytes of data from this file into an unsigned array of bytes. This
method is a wrapper around read(byte[],
int, int)
, but assumes the output should be interpreted as unsigned.IOException
public static void readFullyUnsigned(RandomAccessFile f, @Unsigned byte[] b) throws IOException
readFully(byte[])
, but assumes the output should be
interpreted as unsigned.IOException
public static void writeUnsigned(RandomAccessFile f, @Unsigned byte[] bs, int off, int len) throws IOException
write(byte[], int, int)
, but
assumes the input should be interpreted as unsigned.IOException
public static void writeUnsignedByte(RandomAccessFile f, @Unsigned byte b) throws IOException
writeByte(int)
, but assumes the input should be
interpreted as unsigned.IOException
public static void writeUnsignedChar(RandomAccessFile f, @Unsigned char c) throws IOException
writeChar(int)
, but assumes the input should be
interpreted as unsigned.IOException
public static void writeUnsignedShort(RandomAccessFile f, @Unsigned short s) throws IOException
writeShort(int)
, but assumes the input should be
interpreted as unsigned.IOException
public static void writeUnsignedInt(RandomAccessFile f, @Unsigned int i) throws IOException
writeInt(int)
, but assumes the input should be
interpreted as unsigned.IOException
public static void writeUnsignedLong(RandomAccessFile f, @Unsigned long l) throws IOException
writeLong(long)
, but assumes the input should be
interpreted as unsigned.IOException
public static void getUnsigned(ByteBuffer b, @Unsigned byte[] bs)
get(byte[])
, but assumes
that the array of bytes should be interpreted as unsigned.public static int compareUnsigned(@Unsigned short x, @Unsigned short y)
In Java 11 or later, use Short.compareUnsigned.
x
- the first value to comparey
- the second value to comparepublic static int compareUnsigned(@Unsigned byte x, @Unsigned byte y)
In Java 11 or later, use Byte.compareUnsigned.
x
- the first value to comparey
- the second value to comparepublic static String toUnsignedString(@Unsigned short s)
public static String toUnsignedString(@Unsigned short s, int radix)
public static String toUnsignedString(@Unsigned byte b)
public static String toUnsignedString(@Unsigned byte b, int radix)
public static @Unsigned short toUnsignedShort(@Unsigned byte b)
public static @Unsigned long toUnsignedLong(@Unsigned char c)
public static @Unsigned int toUnsignedInt(@Unsigned char c)
public static @Unsigned short toUnsignedShort(@Unsigned char c)
public static float toFloat(@Unsigned byte b)
public static float toFloat(@Unsigned short s)
public static float toFloat(@Unsigned int i)
public static float toFloat(@Unsigned long l)
public static double toDouble(@Unsigned byte b)
public static double toDouble(@Unsigned short s)
public static double toDouble(@Unsigned int i)
public static double toDouble(@Unsigned long l)
public static @Unsigned byte byteFromFloat(float f)
public static @Unsigned short shortFromFloat(float f)
public static @Unsigned int intFromFloat(float f)
public static @Unsigned long longFromFloat(float f)
public static @Unsigned byte byteFromDouble(double d)
public static @Unsigned short shortFromDouble(double d)
public static @Unsigned int intFromDouble(double d)
public static @Unsigned long longFromDouble(double d)