Package org.httprpc.io
Class Decoder<T>
- java.lang.Object
-
- org.httprpc.io.Decoder<T>
-
- Type Parameters:
T- The type of value produced by the decoder.
- Direct Known Subclasses:
CSVDecoder,JSONDecoder,TextDecoder
public abstract class Decoder<T> extends java.lang.ObjectAbstract base class for decoders.
-
-
Field Summary
Fields Modifier and Type Field Description protected static intEOF
-
Constructor Summary
Constructors Constructor Description Decoder(java.nio.charset.Charset charset)Constructs a new decoder.
-
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 decoding an input stream.<U extends T>
Uread(java.io.InputStream inputStream)Reads a value from an input stream.abstract <U extends T>
Uread(java.io.Reader reader)Reads a value from a character stream.
-
-
-
Field Detail
-
EOF
protected static final int EOF
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCharset
public java.nio.charset.Charset getCharset()
Returns the character set to use when decoding an input stream.- Returns:
- The input stream's character set.
-
read
public <U extends T> U read(java.io.InputStream inputStream) throws java.io.IOException
Reads a value from an input stream.- Type Parameters:
U- The decoded value type.- Parameters:
inputStream- The input stream to read from.- Returns:
- The decoded value.
- Throws:
java.io.IOException- If an exception occurs.
-
read
public abstract <U extends T> U read(java.io.Reader reader) throws java.io.IOException
Reads a value from a character stream.- Type Parameters:
U- The decoded value type.- Parameters:
reader- The character stream to read from.- Returns:
- The decoded value.
- Throws:
java.io.IOException- If an exception occurs.
-
-