Package org.aion.avm.userlib.abi
Class ABIEncoder
- java.lang.Object
-
- org.aion.avm.userlib.abi.ABIEncoder
-
public final class ABIEncoder extends java.lang.Object
Utility class for AVM ABI encoding.This class provides static helpers for encoding single data elements.
It is typically more appropriate to use
ABIStreamingEncoder
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
encodeOne2DBooleanArray(boolean[][] data)
Encodes one 2D boolean array as a serialized extent.static byte[]
encodeOne2DByteArray(byte[][] data)
Encodes one 2D byte array as a serialized extent.static byte[]
encodeOne2DCharacterArray(char[][] data)
Encodes one 2D character array as a serialized extent.static byte[]
encodeOne2DDoubleArray(double[][] data)
Encodes one 2D double array as a serialized extent.static byte[]
encodeOne2DFloatArray(float[][] data)
Encodes one 2D float array as a serialized extent.static byte[]
encodeOne2DIntegerArray(int[][] data)
Encodes one 2D integer array as a serialized extent.static byte[]
encodeOne2DLongArray(long[][] data)
Encodes one 2D long array as a serialized extent.static byte[]
encodeOne2DShortArray(short[][] data)
Encodes one 2D short array as a serialized extent.static byte[]
encodeOneAddress(Address data)
Encodes one Address as a serialized extent.static byte[]
encodeOneAddressArray(Address[] data)
Encodes one Address array as a serialized extent.static byte[]
encodeOneBigInteger(java.math.BigInteger data)
Encodes one BigInteger as a serialized extent Null is encoded as the two identifiers: NULL, followed by BIGINT.static byte[]
encodeOneBigIntegerArray(java.math.BigInteger[] data)
Encodes one BigInteger array as a serialized extent.static byte[]
encodeOneBoolean(boolean data)
Encodes one boolean as a serialized extent.static byte[]
encodeOneBooleanArray(boolean[] data)
Encodes one boolean array as a serialized extent.static byte[]
encodeOneByte(byte data)
Encodes one byte as a serialized extent.static byte[]
encodeOneByteArray(byte[] data)
Encodes one byte array as a serialized extent.static byte[]
encodeOneCharacter(char data)
Encodes one character as a serialized extent.static byte[]
encodeOneCharacterArray(char[] data)
Encodes one character array as a serialized extent.static byte[]
encodeOneDouble(double data)
Encodes one double as a serialized extent.static byte[]
encodeOneDoubleArray(double[] data)
Encodes one double array as a serialized extent.static byte[]
encodeOneFloat(float data)
Encodes float byte as a serialized extent.static byte[]
encodeOneFloatArray(float[] data)
Encodes one float array as a serialized extent.static byte[]
encodeOneInteger(int data)
Encodes one integer as a serialized extent.static byte[]
encodeOneIntegerArray(int[] data)
Encodes one integer array as a serialized extent.static byte[]
encodeOneLong(long data)
Encodes one long as a serialized extent.static byte[]
encodeOneLongArray(long[] data)
Encodes one long array as a serialized extent.static byte[]
encodeOneShort(short data)
Encodes one short as a serialized extent.static byte[]
encodeOneShortArray(short[] data)
Encodes one short array as a serialized extent.static byte[]
encodeOneString(java.lang.String data)
Encodes one String as a serialized extent.static byte[]
encodeOneStringArray(java.lang.String[] data)
Encodes one String array as a serialized extent.
-
-
-
Method Detail
-
encodeOneByte
public static byte[] encodeOneByte(byte data)
Encodes one byte as a serialized extent.- Parameters:
data
- one byte.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneBoolean
public static byte[] encodeOneBoolean(boolean data)
Encodes one boolean as a serialized extent.- Parameters:
data
- one boolean.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneCharacter
public static byte[] encodeOneCharacter(char data)
Encodes one character as a serialized extent.- Parameters:
data
- one character.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneShort
public static byte[] encodeOneShort(short data)
Encodes one short as a serialized extent.- Parameters:
data
- one short.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneInteger
public static byte[] encodeOneInteger(int data)
Encodes one integer as a serialized extent.- Parameters:
data
- one integer.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneLong
public static byte[] encodeOneLong(long data)
Encodes one long as a serialized extent.- Parameters:
data
- one long.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneFloat
public static byte[] encodeOneFloat(float data)
Encodes float byte as a serialized extent.- Parameters:
data
- one float.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneDouble
public static byte[] encodeOneDouble(double data)
Encodes one double as a serialized extent.- Parameters:
data
- one double.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneByteArray
public static byte[] encodeOneByteArray(byte[] data)
Encodes one byte array as a serialized extent. Null is encoded as the two identifiers: NULL, followed by A_BYTE.- Parameters:
data
- one byte array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneBooleanArray
public static byte[] encodeOneBooleanArray(boolean[] data)
Encodes one boolean array as a serialized extent. Null is encoded as the two identifiers: NULL, followed by A_BOOLEAN.- Parameters:
data
- one boolean array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneCharacterArray
public static byte[] encodeOneCharacterArray(char[] data)
Encodes one character array as a serialized extent. Null is encoded as the two identifiers: NULL, followed by A_CHAR.- Parameters:
data
- one character array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneShortArray
public static byte[] encodeOneShortArray(short[] data)
Encodes one short array as a serialized extent. Null is encoded as the two identifiers: NULL, followed by A_SHORT.- Parameters:
data
- one short array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneIntegerArray
public static byte[] encodeOneIntegerArray(int[] data)
Encodes one integer array as a serialized extent. Null is encoded as the two identifiers: NULL, followed by A_INT.- Parameters:
data
- one integer array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneLongArray
public static byte[] encodeOneLongArray(long[] data)
Encodes one long array as a serialized extent. Null is encoded as the two identifiers: NULL, followed by A_LONG.- Parameters:
data
- one long array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneFloatArray
public static byte[] encodeOneFloatArray(float[] data)
Encodes one float array as a serialized extent. Null is encoded as the two identifiers: NULL, followed by A_FLOAT.- Parameters:
data
- one float array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneDoubleArray
public static byte[] encodeOneDoubleArray(double[] data)
Encodes one double array as a serialized extent. Null is encoded as the two identifiers: NULL, followed by A_DOUBLE.- Parameters:
data
- one double array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneString
public static byte[] encodeOneString(java.lang.String data)
Encodes one String as a serialized extent. Null is encoded as the two identifiers: NULL, followed by STRING.- Parameters:
data
- one string.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneAddress
public static byte[] encodeOneAddress(Address data)
Encodes one Address as a serialized extent. Null is encoded as the two identifiers: NULL, followed by ADDRESS.- Parameters:
data
- one address.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneBigInteger
public static byte[] encodeOneBigInteger(java.math.BigInteger data)
Encodes one BigInteger as a serialized extent Null is encoded as the two identifiers: NULL, followed by BIGINT.- Parameters:
data
- one BigInteger.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOne2DByteArray
public static byte[] encodeOne2DByteArray(byte[][] data)
Encodes one 2D byte array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by A_BYTE.- Parameters:
data
- one 2D byte array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOne2DBooleanArray
public static byte[] encodeOne2DBooleanArray(boolean[][] data)
Encodes one 2D boolean array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by A_BOOLEAN.- Parameters:
data
- one 2D boolean array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOne2DCharacterArray
public static byte[] encodeOne2DCharacterArray(char[][] data)
Encodes one 2D character array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by A_CHAR.- Parameters:
data
- one 2D character array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOne2DShortArray
public static byte[] encodeOne2DShortArray(short[][] data)
Encodes one 2D short array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by A_SHORT.- Parameters:
data
- one 2D short array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOne2DIntegerArray
public static byte[] encodeOne2DIntegerArray(int[][] data)
Encodes one 2D integer array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by A_INT.- Parameters:
data
- one 2D integer array- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOne2DFloatArray
public static byte[] encodeOne2DFloatArray(float[][] data)
Encodes one 2D float array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by A_FLOAT.- Parameters:
data
- one 2D float array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOne2DLongArray
public static byte[] encodeOne2DLongArray(long[][] data)
Encodes one 2D long array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by A_LONG.- Parameters:
data
- one 2D long array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOne2DDoubleArray
public static byte[] encodeOne2DDoubleArray(double[][] data)
Encodes one 2D double array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by A_DOUBLE.- Parameters:
data
- one 2D double array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneStringArray
public static byte[] encodeOneStringArray(java.lang.String[] data)
Encodes one String array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by STRING.- Parameters:
data
- one string array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneAddressArray
public static byte[] encodeOneAddressArray(Address[] data)
Encodes one Address array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by ADDRESS.- Parameters:
data
- one address array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
encodeOneBigIntegerArray
public static byte[] encodeOneBigIntegerArray(java.math.BigInteger[] data)
Encodes one BigInteger array as a serialized extent. Null is encoded as the three identifiers: NULL, followed by ARRAY, followed by BIGINT.- Parameters:
data
- one BigInteger array.- Returns:
- the byte array that contains the argument descriptor and the encoded data.
-
-