Class CompressedNumber
- java.lang.Object
-
- org.apache.derby.iapi.services.io.CompressedNumber
-
public abstract class CompressedNumber extends java.lang.ObjectStatic methods to write and read compressed forms of numbers to DataOut and DataIn interfaces. Format written is platform independent like the Data* interfaces and must remain fixed once a product is shipped. If a different format is required then write a new set of methods, e.g. writeInt2. The formats defined by stored format identifiers are implicitly dependent on these formats not changing.
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_COMPRESSED_INT_ONE_BYTEstatic intMAX_COMPRESSED_INT_TWO_BYTESstatic intMAX_INT_STORED_SIZEstatic intMAX_LONG_STORED_SIZE
-
Constructor Summary
Constructors Constructor Description CompressedNumber()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intreadInt(byte[] data, int offset)static intreadInt(java.io.DataInput in)Read an integer previously written by writeInt().static intreadInt(java.io.InputStream in)Read an integer previously written by writeInt().static longreadLong(byte[] data, int offset)static longreadLong(java.io.DataInput in)Read a long previously written by writeLong().static longreadLong(java.io.InputStream in)Read a long previously written by writeLong().static intsizeInt(int value)Return the number of bytes that would be written by a writeInt callstatic intsizeLong(long value)static intwriteInt(java.io.DataOutput out, int value)Write a compressed integer only supporting signed values.static intwriteInt(java.io.OutputStream out, int value)Write a compressed integer directly to an OutputStream.static intwriteLong(java.io.DataOutput out, long value)Write a compressed long only supporting signed values.static intwriteLong(java.io.OutputStream out, long value)Write a compressed integer only supporting signed values.
-
-
-
Field Detail
-
MAX_INT_STORED_SIZE
public static final int MAX_INT_STORED_SIZE
- See Also:
- Constant Field Values
-
MAX_LONG_STORED_SIZE
public static final int MAX_LONG_STORED_SIZE
- See Also:
- Constant Field Values
-
MAX_COMPRESSED_INT_ONE_BYTE
public static final int MAX_COMPRESSED_INT_ONE_BYTE
- See Also:
- Constant Field Values
-
MAX_COMPRESSED_INT_TWO_BYTES
public static final int MAX_COMPRESSED_INT_TWO_BYTES
- See Also:
- Constant Field Values
-
-
Method Detail
-
writeInt
public static final int writeInt(java.io.DataOutput out, int value) throws java.io.IOExceptionWrite a compressed integer only supporting signed values. Formats are (with x representing value bits):1 Byte - 00xxxxxx Represents the value <= 63 (0x3f) 2 Byte - 01xxxxxx xxxxxxxx Represents the value > 63 && <= 16383 (0x3fff) 4 byte - 1xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx Represents the value > 16383 && <= MAX_INT- Throws:
java.io.IOException- value is negative or an exception was thrown by a method on out.
-
writeInt
public static final int writeInt(java.io.OutputStream out, int value) throws java.io.IOExceptionWrite a compressed integer directly to an OutputStream.- Throws:
java.io.IOException- an exception was thrown by a method on in.
-
readInt
public static final int readInt(java.io.DataInput in) throws java.io.IOExceptionRead an integer previously written by writeInt().- Throws:
java.io.IOException- an exception was thrown by a method on in.
-
readInt
public static final int readInt(java.io.InputStream in) throws java.io.IOExceptionRead an integer previously written by writeInt().- Throws:
java.io.IOException- an exception was thrown by a method on in.
-
readInt
public static final int readInt(byte[] data, int offset)
-
sizeInt
public static final int sizeInt(int value)
Return the number of bytes that would be written by a writeInt call
-
writeLong
public static final int writeLong(java.io.DataOutput out, long value) throws java.io.IOExceptionWrite a compressed long only supporting signed values. Formats are (with x representing value bits):2 byte - 00xxxxxx xxxxxxxx Represents the value <= 16383 (0x3fff) 4 byte - 01xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx Represents the value > 16383 && <= 0x3fffffff 8 byte - 1xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx Represents the value > 0x3fffffff && <= MAX_LONG- Throws:
java.io.IOException- value is negative or an exception was thrown by a method on out.
-
writeLong
public static final int writeLong(java.io.OutputStream out, long value) throws java.io.IOExceptionWrite a compressed integer only supporting signed values.- Throws:
java.io.IOException- value is negative or an exception was thrown by a method on out.
-
readLong
public static final long readLong(java.io.DataInput in) throws java.io.IOExceptionRead a long previously written by writeLong().- Throws:
java.io.IOException- an exception was thrown by a method on in.
-
readLong
public static final long readLong(java.io.InputStream in) throws java.io.IOExceptionRead a long previously written by writeLong().- Throws:
java.io.IOException- an exception was thrown by a method on in.
-
readLong
public static final long readLong(byte[] data, int offset)
-
sizeLong
public static final int sizeLong(long value)
-
-