use of org.fisco.bcos.web3j.abi.datatypes.Array in project web3sdk by FISCO-BCOS.
the class ResultEntity method typeToObject.
public static Object typeToObject(Type type) {
Object obj = null;
if (type instanceof NumericType) {
// uint int
obj = ((NumericType) type).getValue();
} else if (type instanceof Bool) {
// bool
obj = ((Bool) type).getValue();
} else if (type instanceof Address) {
// address
obj = type.toString();
} else if (type instanceof Bytes) {
// bytes32
obj = new String(((Bytes) type).getValue()).trim();
} else if (type instanceof DynamicBytes) {
// bytes
obj = new String(((DynamicBytes) type).getValue()).trim();
} else if (type instanceof Utf8String) {
// string
obj = ((Utf8String) type).getValue();
} else if (type instanceof Array) {
// T[] T[k]
List<Object> r = new ArrayList<Object>();
List l = ((Array) type).getValue();
for (int i = 0; i < l.size(); ++i) {
r.add(typeToObject((Type) l.get(i)));
}
obj = (Object) r;
} else {
obj = (Object) obj;
}
return obj;
}
Aggregations