Class TxtEncoderFactory<T>
- java.lang.Object
-
- org.pipecraft.pipes.serialization.TxtEncoderFactory<T>
-
- Type Parameters:
T- The data type of the items to encode
- All Implemented Interfaces:
EncoderFactory<T>
public class TxtEncoderFactory<T> extends Object implements EncoderFactory<T>
AnEncoderFactorythat encodes items as text, delimiting them by "\n". See alsoTxtDecoderFactory.- Author:
- Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description TxtEncoderFactory()Constructor Assumes UTF8 text encoding and textualization based on the object's toString()TxtEncoderFactory(Function<T,String> itemTextualizer)Constructor Assumes UTF8 text encodingTxtEncoderFactory(Function<T,String> itemTextualizer, Charset charset)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteArrayEncoder<T>newByteArrayEncoder()ItemEncoder<T>newEncoder(OutputStream os, FileWriteOptions writeOptions)-
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.EncoderFactory
newEncoder
-
-
-
-
Constructor Detail
-
TxtEncoderFactory
public TxtEncoderFactory(Function<T,String> itemTextualizer, Charset charset)
Constructor- Parameters:
itemTextualizer- A converter from the object to its textual formcharset- The charset encoding to use for encoding
-
TxtEncoderFactory
public TxtEncoderFactory(Function<T,String> itemTextualizer)
Constructor Assumes UTF8 text encoding- Parameters:
itemTextualizer- A converter from the object to its textual form
-
TxtEncoderFactory
public TxtEncoderFactory()
Constructor Assumes UTF8 text encoding and textualization based on the object's toString()
-
-
Method Detail
-
newEncoder
public ItemEncoder<T> newEncoder(OutputStream os, FileWriteOptions writeOptions) throws IOException
- Specified by:
newEncoderin interfaceEncoderFactory<T>- Parameters:
os- The output stream the encoder should be bound to. Not expected to be buffered. The encoder handles buffering.writeOptions- The way the output stream should be handled- Returns:
- The new encoder
- Throws:
IOException- In case of an IO error while preparing to write to the output stream
-
newByteArrayEncoder
public ByteArrayEncoder<T> newByteArrayEncoder()
- Specified by:
newByteArrayEncoderin interfaceEncoderFactory<T>- Returns:
- A new
ByteArrayEncoder, able to efficiently encode individual items as byte arrays. The default implementation goes through aByteArrayOutputStreamand is not very efficient, so sub-classes are encouraged to override it when a faster alternative is available.
-
-