Class 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.Object
    Abstract base class for decoders.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int EOF  
    • 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.Charset getCharset()
      Returns the character set to use when decoding an input stream.
      <U extends T>
      U
      read​(java.io.InputStream inputStream)
      Reads a value from an input stream.
      abstract <U extends T>
      U
      read​(java.io.Reader reader)
      Reads a value from a character stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Decoder

        public Decoder​(java.nio.charset.Charset charset)
        Constructs a new decoder.
        Parameters:
        charset - The character set to use when decoding an input stream.
    • 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.