Package org.stellar.sdk
Class Util
java.lang.Object
org.stellar.sdk.Util
Utility class for common operations.
note: For some reason we need to make it public, but I don't recommend to use it directly.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe function that converts XDR string to XDR object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AssetTypeCreditAlphaNumassertNonNativeAsset(Asset asset) ThrowsIllegalArgumentExceptionif the given asset is native (XLM).static StringbytesToHex(byte[] bytes) Returns hex representation ofbytesarray.static byte[]getBytes(BigInteger value) Returns an 8 byte array representation of a BigInteger value.static StringGet the version of the SDKstatic byte[]hash(byte[] data) Returns SHA-256 hash ofdata.static byte[]hexToBytes(String s) Returns byte array representation ofhexstring.static byte[]paddedByteArray(String string, int length) Padsstringtolengthwith zeros.static <T> TparseXdr(String xdr, Util.XdrDecodeFunction<String, T> fromXdrBase64) Parses XDR string to XDR object.
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
bytesToHex
Returns hex representation ofbytesarray.- Parameters:
bytes- byte array to convert to hex- Returns:
- hex representation of the byte array
-
hexToBytes
Returns byte array representation ofhexstring.- Parameters:
s- hex string to convert to byte array- Returns:
- byte array representation of the hex string
-
hash
public static byte[] hash(byte[] data) Returns SHA-256 hash ofdata.- Parameters:
data- byte array to hash- Returns:
- SHA-256 hash of the data
-
paddedByteArray
Padsstringtolengthwith zeros.- Parameters:
string- string to padlength- length of the resulting array- Returns:
- padded byte array
-
getSdkVersion
Get the version of the SDK- Returns:
- version
-
assertNonNativeAsset
ThrowsIllegalArgumentExceptionif the given asset is native (XLM).- Parameters:
asset- The asset to check
-
getBytes
Returns an 8 byte array representation of a BigInteger value.- Parameters:
value- BigInteger value to convert to byte array- Returns:
- byte array
-
parseXdr
Parses XDR string to XDR object.- Type Parameters:
T- type of XDR object- Parameters:
xdr- XDR stringfromXdrBase64- function that converts XDR string to XDR object- Returns:
- XDR object, or null if the input string is null or empty
-