Class 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.Object
    Abstract 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.Charset getCharset()
      Returns the character set to use when encoding an output stream.
      void write​(T value, java.io.OutputStream outputStream)
      Writes a value to an output stream.
      abstract void write​(T value, java.io.Writer writer)
      Writes a value to a character stream.
      • Methods inherited from class java.lang.Object

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

      • Encoder

        public Encoder​(java.nio.charset.Charset charset)
        Constructs a new encoder.
        Parameters:
        charset - The character set to use when encoding an output 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.