Package org.httprpc.io
Class Encoder<T>
- java.lang.Object
-
- org.httprpc.io.Encoder<T>
-
- Type Parameters:
T- The type of value consumed by the encoder.
- Direct Known Subclasses:
CSVEncoder,JSONEncoder,TemplateEncoder,TextEncoder
public abstract class Encoder<T> extends java.lang.ObjectAbstract base class for encoders.
-
-
Constructor Summary
Constructors Constructor Description Encoder(java.nio.charset.Charset charset)Constructs a new encoder.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.nio.charset.CharsetgetCharset()Returns the character set to use when encoding an output stream.voidwrite(T value, java.io.OutputStream outputStream)Writes a value to an output stream.abstract voidwrite(T value, java.io.Writer writer)Writes a value to a character stream.
-
-
-
Method Detail
-
getCharset
public java.nio.charset.Charset getCharset()
Returns the character set to use when encoding an output stream.- Returns:
- The output stream's character set.
-
write
public void write(T value, java.io.OutputStream outputStream) throws java.io.IOException
Writes a value to an output stream.- Parameters:
value- The value to encode.outputStream- The output stream to write to.- Throws:
java.io.IOException- If an exception occurs.
-
write
public abstract void write(T value, java.io.Writer writer) throws java.io.IOException
Writes a value to a character stream.- Parameters:
value- The value to encode.writer- The character stream to write to.- Throws:
java.io.IOException- If an exception occurs.
-
-