Class EncodedWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public class EncodedWriter
    extends java.io.Writer
    EncodedWriter -- A writer the encodes all input for a specific context and writes the encoded output to another writer.
    • Constructor Summary

      Constructors 
      Constructor Description
      EncodedWriter​(java.io.Writer out, java.lang.String contextName)
      Creates an EncodedWriter that uses the specified encoder to encode all input before sending it to the wrapped writer.
      EncodedWriter​(java.io.Writer out, Encoder encoder)
      Creates an EncodedWriter that uses the specified encoder to encode all input before sending it to the wrapped writer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void flush()  
      void write​(char[] cbuf, int off, int len)  
      • Methods inherited from class java.io.Writer

        append, append, append, nullWriter, write, write, write, write
      • Methods inherited from class java.lang.Object

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

      • EncodedWriter

        public EncodedWriter​(java.io.Writer out,
                             Encoder encoder)
        Creates an EncodedWriter that uses the specified encoder to encode all input before sending it to the wrapped writer.
        Parameters:
        out - the target for all writes
        encoder - the encoder to use
      • EncodedWriter

        public EncodedWriter​(java.io.Writer out,
                             java.lang.String contextName)
                      throws UnsupportedContextException
        Creates an EncodedWriter that uses the specified encoder to encode all input before sending it to the wrapped writer. This method is equivalent to calling:
             new EncodedWriter(out, Encoders.forName(contextName));
         
        Parameters:
        out - the target for all writes
        contextName - the encoding context name.
        Throws:
        UnsupportedContextException - if the contextName is unrecognized or not supported.
    • Method Detail

      • write

        public void write​(char[] cbuf,
                          int off,
                          int len)
                   throws java.io.IOException
        Specified by:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in class java.io.Writer
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Writer
        Throws:
        java.io.IOException