Package foundation.icon.icx.data
Class Bytes
- java.lang.Object
-
- foundation.icon.icx.data.Bytes
-
public class Bytes extends java.lang.Object
A wrapper class of byte array
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
HEX_PREFIX
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
cleanHexPrefix(java.lang.String input)
static boolean
containsHexPrefix(java.lang.String input)
boolean
equals(java.lang.Object obj)
int
hashCode()
int
length()
byte[]
toByteArray()
Gets the data as a byte arraybyte[]
toByteArray(int size)
Gets the data as a byte array given sizestatic byte[]
toBytesPadded(byte[] value, int length)
add the pad bytes to the passed in block, returning the number of bytes added.java.lang.String
toHexString(boolean withPrefix)
Gets the data as a hex stringjava.lang.String
toHexString(boolean withPrefix, int size)
Gets the data as a hex string given sizejava.lang.String
toString()
-
-
-
Field Detail
-
HEX_PREFIX
public static final java.lang.String HEX_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Bytes
public Bytes(java.lang.String hexString)
Creates an instance using hex string- Parameters:
hexString
- hex string of bytes
-
Bytes
public Bytes(byte[] data)
Creates an instance using byte array- Parameters:
data
- byte array to wrap
-
Bytes
public Bytes(java.math.BigInteger value)
Creates an instance using BigIntegerSet a byte array of
BigInteger.toByteArray()
return value. The array will contain the minimum number of bytes required to represent this BigInteger, including at least one sign bit.- Parameters:
value
- the value
-
-
Method Detail
-
toByteArray
public byte[] toByteArray()
Gets the data as a byte array- Returns:
- byte array
-
toBytesPadded
public static byte[] toBytesPadded(byte[] value, int length)
add the pad bytes to the passed in block, returning the number of bytes added.
-
cleanHexPrefix
public static java.lang.String cleanHexPrefix(java.lang.String input)
-
toHexString
public java.lang.String toHexString(boolean withPrefix)
Gets the data as a hex string- Parameters:
withPrefix
- whether 0x prefix included- Returns:
- hex string
-
containsHexPrefix
public static boolean containsHexPrefix(java.lang.String input)
-
toByteArray
public byte[] toByteArray(int size)
Gets the data as a byte array given size- Parameters:
size
- size of byte array- Returns:
- byte array given size
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toHexString
public java.lang.String toHexString(boolean withPrefix, int size)
Gets the data as a hex string given size- Parameters:
withPrefix
- whether 0x prefix includedsize
- size of byte array- Returns:
- hex string given size
-
length
public int length()
-
-