Class ProtobufEncoder<T extends com.google.protobuf.Message>
- java.lang.Object
-
- org.pipecraft.pipes.serialization.ProtobufEncoder<T>
-
- Type Parameters:
T- The data type of the items to encode. Must be a protobuf generated type (i.e. must extendMessage).
- All Implemented Interfaces:
Closeable,AutoCloseable,ItemEncoder<T>
public class ProtobufEncoder<T extends com.google.protobuf.Message> extends Object implements ItemEncoder<T>
AnItemEncoderthat encodes objects in Protocol Buffers format (sequential, delimited proto objects).- Author:
- Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description ProtobufEncoder(OutputStream os)ConstructorProtobufEncoder(OutputStream os, FileWriteOptions options)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidencode(T item)static <R extends com.google.protobuf.Message>
EncoderFactory<R>getFactory()
-
-
-
Constructor Detail
-
ProtobufEncoder
public ProtobufEncoder(OutputStream os) throws IOException
Constructor- Parameters:
os- The output stream to bound to this encoder. Not expected to be buffered.- Throws:
IOException- In case of an IO error while preparing to write to the stream
-
ProtobufEncoder
public ProtobufEncoder(OutputStream os, FileWriteOptions options) throws IOException
Constructor- Parameters:
os- The output stream to bound to this encoder. Not expected to be buffered.options- The write options defining how to handle the output stream- Throws:
IOException- In case of an IO error while preparing to write to the stream
-
-
Method Detail
-
encode
public void encode(T item) throws IOException
- Specified by:
encodein interfaceItemEncoder<T extends com.google.protobuf.Message>- Parameters:
item- The item to encode into the output stream provided at construction type- Throws:
IOException- In case of write error
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getFactory
public static <R extends com.google.protobuf.Message> EncoderFactory<R> getFactory()
- Returns:
- A decoder factory producing protobuf decoders based on the given type
-
-