Class CopyCharsUnicodeUtils


  • public final class CopyCharsUnicodeUtils
    extends Object
    Utilities for copying textual data, with Unicode BOM support. The participating media include files, arrays, readers/writers, or some combinations thereof.
    Since:
    0.6.0
    Version:
    $Id: CopyCharsUnicodeUtils.java 16154 2012-07-14 16:34:05Z colin $
    Author:
    tlerios@marketcetera.com
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CopyCharsUnicodeUtils()
      Constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void copy​(char[] data, String name, SignatureCharset requestedSignatureCharset)
      Copies an in-memory character array into the given location and using the given signature/charset.
      static long copy​(Reader in, boolean skipClose, String out)
      Copies a character stream from the given source to the given location, attempting to retain signature/charset information.
      static char[] copy​(String name, DecodingStrategy decodingStrategy)
      Copies the character stream at the given location (and interpreted using the given strategy) into memory, returning a character array.
      static long copy​(String in, DecodingStrategy decodingStrategy, Writer out, boolean skipClose)
      Copies a character stream from the given location (and interpreted using the given strategy) to the given sink.
      static long copy​(String in, DecodingStrategy decodingStrategy, String out)
      Copies a character stream from one given location (and interpreted using the given strategy) to another, attempting to retain signature/charset information.
    • Constructor Detail

      • CopyCharsUnicodeUtils

        private CopyCharsUnicodeUtils()
        Constructor. It is private so that no instances can be created.
    • Method Detail

      • copy

        public static long copy​(String in,
                                DecodingStrategy decodingStrategy,
                                String out)
                         throws I18NException
        Copies a character stream from one given location (and interpreted using the given strategy) to another, attempting to retain signature/charset information.
        Parameters:
        in - The name of the character source, as interpreted by ReaderWrapper(String,DecodingStrategy).
        decodingStrategy - The decoding strategy. It may be null to use the default JVM charset.
        out - The name of the character sink, as interpreted by WriterWrapper(String,SignatureCharset).
        Returns:
        The number of characters copied.
        Throws:
        I18NException - Thrown if there is a data read/write error.
      • copy

        public static long copy​(Reader in,
                                boolean skipClose,
                                String out)
                         throws I18NException
        Copies a character stream from the given source to the given location, attempting to retain signature/charset information.
        Parameters:
        in - The character source, as interpreted by ReaderWrapper(Reader,boolean).
        skipClose - True if the source reader should not be closed.
        out - The name of the character sink, as interpreted by WriterWrapper(String,SignatureCharset).
        Returns:
        The number of characters copied.
        Throws:
        I18NException - Thrown if there is a data read/write error.
      • copy

        public static long copy​(String in,
                                DecodingStrategy decodingStrategy,
                                Writer out,
                                boolean skipClose)
                         throws I18NException
        Copies a character stream from the given location (and interpreted using the given strategy) to the given sink.
        Parameters:
        in - The name of the character source, as interpreted by ReaderWrapper(String,DecodingStrategy).
        decodingStrategy - The decoding strategy. It may be null to use the default JVM charset.
        out - The character sink, as interpreted by WriterWrapper(Writer,boolean).
        skipClose - True if the sink writer should not be closed.
        Returns:
        The number of characters copied.
        Throws:
        I18NException - Thrown if there is a data read/write error.
      • copy

        public static char[] copy​(String name,
                                  DecodingStrategy decodingStrategy)
                           throws I18NException
        Copies the character stream at the given location (and interpreted using the given strategy) into memory, returning a character array.
        Parameters:
        name - The name of the character source, as interpreted by ReaderWrapper(String,DecodingStrategy).
        decodingStrategy - The decoding strategy. It may be null to use the default JVM charset.
        Returns:
        The array.
        Throws:
        I18NException - Thrown if there is a data read/write error.
      • copy

        public static void copy​(char[] data,
                                String name,
                                SignatureCharset requestedSignatureCharset)
                         throws I18NException
        Copies an in-memory character array into the given location and using the given signature/charset.
        Parameters:
        data - The array.
        name - The name of the character sink, as interpreted by WriterWrapper(String,SignatureCharset).
        requestedSignatureCharset - The signature/charset. It may be null to use the default JVM charset.
        Throws:
        I18NException - Thrown if there is a data read/write error.