/** * Deserializes the encoded data from the given input stream, setting the values as fields * on the given {@code TransactionEdit} instances. This method expects first value in the * {code DataInput} to be a byte representing the codec version used to serialize the instance. * * @param dest the transaction edit to populate with the deserialized values * @param in the input stream containing the encoded data * @throws IOException if an error occurs while deserializing from the input stream */ public static void decode(TransactionEdit dest, DataInput in) throws IOException { byte version = in.readByte(); TransactionEditCodec codec = CODECS.get(version); if (codec == null) { throw new IOException("TransactionEdit was serialized with an unknown codec version " + version + ". Was it written with a newer version of Tephra?"); } codec.decode(dest, in); }
/** * Serializes the given {@code TransactionEdit} instance with the latest available codec. * This will first write out the version of the codec used to serialize the instance so that * the correct codec can be used when calling {@link #decode(TransactionEdit, DataInput)}. * * @param src the transaction edit to serialize * @param out the output stream to contain the data * @throws IOException if an error occurs while serializing to the output stream */ public static void encode(TransactionEdit src, DataOutput out) throws IOException { TransactionEditCodec latestCodec = CODECS.get(CODECS.firstKey()); out.writeByte(latestCodec.getVersion()); latestCodec.encode(src, out); }
/** * Deserializes the encoded data from the given input stream, setting the values as fields * on the given {@code TransactionEdit} instances. This method expects first value in the * {code DataInput} to be a byte representing the codec version used to serialize the instance. * * @param dest the transaction edit to populate with the deserialized values * @param in the input stream containing the encoded data * @throws IOException if an error occurs while deserializing from the input stream */ public static void decode(TransactionEdit dest, DataInput in) throws IOException { byte version = in.readByte(); TransactionEditCodec codec = CODECS.get(version); if (codec == null) { throw new IOException("TransactionEdit was serialized with an unknown codec version " + version + ". Was it written with a newer version of Tephra?"); } codec.decode(dest, in); }
/** * Deserializes the encoded data from the given input stream, setting the values as fields * on the given {@code TransactionEdit} instances. This method expects first value in the * {code DataInput} to be a byte representing the codec version used to serialize the instance. * * @param dest the transaction edit to populate with the deserialized values * @param in the input stream containing the encoded data * @throws IOException if an error occurs while deserializing from the input stream */ public static void decode(TransactionEdit dest, DataInput in) throws IOException { byte version = in.readByte(); TransactionEditCodec codec = CODECS.get(version); if (codec == null) { throw new IOException("TransactionEdit was serialized with an unknown codec version " + version + ". Was it written with a newer version of Tephra?"); } codec.decode(dest, in); }
/** * Serializes the given {@code TransactionEdit} instance with the latest available codec. * This will first write out the version of the codec used to serialize the instance so that * the correct codec can be used when calling {@link #decode(TransactionEdit, DataInput)}. * * @param src the transaction edit to serialize * @param out the output stream to contain the data * @throws IOException if an error occurs while serializing to the output stream */ public static void encode(TransactionEdit src, DataOutput out) throws IOException { TransactionEditCodec latestCodec = CODECS.get(CODECS.firstKey()); out.writeByte(latestCodec.getVersion()); latestCodec.encode(src, out); }
/** * Encodes the given transaction edit using a specific codec. Note that this is only exposed * for use by tests. */ @VisibleForTesting static void encode(TransactionEdit src, DataOutput out, TransactionEditCodec codec) throws IOException { out.writeByte(codec.getVersion()); codec.encode(src, out); }
/** * Encodes the given transaction edit using a specific codec. Note that this is only exposed * for use by tests. */ @VisibleForTesting static void encode(TransactionEdit src, DataOutput out, TransactionEditCodec codec) throws IOException { out.writeByte(codec.getVersion()); codec.encode(src, out); }
/** * Serializes the given {@code TransactionEdit} instance with the latest available codec. * This will first write out the version of the codec used to serialize the instance so that * the correct codec can be used when calling {@link #decode(TransactionEdit, DataInput)}. * * @param src the transaction edit to serialize * @param out the output stream to contain the data * @throws IOException if an error occurs while serializing to the output stream */ public static void encode(TransactionEdit src, DataOutput out) throws IOException { TransactionEditCodec latestCodec = CODECS.get(CODECS.firstKey()); out.writeByte(latestCodec.getVersion()); latestCodec.encode(src, out); }
/** * Encodes the given transaction edit using a specific codec. Note that this is only exposed * for use by tests. */ @VisibleForTesting static void encode(TransactionEdit src, DataOutput out, TransactionEditCodec codec) throws IOException { out.writeByte(codec.getVersion()); codec.encode(src, out); }