Package org.postgresql.util
Class PGbytea
java.lang.Object
org.postgresql.util.PGbytea
Converts to and from the postgresql bytea datatype used by the backend.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int[]
Lookup table for each of the valid ascii code points (offset by'0'
) to the 4 bit numeric value.private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendHexString
(StringBuilder sb, byte[] buf, int offset, int length) Appends given byte array as hex string.private static int
getHex
(byte b) static byte[]
toBytes
(byte[] s) private static byte[]
toBytesHexEscaped
(byte[] s) private static byte[]
toBytesOctalEscaped
(byte[] s) static String
toPGLiteral
(Object value) Formats input object asbytea
literal like'\xcafebabe'::bytea
.static String
toPGString
(byte[] buf)
-
Field Details
-
MAX_3_BUFF_SIZE
private static final int MAX_3_BUFF_SIZE- See Also:
-
HEX_VALS
private static final int[] HEX_VALSLookup table for each of the valid ascii code points (offset by'0'
) to the 4 bit numeric value.
-
-
Constructor Details
-
PGbytea
public PGbytea()
-
-
Method Details
-
toBytes
- Throws:
SQLException
-
toBytesHexEscaped
private static byte[] toBytesHexEscaped(byte[] s) -
getHex
private static int getHex(byte b) -
toBytesOctalEscaped
private static byte[] toBytesOctalEscaped(byte[] s) -
toPGString
-
appendHexString
Appends given byte array as hex string. See HexEncodingBenchmark for the benchmark.- Parameters:
sb
- output builderbuf
- buffer to appendoffset
- offset within the bufferlength
- the length of sequence to append
-
toPGLiteral
Formats input object asbytea
literal like'\xcafebabe'::bytea
. The following inputs are supported:byte[]
,StreamWrapper
, andByteStreamWriter
.- Parameters:
value
- input value to format- Returns:
- formatted value
- Throws:
IOException
- in case there's underflow in the input value
-