Package org.infinispan.commons.io
Class UnsignedNumeric
java.lang.Object
org.infinispan.commons.io.UnsignedNumeric
Helper to read and write unsigned numerics
- Since:
- 4.0
- Author:
- Manik Surtani
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
readUnsignedInt
(byte[] bytes, int offset) Reads an int stored in variable-length format.static int
Reads an int stored in variable-length format.static int
static int
static long
readUnsignedLong
(byte[] bytes, int offset) Reads an int stored in variable-length format.static long
Reads a long stored in variable-length format.static long
static long
static byte
sizeUnsignedInt
(int i) static int
writeUnsignedInt
(byte[] bytes, int offset, int i) Writes an int in a variable-length format.static void
writeUnsignedInt
(DataOutput out, int i) Writes an int in a variable-length format.static void
writeUnsignedInt
(OutputStream out, int i) static void
writeUnsignedInt
(ByteBuffer out, int i) static void
writeUnsignedLong
(byte[] bytes, int offset, long i) Writes an int in a variable-length format.static void
writeUnsignedLong
(DataOutput out, long i) Writes a long in a variable-length format.static void
writeUnsignedLong
(OutputStream out, long i) static void
writeUnsignedLong
(ByteBuffer out, long i)
-
Constructor Details
-
UnsignedNumeric
public UnsignedNumeric()
-
-
Method Details
-
readUnsignedInt
Reads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Throws:
IOException
-
readUnsignedInt
- Throws:
IOException
-
readUnsignedInt
-
writeUnsignedInt
Writes an int in a variable-length format. Writes between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Parameters:
i
- int to write- Throws:
IOException
-
writeUnsignedInt
- Throws:
IOException
-
sizeUnsignedInt
public static byte sizeUnsignedInt(int i) -
writeUnsignedInt
-
readUnsignedLong
Reads a long stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Throws:
IOException
-
readUnsignedLong
- Throws:
IOException
-
readUnsignedLong
-
writeUnsignedLong
Writes a long in a variable-length format. Writes between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Parameters:
i
- int to write- Throws:
IOException
-
writeUnsignedLong
- Throws:
IOException
-
writeUnsignedLong
-
readUnsignedInt
public static int readUnsignedInt(byte[] bytes, int offset) Reads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported. -
writeUnsignedInt
public static int writeUnsignedInt(byte[] bytes, int offset, int i) Writes an int in a variable-length format. Writes between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Parameters:
i
- int to write
-
readUnsignedLong
public static long readUnsignedLong(byte[] bytes, int offset) Reads an int stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported. -
writeUnsignedLong
public static void writeUnsignedLong(byte[] bytes, int offset, long i) Writes an int in a variable-length format. Writes between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Parameters:
i
- int to write
-