|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.util.Int30
public final class Int30
Provides utilities for reading and writing 30-bit integers in a compressed format that is smaller for smaller integers. Does not support negative integers or values above 2^30 - 1 or 1073741823.
The high order two bits of the first byte specify the number of additional bytes beyond the first byte that will be needed to store the entire integer. The bottom 6 bits of the first byte hold the highest order bits of the integer, with the following bytes holding the remaining bytes.
Values less than 2^6 are represented by just storing the value in a single byte, since the top two marking bits are zero:
Values less than 2^14 are represented in two bytes, with the top two bits of the first byte set to 01 binary:
Values less than 2^22 take three bytes, with 10 binary in the top bits, and less than 2^30 take four, with 11 binary in the top bits:
| Field Summary | |
|---|---|
static int |
MAX_VALUE
The maximum integer that can be encoded. |
| Method Summary | |
|---|---|
static int |
read(InputStream in)
Reads a 30-bit integer from an input stream. |
static void |
write(int n,
OutputStream out)
Writes a 30-bit integer to an output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_VALUE
| Method Detail |
|---|
public static void write(int n,
OutputStream out)
throws IOException
n - the integerout - the output stream
IllegalArgumentException - if n is less than 0 or
greater than 1073741823
IOException - if an I/O error occurs
public static int read(InputStream in)
throws IOException
in - the input stream
IOException - if an I/O error occurs
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||