org.hyperledger.fabric.contract.execution.SerializerInterface Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fabric-chaincode-shim Show documentation
Show all versions of fabric-chaincode-shim Show documentation
Hyperledger Fabric Java Chaincode Shim
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.contract.execution;
import org.hyperledger.fabric.contract.metadata.TypeSchema;
import org.hyperledger.fabric.contract.routing.TypeRegistry;
/**
* This interface allows contract developers to change the serialization mechanism.
* There are two scenaios where instances of DataTypes are serialized.
*
* When the objects are (logically) transferred from the Client application to the Contract resulting
* in a transaction function being invoked. Typicaly this is JSON, hence a default JSON parser is provided.
*
* The JSONTransactionSerializer can be extended if needed
*/
public interface SerializerInterface {
/**
* Convert the value supplied to a byte array, according to the TypeSchema
*
* @param value
* @param ts
* @return
*/
byte[] toBuffer(Object value, TypeSchema ts);
/**
* Take the byte buffer and return the object as required
*
* @param buffer Byte buffer from the wire
* @param ts TypeSchema representing the type
*
* @return Object created; relies on Java auto-boxing for primitives
*
* @throws InstantiationException
* @throws IllegalAccessException
*/
Object fromBuffer(byte[] buffer, TypeSchema ts);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy