Class EncodingUtil

java.lang.Object
io.deephaven.util.EncodingUtil

public class EncodingUtil extends Object
  • Field Details

    • EMPTY_BOM_ARRAY

      public static final org.apache.commons.io.ByteOrderMark[] EMPTY_BOM_ARRAY
  • Constructor Details

    • EncodingUtil

      public EncodingUtil()
  • Method Details

    • getEncodingInfoForCharset

      @NotNull public static @NotNull EncodingInfo getEncodingInfoForCharset(@NotNull @NotNull Charset charSet) throws IllegalArgumentException
      Get the EncodingInfo associated with a particular Charset
      Parameters:
      charSet - The charset
      Returns:
      the matching EncodingInfo
      Throws:
      IllegalArgumentException - if there is no associated encoding
    • getEncodingInfoForCharset

      public static EncodingInfo getEncodingInfoForCharset(@NotNull @NotNull String charsetName)
      Get the EncodingInfo associated with a particular charset name
      Parameters:
      charsetName - the charset
      Returns:
      the matching EncodingInfo
      Throws:
      IllegalArgumentException - if there is no associated encoding
    • getBOMsForEncoding

      @NotNull public static @NotNull org.apache.commons.io.ByteOrderMark[] getBOMsForEncoding(EncodingInfo encoding)
      Get an array containing the possible byte order marks that could be present within a file of the specified encoding. This is intended for use with BOMInputStream
      Parameters:
      encoding - The encoding.
      Returns:
      An array containing the possible BOMs for the encoding.
    • putUtf8String

      public static void putUtf8String(@NotNull @NotNull ByteBuffer destination, @NotNull @NotNull String value)
      Encode the given string in UTF-8 format into the given ByteBuffer. The string is encoded as an int length followed by the encoded bytes.
      Parameters:
      destination - a ByteBuffer in which to encode the string. The buffer must be big enough for the encoded string.
      value - the String value to encode.
      Throws:
      BufferOverflowException - if the destination isn't big enough.
    • getUtf8String

      public static String getUtf8String(@NotNull @NotNull ByteBuffer source)
      Extract a UTF-8 encoded string from the given buffer. The buffer must be positioned at the start of the encoding, which is an int length followed by the UTF-8 encoded bytes. The buffer is advanced to the end of the string.
      Parameters:
      source - a ByteBuffer positioned at the string encoded as length + UTF-8 encoded bytes.
      Returns:
      a new String extracted from the buffer
      Throws:
      BufferUnderflowException - if there isn't enough data in the source ByteBuffer
      IllegalArgumentException - if there is a decoding error