Package org.postgresql.util
Class PGbytea
- java.lang.Object
-
- org.postgresql.util.PGbytea
-
public class PGbytea extends java.lang.Object
Converts to and from the postgresql bytea datatype used by the backend.
-
-
Constructor Summary
Constructors Constructor Description PGbytea()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
appendHexString(java.lang.StringBuilder sb, byte[] buf, int offset, int length)
Appends given byte array as hex string.static byte[]
toBytes(byte[] s)
static java.lang.String
toPGLiteral(java.lang.Object value)
Deprecated.prefertoPGLiteral(Object, SqlSerializationContext)
to clarify the behaviour regardingInputStream
objectsstatic java.lang.String
toPGLiteral(java.lang.Object value, SqlSerializationContext context)
Formats input object asbytea
literal like'\xcafebabe'::bytea
.static java.lang.String
toPGString(byte[] buf)
-
-
-
Method Detail
-
toBytes
public static byte[] toBytes(byte[] s) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
toPGString
public static java.lang.String toPGString(byte[] buf)
-
appendHexString
public static void appendHexString(java.lang.StringBuilder sb, byte[] buf, int offset, int length)
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
@Deprecated public static java.lang.String toPGLiteral(java.lang.Object value) throws java.io.IOException
Deprecated.prefertoPGLiteral(Object, SqlSerializationContext)
to clarify the behaviour regardingInputStream
objectsFormats 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:
java.io.IOException
- in case there's underflow in the input value
-
toPGLiteral
public static java.lang.String toPGLiteral(java.lang.Object value, SqlSerializationContext context) throws java.io.IOException
Formats input object asbytea
literal like'\xcafebabe'::bytea
. The following inputs are supported:byte[]
,StreamWrapper
, andByteStreamWriter
.- Parameters:
value
- input value to formatcontext
- specifies configuration for converting the parameters to string- Returns:
- formatted value
- Throws:
java.io.IOException
- in case there's underflow in the input value
-
-