Class AvroDecoder<T>
- java.lang.Object
-
- org.pipecraft.pipes.serialization.AvroDecoder<T>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ItemDecoder<T>
public class AvroDecoder<T> extends Object implements ItemDecoder<T>
AnItemDecoderthat decodes objects encoded in avro format.- Author:
- Zacharya Haitin, Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description AvroDecoder(Class<T> clazz, InputStream is)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Tdecode()Reads and decodes the next object from the input stream.static <R> DecoderFactory<R>getFactory(Class<R> clazz)
-
-
-
Constructor Detail
-
AvroDecoder
public AvroDecoder(Class<T> clazz, InputStream is) throws IOException
Constructor.- Parameters:
clazz- The java class the bytes will be decoded to.is- The input stream to bound to this decoder. Not expected to be buffered.- Throws:
IOException- In case of an IO error while preparing to read from the input stream
-
-
Method Detail
-
decode
public T decode() throws IOException
Description copied from interface:ItemDecoderReads and decodes the next object from the input stream.- Specified by:
decodein interfaceItemDecoder<T>- Returns:
- The decoded item from the input stream provided on construction, or null if end of stream was reached
- Throws:
IOException- In case of a read error
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceItemDecoder<T>- Throws:
IOException
-
getFactory
public static <R> DecoderFactory<R> getFactory(Class<R> clazz)
- Parameters:
clazz- The java class representing the decoded items' data type- Returns:
- A decoder factory producing avro decoders based on the given type
-
-