public class ByteConverter
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
ByteConverter.PositiveShorts
Simple stack structure for non-negative
short values. |
| Modifier and Type | Field and Description |
|---|---|
private static java.math.BigInteger |
BI_MAX_LONG |
private static java.math.BigInteger[] |
BI_TEN_POWERS |
private static java.math.BigInteger |
BI_TEN_THOUSAND |
private static int[] |
INT_TEN_POWERS |
private static int |
LONG_BYTES |
private static long[] |
LONG_TEN_POWERS |
private static int |
NUMERIC_DSCALE_MASK |
private static short |
NUMERIC_NAN |
private static short |
NUMERIC_NEG |
private static short |
NUMERIC_POS |
private static int |
SHORT_BYTES |
| Modifier | Constructor and Description |
|---|---|
private |
ByteConverter() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
bool(byte[] bytes,
int idx)
Parses a boolean value from the byte array.
|
static void |
bool(byte[] target,
int idx,
boolean value)
Encodes a boolean value to the byte array.
|
static int |
bytesToInt(byte[] bytes)
Convert a variable length array of bytes to an integer
|
static float |
float4(byte[] bytes,
int idx)
Parses a float value from the byte array.
|
static void |
float4(byte[] target,
int idx,
float value)
Encodes a int value to the byte array.
|
static double |
float8(byte[] bytes,
int idx)
Parses a double value from the byte array.
|
static void |
float8(byte[] target,
int idx,
double value)
Encodes a int value to the byte array.
|
static short |
int2(byte[] bytes,
int idx)
Parses a short value from the byte array.
|
static void |
int2(byte[] target,
int idx,
int value)
Encodes a int value to the byte array.
|
static int |
int4(byte[] bytes,
int idx)
Parses an int value from the byte array.
|
static void |
int4(byte[] target,
int idx,
int value)
Encodes a int value to the byte array.
|
static long |
int8(byte[] bytes,
int idx)
Parses a long value from the byte array.
|
static void |
int8(byte[] target,
int idx,
long value)
Encodes a long value to the byte array.
|
static byte[] |
numeric(java.math.BigDecimal nbr)
Converts a non-null
BigDecimal to binary format for Oid.NUMERIC. |
static java.lang.Number |
numeric(byte[] bytes)
Convert a variable length array of bytes to an integer
|
static java.lang.Number |
numeric(byte[] bytes,
int pos,
int numBytes)
Convert a variable length array of bytes to a
Number. |
private static java.math.BigInteger |
tenPower(int exponent) |
private static final int NUMERIC_DSCALE_MASK
private static final short NUMERIC_POS
private static final short NUMERIC_NEG
private static final short NUMERIC_NAN
private static final int SHORT_BYTES
private static final int LONG_BYTES
private static final int[] INT_TEN_POWERS
private static final long[] LONG_TEN_POWERS
private static final java.math.BigInteger[] BI_TEN_POWERS
private static final java.math.BigInteger BI_TEN_THOUSAND
private static final java.math.BigInteger BI_MAX_LONG
public static int bytesToInt(byte[] bytes)
bytes - array of bytes that can be decoded as an integerpublic static java.lang.Number numeric(byte[] bytes)
bytes - array of bytes that can be decoded as an integerpublic static java.lang.Number numeric(byte[] bytes,
int pos,
int numBytes)
Number. The result will
always be a BigDecimal or Double.NaN.bytes - array of bytes to be decoded from binary numeric representation.pos - index of the start position of the bytes array for numbernumBytes - number of bytes to use, length is already encoded
in the binary format but this is used for double checkingDouble.NaN.public static byte[] numeric(java.math.BigDecimal nbr)
BigDecimal to binary format for Oid.NUMERIC.nbr - The instance to represent in binary.private static java.math.BigInteger tenPower(int exponent)
public static long int8(byte[] bytes,
int idx)
bytes - The byte array to parse.idx - The starting index of the parse in the byte array.public static int int4(byte[] bytes,
int idx)
bytes - The byte array to parse.idx - The starting index of the parse in the byte array.public static short int2(byte[] bytes,
int idx)
bytes - The byte array to parse.idx - The starting index of the parse in the byte array.public static boolean bool(byte[] bytes,
int idx)
bytes - The byte array to parse.idx - The starting index to read from bytes.public static float float4(byte[] bytes,
int idx)
bytes - The byte array to parse.idx - The starting index of the parse in the byte array.public static double float8(byte[] bytes,
int idx)
bytes - The byte array to parse.idx - The starting index of the parse in the byte array.public static void int8(byte[] target,
int idx,
long value)
target - The byte array to encode to.idx - The starting index in the byte array.value - The value to encode.public static void int4(byte[] target,
int idx,
int value)
target - The byte array to encode to.idx - The starting index in the byte array.value - The value to encode.public static void int2(byte[] target,
int idx,
int value)
target - The byte array to encode to.idx - The starting index in the byte array.value - The value to encode.public static void bool(byte[] target,
int idx,
boolean value)
target - The byte array to encode to.idx - The starting index in the byte array.value - The value to encode.public static void float4(byte[] target,
int idx,
float value)
target - The byte array to encode to.idx - The starting index in the byte array.value - The value to encode.public static void float8(byte[] target,
int idx,
double value)
target - The byte array to encode to.idx - The starting index in the byte array.value - The value to encode.