Package org.postgresql.core
Class ByteOptimizedUTF8Encoder
java.lang.Object
org.postgresql.core.Encoding
org.postgresql.core.OptimizedUTF8Encoder
org.postgresql.core.ByteOptimizedUTF8Encoder
UTF-8 encoder which validates input and is optimized for jdk 9+ where
String
objects are backed by
byte[]
.-
Field Summary
FieldsFields inherited from class org.postgresql.core.OptimizedUTF8Encoder
UTF_8_CHARSET
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecode
(byte[] encodedString, int offset, int length) Decode an array of bytes into a string.private String
slowDecode
(byte[] encodedString, int offset, int length, int curIdx) Decodes tochar[]
in presence of non-ascii values after first copying all known ascii chars directly frombyte[]
tochar[]
.Methods inherited from class org.postgresql.core.OptimizedUTF8Encoder
charDecode, decodeToChars, getCharArray
Methods inherited from class org.postgresql.core.Encoding
decode, defaultEncoding, encode, getDatabaseEncoding, getDecodingReader, getEncodingWriter, getJVMEncoding, hasAsciiNumbers, name, toString
-
Field Details
-
ASCII_CHARSET
-
-
Constructor Details
-
ByteOptimizedUTF8Encoder
ByteOptimizedUTF8Encoder()
-
-
Method Details
-
decode
Decode an array of bytes into a string.- Overrides:
decode
in classEncoding
- Parameters:
encodedString
- a byte array containing the string to decodeoffset
- the offset inencodedString
of the first byte of the encoded representationlength
- the length, in bytes, of the encoded representation- Returns:
- the decoded string
- Throws:
IOException
- if something goes wrong
-
slowDecode
private String slowDecode(byte[] encodedString, int offset, int length, int curIdx) throws IOException Decodes tochar[]
in presence of non-ascii values after first copying all known ascii chars directly frombyte[]
tochar[]
.- Throws:
IOException
-