Package org.postgresql.core
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 aCharsetDecoder.
-
-
Field Summary
Fields Modifier and Type Field Description private char[]decoderArrayprivate static intMAX_CODE_POINTprivate static intMIN_2_BYTESprivate static intMIN_3_BYTESprivate static intMIN_4_BYTESprivate intthresholdSize(package private) static java.nio.charset.CharsetUTF_8_CHARSET
-
Constructor Summary
Constructors Constructor Description OptimizedUTF8Encoder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.lang.StringcharDecode(byte[] encodedString, int offset, int length)Decodes binary content toStringby first converting tochar[].private static voidcheckByte(int ch, int pos, int len)private static voidcheckMinimal(int ch, int minValue)(package private) static java.lang.StringdecodeToChars(byte[] data, int offset, int length, char[] chars, int out)Decodes data from offset with given length as utf-8 and gives each decoded code point to the codePointConsumer.(package private) char[]getCharArray(int size)Returns achar[]to use for decoding.-
Methods inherited from class org.postgresql.core.Encoding
decode, decode, defaultEncoding, encode, getDatabaseEncoding, getDecodingReader, getEncodingWriter, getJVMEncoding, hasAsciiNumbers, name, toString
-
-
-
-
Field Detail
-
UTF_8_CHARSET
static final java.nio.charset.Charset UTF_8_CHARSET
-
MIN_2_BYTES
private static final int MIN_2_BYTES
- See Also:
- Constant Field Values
-
MIN_3_BYTES
private static final int MIN_3_BYTES
- See Also:
- Constant Field Values
-
MIN_4_BYTES
private static final int MIN_4_BYTES
- See Also:
- Constant Field Values
-
MAX_CODE_POINT
private static final int MAX_CODE_POINT
- See Also:
- Constant Field Values
-
thresholdSize
private final int thresholdSize
- See Also:
- Constant Field Values
-
decoderArray
private char[] decoderArray
-
-
Method Detail
-
getCharArray
char[] getCharArray(int size)
Returns achar[]to use for decoding. Will use member variable if size is small enough. This method must be called, and returnedchar[]only used, fromsynchronizedblock.- Parameters:
size- The needed size of returnedchar[].- Returns:
- A
char[]at least as long as length.
-
charDecode
java.lang.String charDecode(byte[] encodedString, int offset, int length) throws java.io.IOExceptionDecodes binary content toStringby first converting tochar[].- Throws:
java.io.IOException
-
decodeToChars
static java.lang.String decodeToChars(byte[] data, int offset, int length, char[] chars, int out) throws java.io.IOExceptionDecodes data from offset with given length as utf-8 and gives each decoded code point to the codePointConsumer.- Parameters:
data- Thebyte[]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:
java.io.IOException- If data is not valid utf-8 content.
-
checkByte
private static void checkByte(int ch, int pos, int len) throws java.io.IOException- Throws:
java.io.IOException
-
checkMinimal
private static void checkMinimal(int ch, int minValue) throws java.io.IOException- Throws:
java.io.IOException
-
-