Class OptimizedUTF8Encoder

java.lang.Object
org.postgresql.core.Encoding
org.postgresql.core.OptimizedUTF8Encoder
Direct Known Subclasses:
ByteOptimizedUTF8Encoder, CharOptimizedUTF8Encoder

abstract class OptimizedUTF8Encoder extends Encoding
UTF-8 encoder implementation which validates values during decoding which is significantly faster than using a CharsetDecoder.
  • Field Details

  • Constructor Details

    • OptimizedUTF8Encoder

      OptimizedUTF8Encoder()
  • Method Details

    • getCharArray

      char[] getCharArray(int size)
      Returns a char[] to use for decoding. Will use member variable if size is small enough. This method must be called, and returned char[] only used, from synchronized block.
      Parameters:
      size - The needed size of returned char[].
      Returns:
      A char[] at least as long as length.
    • charDecode

      String charDecode(byte[] encodedString, int offset, int length) throws IOException
      Decodes binary content to String by first converting to char[].
      Throws:
      IOException
    • decodeToChars

      static String decodeToChars(byte[] data, int offset, int length, char[] chars, int out) throws IOException
      Decodes data from offset with given length as utf-8 and gives each decoded code point to the codePointConsumer.
      Parameters:
      data - The byte[] to decode.
      offset - The starting index in data.
      length - The number of bytes in data to decode.
      codePointConsumer - The consumer of all decoded code points.
      Throws:
      IOException - If data is not valid utf-8 content.
    • checkByte

      private static void checkByte(int ch, int pos, int len) throws IOException
      Throws:
      IOException
    • checkMinimal

      private static void checkMinimal(int ch, int minValue) throws IOException
      Throws:
      IOException