Search in sources :

Example 1 with DynamicArray

use of org.bcos.web3j.abi.datatypes.DynamicArray in project web3sdk by FISCO-BCOS.

the class TypeDecoder method decodeDynamicArray.

@SuppressWarnings("unchecked")
static <T extends Type> T decodeDynamicArray(String input, int offset, TypeReference<T> typeReference) {
    int length = decodeUintAsInt(input, offset);
    BiFunction<List<T>, String, T> function = (elements, typeName) -> {
        if (elements.isEmpty()) {
            return (T) DynamicArray.empty(typeName);
        } else {
            return (T) new DynamicArray<>(elements);
        }
    };
    int valueOffset = offset + MAX_BYTE_LENGTH_FOR_HEX_STRING;
    return decodeArrayElements(input, valueOffset, typeReference, length, function);
}
Also used : Address(org.bcos.web3j.abi.datatypes.Address) Numeric(org.bcos.web3j.utils.Numeric) IntType(org.bcos.web3j.abi.datatypes.IntType) Bytes(org.bcos.web3j.abi.datatypes.Bytes) Int(org.bcos.web3j.abi.datatypes.Int) Ufixed(org.bcos.web3j.abi.datatypes.Ufixed) Utf8String(org.bcos.web3j.abi.datatypes.Utf8String) NumericType(org.bcos.web3j.abi.datatypes.NumericType) BiFunction(java.util.function.BiFunction) Array(org.bcos.web3j.abi.datatypes.Array) FixedPointType(org.bcos.web3j.abi.datatypes.FixedPointType) StandardCharsets(java.nio.charset.StandardCharsets) StaticArray(org.bcos.web3j.abi.datatypes.StaticArray) Type(org.bcos.web3j.abi.datatypes.Type) Uint(org.bcos.web3j.abi.datatypes.Uint) InvocationTargetException(java.lang.reflect.InvocationTargetException) ArrayList(java.util.ArrayList) List(java.util.List) ParameterizedType(java.lang.reflect.ParameterizedType) Bool(org.bcos.web3j.abi.datatypes.Bool) DynamicArray(org.bcos.web3j.abi.datatypes.DynamicArray) DynamicBytes(org.bcos.web3j.abi.datatypes.DynamicBytes) BigInteger(java.math.BigInteger) Fixed(org.bcos.web3j.abi.datatypes.Fixed) DynamicArray(org.bcos.web3j.abi.datatypes.DynamicArray) ArrayList(java.util.ArrayList) List(java.util.List) Utf8String(org.bcos.web3j.abi.datatypes.Utf8String) Uint(org.bcos.web3j.abi.datatypes.Uint)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 BigInteger (java.math.BigInteger)1 StandardCharsets (java.nio.charset.StandardCharsets)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BiFunction (java.util.function.BiFunction)1 Address (org.bcos.web3j.abi.datatypes.Address)1 Array (org.bcos.web3j.abi.datatypes.Array)1 Bool (org.bcos.web3j.abi.datatypes.Bool)1 Bytes (org.bcos.web3j.abi.datatypes.Bytes)1 DynamicArray (org.bcos.web3j.abi.datatypes.DynamicArray)1 DynamicBytes (org.bcos.web3j.abi.datatypes.DynamicBytes)1 Fixed (org.bcos.web3j.abi.datatypes.Fixed)1 FixedPointType (org.bcos.web3j.abi.datatypes.FixedPointType)1 Int (org.bcos.web3j.abi.datatypes.Int)1 IntType (org.bcos.web3j.abi.datatypes.IntType)1 NumericType (org.bcos.web3j.abi.datatypes.NumericType)1 StaticArray (org.bcos.web3j.abi.datatypes.StaticArray)1 Type (org.bcos.web3j.abi.datatypes.Type)1