Class DelegatingByteArrayCodec<T>
- java.lang.Object
-
- org.pipecraft.pipes.serialization.DelegatingByteArrayCodec<T>
-
- Type Parameters:
T- The encoded/decoded items' data type
- All Implemented Interfaces:
ByteArrayCodec<T>,ByteArrayDecoder<T>,ByteArrayEncoder<T>
public class DelegatingByteArrayCodec<T> extends Object implements ByteArrayCodec<T>
Wraps a given byte array encoder and byte array decoder, and delegates encoding/decoding requests to them.- Author:
- Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description DelegatingByteArrayCodec(ByteArrayEncoder<T> encoder, ByteArrayDecoder<T> decoder)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tdecode(byte[] bytes)byte[]encode(T item)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pipecraft.pipes.serialization.ByteArrayDecoder
newFixedRecSizeDecoder
-
-
-
-
Constructor Detail
-
DelegatingByteArrayCodec
public DelegatingByteArrayCodec(ByteArrayEncoder<T> encoder, ByteArrayDecoder<T> decoder)
Constructor- Parameters:
encoder- The encoderdecoder- The decoder
-
-
Method Detail
-
encode
public byte[] encode(T item)
- Specified by:
encodein interfaceByteArrayEncoder<T>- Parameters:
item- The item to encode- Returns:
- The encoded item, as byte array
-
decode
public T decode(byte[] bytes) throws ValidationPipeException
- Specified by:
decodein interfaceByteArrayDecoder<T>- Parameters:
bytes- The byte representation of an item to decode- Returns:
- The decoded item
- Throws:
ValidationPipeException- In case that the data for decoding is illegal
-
-