public final class Numeric
extends java.lang.Object
Message codec functions.
Implementation as per https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding
| Modifier and Type | Method and Description |
|---|---|
static byte |
asByte(int m,
int n) |
static java.lang.String |
cleanHexPrefix(java.lang.String input) |
static boolean |
containsHexPrefix(java.lang.String input) |
static java.math.BigInteger |
decodeQuantity(java.lang.String value) |
static java.lang.String |
encodeQuantity(java.math.BigInteger value) |
static byte[] |
fromBigDecimalToFixed8Bytes(java.math.BigDecimal value)
Converts the given decimal number to a Fixed8 in the form of 8 bytes in big-endian order.
|
static byte[] |
fromBigDecimalToFixed8Bytes(java.lang.String value)
Converts the given decimal number to a Fixed8 in the form of 8 bytes in big-endian order.
|
static java.math.BigInteger |
fromDecimalToFixed8(java.math.BigDecimal value)
Converts the given decimal number to a Fixed8 in the form of an integer.
|
static java.math.BigInteger |
fromDecimalToFixed8(java.lang.String value)
Converts the given decimal number to a Fixed8 in the form of an integer.
|
static java.math.BigDecimal |
fromFixed8ToDecimal(java.math.BigInteger value)
Converts the given Fixed8 number to a BigDecimal.
|
static java.math.BigDecimal |
fromFixed8ToDecimal(byte[] value)
Converts the given Fixed8 number to a BigDecimal.
|
static byte[] |
fromIntegerToFixed8Bytes(java.math.BigInteger value) |
static byte[] |
hexStringToByteArray(java.lang.String input) |
static java.math.BigInteger |
hexToInteger(java.lang.String input) |
static java.lang.String |
hexToString(java.lang.String input) |
static boolean |
isIntegerValue(java.math.BigDecimal value) |
static boolean |
isValidHexString(java.lang.String string)
Checks if the given string is a valid hexadecimal string.
|
static java.lang.String |
prependHexPrefix(java.lang.String input) |
static java.lang.String |
reverseHexString(java.lang.String input) |
static java.math.BigInteger |
toBigInt(byte[] value) |
static java.math.BigInteger |
toBigInt(byte[] value,
int offset,
int length) |
static java.math.BigInteger |
toBigInt(java.lang.String hexValue) |
static java.math.BigInteger |
toBigIntNoPrefix(java.lang.String hexValue) |
static byte[] |
toBytesPadded(java.math.BigInteger value,
int length) |
static java.lang.String |
toHexString(byte input) |
static java.lang.String |
toHexString(byte[] input) |
static java.lang.String |
toHexString(byte[] input,
int offset,
int length,
boolean withPrefix) |
static java.lang.String |
toHexStringNoPrefix(java.math.BigInteger value) |
static java.lang.String |
toHexStringNoPrefix(byte input) |
static java.lang.String |
toHexStringNoPrefix(byte[] input) |
static java.lang.String |
toHexStringNoPrefixZeroPadded(java.math.BigInteger value,
int size) |
static java.lang.String |
toHexStringWithPrefix(java.math.BigInteger value) |
static java.lang.String |
toHexStringWithPrefixSafe(java.math.BigInteger value) |
static java.lang.String |
toHexStringWithPrefixZeroPadded(java.math.BigInteger value,
int size) |
public static java.lang.String encodeQuantity(java.math.BigInteger value)
public static java.math.BigInteger decodeQuantity(java.lang.String value)
public static java.lang.String cleanHexPrefix(java.lang.String input)
public static java.lang.String prependHexPrefix(java.lang.String input)
public static boolean containsHexPrefix(java.lang.String input)
public static boolean isValidHexString(java.lang.String string)
string - The string to check.public static java.math.BigDecimal fromFixed8ToDecimal(byte[] value)
value - The Fixed8 value as a byte array. Must be 8 bytes in big-endian order.public static java.math.BigDecimal fromFixed8ToDecimal(java.math.BigInteger value)
value - The Fixed8 value as an integer.public static java.math.BigInteger fromDecimalToFixed8(java.lang.String value)
value - The decimal number to convert.public static java.math.BigInteger fromDecimalToFixed8(java.math.BigDecimal value)
value - The decimal number to convert.public static byte[] fromBigDecimalToFixed8Bytes(java.lang.String value)
value - The decimal number to convert.public static byte[] fromBigDecimalToFixed8Bytes(java.math.BigDecimal value)
value - The decimal number to convert.public static byte[] fromIntegerToFixed8Bytes(java.math.BigInteger value)
public static java.math.BigInteger toBigInt(byte[] value,
int offset,
int length)
public static java.math.BigInteger toBigInt(byte[] value)
public static java.math.BigInteger toBigInt(java.lang.String hexValue)
public static java.math.BigInteger toBigIntNoPrefix(java.lang.String hexValue)
public static java.lang.String toHexStringWithPrefix(java.math.BigInteger value)
public static java.lang.String toHexStringNoPrefix(java.math.BigInteger value)
public static java.lang.String toHexStringNoPrefix(byte input)
public static java.lang.String toHexStringNoPrefix(byte[] input)
public static java.lang.String toHexStringWithPrefixZeroPadded(java.math.BigInteger value,
int size)
public static java.lang.String toHexStringWithPrefixSafe(java.math.BigInteger value)
public static java.lang.String toHexStringNoPrefixZeroPadded(java.math.BigInteger value,
int size)
public static byte[] toBytesPadded(java.math.BigInteger value,
int length)
public static byte[] hexStringToByteArray(java.lang.String input)
public static java.lang.String toHexString(byte[] input,
int offset,
int length,
boolean withPrefix)
public static java.lang.String toHexString(byte input)
public static java.lang.String toHexString(byte[] input)
public static java.lang.String hexToString(java.lang.String input)
public static java.math.BigInteger hexToInteger(java.lang.String input)
public static java.lang.String reverseHexString(java.lang.String input)
public static byte asByte(int m,
int n)
public static boolean isIntegerValue(java.math.BigDecimal value)