Package org.postgresql.util
Class PGbytea
- java.lang.Object
-
- org.postgresql.util.PGbytea
-
public class PGbytea extends java.lang.ObjectConverts 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 voidappendHexString(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.StringtoPGLiteral(java.lang.Object value)Deprecated.prefertoPGLiteral(Object, SqlSerializationContext)to clarify the behaviour regardingInputStreamobjectsstatic java.lang.StringtoPGLiteral(java.lang.Object value, SqlSerializationContext context)Formats input object asbytealiteral like'\xcafebabe'::bytea.static java.lang.StringtoPGString(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.IOExceptionDeprecated.prefertoPGLiteral(Object, SqlSerializationContext)to clarify the behaviour regardingInputStreamobjectsFormats input object asbytealiteral 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.IOExceptionFormats input object asbytealiteral 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
-
-