Class 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 
      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)
      Formats input object as bytea literal like '\xcafebabe'::bytea.
      static java.lang.String toPGString​(byte[] buf)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PGbytea

        public PGbytea()
    • 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 builder
        buf - buffer to append
        offset - offset within the buffer
        length - the length of sequence to append
      • toPGLiteral

        public static java.lang.String toPGLiteral​(java.lang.Object value)
                                            throws java.io.IOException
        Formats input object as bytea literal like '\xcafebabe'::bytea. The following inputs are supported: byte[], StreamWrapper, and ByteStreamWriter.
        Parameters:
        value - input value to format
        Returns:
        formatted value
        Throws:
        java.io.IOException - in case there's underflow in the input value