Class AvroEncoder<T>
- java.lang.Object
-
- org.pipecraft.pipes.serialization.AvroEncoder<T>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ItemEncoder<T>
public class AvroEncoder<T> extends Object implements ItemEncoder<T>
AnItemEncoderthat encode any java class to bytes using avro.- Author:
- Zacharya Haitin
-
-
Constructor Summary
Constructors Constructor Description AvroEncoder(Class<T> clazz, OutputStream os)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidencode(T item)static <R> EncoderFactory<R>getFactory(Class<R> clazz)
-
-
-
Constructor Detail
-
AvroEncoder
public AvroEncoder(Class<T> clazz, OutputStream os) throws IOException
Constructor- Parameters:
clazz- The java class representing the type to encodeos- The output stream this encoder is bound to. Not expected to be buffered. Buffering is added internally.- Throws:
IOException- In case of an IO error while preparing to write to the output stream
-
-
Method Detail
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
encode
public void encode(T item) throws IOException
- Specified by:
encodein interfaceItemEncoder<T>- Parameters:
item- The item to encode into the output stream provided at construction type- Throws:
IOException- In case of write error
-
getFactory
public static <R> EncoderFactory<R> getFactory(Class<R> clazz)
- Parameters:
clazz- The java class representing the encoded items' data type- Returns:
- An encoder factory producing avro encoders based on the given type
-
-