public class BeowulfJUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
byteToHex(byte num) |
static byte[] |
decodeHexString(String hexString) |
static String |
fromEckeyToWif(eu.bittrade.crypto.core.ECKey ecKey) |
static String |
fromPrivKeyHexToWif(String hexString) |
static eu.bittrade.crypto.core.ECKey |
fromWifToEckey(String wif) |
static String |
getAddressFromEckey(eu.bittrade.crypto.core.ECKey ecKey) |
static byte |
hexToByte(String hexString) |
static String |
privateKeyToWIF(eu.bittrade.crypto.core.ECKey privateKey)
Get the WIF representation of a private key.
|
static <T> T |
setIfNotNull(T objectToSet,
String message)
Like
setIfNotNull(Object, String, Object), but does not require
a default value. |
static <T> T |
setIfNotNull(T objectToSet,
String message,
T defaultValue)
This method will check if given
objectToSet is
null. |
static <T> T |
setIfNotNull(T objectToSet,
T defaultValue)
Like
setIfNotNull(Object, String, Object), but the generated
exception will contain a static text. |
static <T> List<T> |
setIfNotNullAndNotEmpty(List<T> collectionToSet,
String message) |
static int |
toDigit(char hexChar) |
static byte[] |
transformBooleanToByteArray(boolean boolValue)
Transform a boolean value into its byte representation.
|
static byte |
transformByteToLittleEndian(byte byteValue)
Change the order of a byte to little endian.
|
static String |
transformDateToString(Date date)
This method transform a date and returns this date in its String
representation.
|
static byte[] |
transformIntToByteArray(int intValue)
Transform an int value into its byte representation.
|
static byte[] |
transformIntToVarIntByteArray(int intValue)
Transform an int value into its byte representation.
|
static byte[] |
transformLongToByteArray(long longValue)
Transform a long variable into a byte array.
|
static byte[] |
transformLongToVarIntByteArray(long longValue)
Transform a long value into its byte representation.
|
static byte[] |
transformShortToByteArray(int shortValue)
Transform a short variable into a byte array.
|
static byte[] |
transformShortToByteArray(short shortValue)
Transform an short value into its byte representation.
|
static long |
transformStringToTimestamp(String dateTime)
This method transforms a String into a timestamp.
|
static byte[] |
transformStringToVarIntByteArray(String string)
Get the VarInt-byte representation of a String.
|
static boolean |
verifyJsonString(String customJsonString)
This method can be used to verify, if the given String is a valid JSON
string.
|
public static boolean verifyJsonString(String customJsonString)
customJsonString - The string to be checked.true If the given String is valid JSON,
false if not.public static byte[] transformShortToByteArray(int shortValue)
shortValue - The short value to transform.public static byte[] transformLongToByteArray(long longValue)
longValue - The long value to transform.public static byte transformByteToLittleEndian(byte byteValue)
byteValue - The byte to transform.public static byte[] transformStringToVarIntByteArray(String string)
Serializing a String has to be done in two steps:
string - The string to transform.public static byte[] transformIntToVarIntByteArray(int intValue)
intValue - The int value to transform.public static byte[] transformShortToByteArray(short shortValue)
shortValue - The short value to transform.public static byte[] transformIntToByteArray(int intValue)
intValue - The int value to transform.public static byte[] transformBooleanToByteArray(boolean boolValue)
boolValue - The bool value to transform.public static byte[] transformLongToVarIntByteArray(long longValue)
longValue - value The long value to transform.public static String transformDateToString(Date date)
BeowulfJConfig.date - The date to transform.public static long transformStringToTimestamp(String dateTime) throws ParseException
BeowulfJConfig.dateTime - The date to transform.ParseException - If the String could not be transformed.public static String privateKeyToWIF(eu.bittrade.crypto.core.ECKey privateKey)
privateKey - The private key to get WIF representation for.IllegalStateException - If no private key is present in the given ECKey instance.public static <T> T setIfNotNull(T objectToSet,
String message)
setIfNotNull(Object, String, Object), but does not require
a default value.
This method will check if given objectToSet is
null and throw an InvalidParameterException if this
is the case.
T - The type of the objectToSet.objectToSet - The object to check.message - The message of the generated exception.objectToSet if its not null.InvalidParameterException - If the objectToSet is null.public static <T> T setIfNotNull(T objectToSet,
String message,
@Nullable
T defaultValue)
objectToSet is
null.
In case objectToSet is not null, the
objectToSet will be returned. Otherwise the method will
check the defaultValue. The method will return the
defaultValue if one has been provided.
If all values are not set the method will throw an
InvalidParameterException.
T - The type of the objectToSet.objectToSet - The object to check.message - The message of the generated exception.defaultValue - The default value to apply in case the
objectToSet is null.objectToSet if its not null.
Otherwise the defaultValue will be returned.InvalidParameterException - If the objectToSet is null and, in
addition, no defaultValue has been provided.public static <T> T setIfNotNull(T objectToSet,
@Nullable
T defaultValue)
setIfNotNull(Object, String, Object), but the generated
exception will contain a static text.T - The type of the objectToSet.objectToSet - The object to check.defaultValue - The default value to apply in case the
objectToSet is null.objectToSet if its not null.
Otherwise the defaultValue will be returned.InvalidParameterException - If the objectToSet is null and, in
addition, no defaultValue has been provided.public static <T> List<T> setIfNotNullAndNotEmpty(List<T> collectionToSet, String message)
T - The type object.collectionToSet - List objects.message - The message.public static String byteToHex(byte num)
public static byte[] decodeHexString(String hexString)
public static byte hexToByte(String hexString)
public static int toDigit(char hexChar)
public static String getAddressFromEckey(eu.bittrade.crypto.core.ECKey ecKey)
public static eu.bittrade.crypto.core.ECKey fromWifToEckey(String wif)
public static String fromEckeyToWif(eu.bittrade.crypto.core.ECKey ecKey)
Copyright © 2019. All rights reserved.