com.ibm.as400.access

Class ConvTableWriter

  • java.lang.Object
    • java.io.Writer
      • java.io.OutputStreamWriter
        • com.ibm.as400.access.ConvTableWriter
  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable


    public class ConvTableWriter
    extends java.io.OutputStreamWriter
    A ConvTableWriter represents a Toolbox converter that uses stateful character conversion. That is, it wraps an underlying OutputStream and caches/writes the appropriate number of bytes for the given Unicode characters and CCSID/encoding. This is especially useful when converting Strings and characters to a mixed-byte CCSID, and you don't want to have to keep track of which shift state the conversion stream is in between writes.
    See Also:
    ConvTableReader
    • Field Summary

      • Fields inherited from class java.io.Writer

        lock
    • Constructor Summary

      Constructors 
      Constructor and Description
      ConvTableWriter(java.io.OutputStream out)
      Creates a ConvTableWriter that uses the default character encoding.
      ConvTableWriter(java.io.OutputStream out, int ccsid)
      Creates a ConvTableWriter that uses the specified CCSID.
      ConvTableWriter(java.io.OutputStream out, int ccsid, BidiConversionProperties properties)
      Creates a ConvTableWriter that uses the specified CCSID and bi-directional string type.
      ConvTableWriter(java.io.OutputStream out, int ccsid, int bidiStringType)
      Creates a ConvTableWriter that uses the specified CCSID and bi-directional string type.
      ConvTableWriter(java.io.OutputStream out, int ccsid, int bidiStringType, int cacheSize)
      Creates a ConvTableWriter that uses the specified CCSID, bi-directional string type, and internal cache size.
      ConvTableWriter(java.io.OutputStream out, java.lang.String encoding)
      Creates a ConvTableWriter that uses the specified character encoding.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void close()
      Closes this ConvTableWriter and its underlying output stream.
      void flush()
      Flushes the underlying output stream.
      int getCcsid()
      Returns the CCSID used by this ConvTableWriter.
      java.lang.String getEncoding()
      Returns the encoding used by this ConvTableWriter.
      void write(char[] buffer)
      Writes the specified array of characters.
      void write(char[] buffer, int offset, int length)
      Writes a portion of the specified array of characters.
      void write(int c)
      Writes a single character.
      void write(java.lang.String data)
      Writes the specified String.
      void write(java.lang.String data, int offset, int length)
      Writes a portion of the specified String.
      • Methods inherited from class java.io.Writer

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

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

      • ConvTableWriter

        public ConvTableWriter(java.io.OutputStream out)
                        throws java.io.UnsupportedEncodingException
        Creates a ConvTableWriter that uses the default character encoding. The CCSID this writer uses may be set if a known mapping exists for this platform's default character encoding.
        Parameters:
        out - The OutputStream to which to write characters.
        Throws:
        java.io.UnsupportedEncodingException - If the default character encoding or its associated CCSID is not supported.
      • ConvTableWriter

        public ConvTableWriter(java.io.OutputStream out,
                       java.lang.String encoding)
                        throws java.io.UnsupportedEncodingException
        Creates a ConvTableWriter that uses the specified character encoding. The CCSID this writer uses may be set if a known mapping exists for the given encoding.
        Parameters:
        out - The OutputStream to which to write characters.
        encoding - The name of a supported character encoding.
        Throws:
        java.io.UnsupportedEncodingException - If the specified character encoding or its associated CCSID is not supported.
      • ConvTableWriter

        public ConvTableWriter(java.io.OutputStream out,
                       int ccsid)
                        throws java.io.UnsupportedEncodingException
        Creates a ConvTableWriter that uses the specified CCSID.
        Parameters:
        out - The OutputStream to which to write characters.
        ccsid - The CCSID.
        Throws:
        java.io.UnsupportedEncodingException - If the specified CCSID or its corresponding character encoding is not supported.
      • ConvTableWriter

        public ConvTableWriter(java.io.OutputStream out,
                       int ccsid,
                       int bidiStringType)
                        throws java.io.UnsupportedEncodingException
        Creates a ConvTableWriter that uses the specified CCSID and bi-directional string type.
        Parameters:
        out - The OutputStream to which to write characters.
        ccsid - The CCSID.
        bidiStringType - The bi-directional string type.
        Throws:
        java.io.UnsupportedEncodingException - If the specified CCSID or its corresponding character encoding is not supported.
      • ConvTableWriter

        public ConvTableWriter(java.io.OutputStream out,
                       int ccsid,
                       BidiConversionProperties properties)
                        throws java.io.UnsupportedEncodingException
        Creates a ConvTableWriter that uses the specified CCSID and bi-directional string type.
        Parameters:
        out - The OutputStream to which to write characters.
        ccsid - The CCSID.
        properties - The bidi conversion properties.
        Throws:
        java.io.UnsupportedEncodingException - If the specified CCSID or its corresponding character encoding is not supported.
      • ConvTableWriter

        public ConvTableWriter(java.io.OutputStream out,
                       int ccsid,
                       int bidiStringType,
                       int cacheSize)
                        throws java.io.UnsupportedEncodingException
        Creates a ConvTableWriter that uses the specified CCSID, bi-directional string type, and internal cache size.
        Parameters:
        out - The OutputStream to which to write characters.
        ccsid - The CCSID.
        bidiStringType - The bi-directional string type.
        cacheSize - The number of characters to store in the internal buffer. The default is 1024. This number must be greater than zero.
        Throws:
        java.io.UnsupportedEncodingException - If the specified CCSID or its corresponding character encoding is not supported.
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Closes this ConvTableWriter and its underlying output stream.
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStreamWriter
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • flush

        public void flush()
                   throws java.io.IOException
        Flushes the underlying output stream.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStreamWriter
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • getCcsid

        public int getCcsid()
        Returns the CCSID used by this ConvTableWriter.
        Returns:
        The CCSID, or -1 if the CCSID is not known.
      • getEncoding

        public java.lang.String getEncoding()
        Returns the encoding used by this ConvTableWriter. If the CCSID is not known, the superclass encoding is returned. Otherwise, the corresponding encoding for the CCSID is returned, which may be null if no such mapping exists.
        Overrides:
        getEncoding in class java.io.OutputStreamWriter
        Returns:
        The encoding, or null if the encoding is not known.
      • write

        public void write(int c)
                   throws java.io.IOException
        Writes a single character.
        Overrides:
        write in class java.io.OutputStreamWriter
        Parameters:
        c - The character to write.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • write

        public void write(char[] buffer)
                   throws java.io.IOException
        Writes the specified array of characters.
        Overrides:
        write in class java.io.Writer
        Parameters:
        buffer - The characters to be written.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • write

        public void write(char[] buffer,
                 int offset,
                 int length)
                   throws java.io.IOException
        Writes a portion of the specified array of characters.
        Overrides:
        write in class java.io.OutputStreamWriter
        Parameters:
        buffer - The characters to be written.
        offset - The offset into the array from which to begin extracting characters to write.
        length - The number of characters to write. If zero is specified, this method does nothing.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • write

        public void write(java.lang.String data)
                   throws java.io.IOException
        Writes the specified String.
        Overrides:
        write in class java.io.Writer
        Parameters:
        data - The String to write.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • write

        public void write(java.lang.String data,
                 int offset,
                 int length)
                   throws java.io.IOException
        Writes a portion of the specified String.
        Overrides:
        write in class java.io.OutputStreamWriter
        Parameters:
        data - The String to write.
        offset - The offset into the String from which to begin extracting characters to write.
        length - The number of characters to write. If zero is specified, this method does nothing.
        Throws:
        java.io.IOException - If an I/O exception occurs.