org.postgresql.core
Class Utils

java.lang.Object
  extended by org.postgresql.core.Utils

public class Utils
extends Object

Collection of utilities used by the protocol-level code.


Constructor Summary
Utils()
           
 
Method Summary
static StringBuffer appendEscapedIdentifier(StringBuffer sbuf, String value)
          Escape the given identifier value and append it to the string buffer * sbuf.
static StringBuffer appendEscapedLiteral(StringBuffer sbuf, String value, boolean standardConformingStrings)
          Escape the given literal value and append it to the string buffer sbuf.
static byte[] encodeUTF8(String str)
          Encode a string as UTF-8.
static String toHexString(byte[] data)
          Turn a bytearray into a printable form, representing each byte in hex.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

toHexString

public static String toHexString(byte[] data)
Turn a bytearray into a printable form, representing each byte in hex.

Parameters:
data - the bytearray to stringize
Returns:
a hex-encoded printable representation of data

encodeUTF8

public static byte[] encodeUTF8(String str)
Encode a string as UTF-8.

Parameters:
str - the string to encode
Returns:
the UTF-8 representation of str

appendEscapedLiteral

public static StringBuffer appendEscapedLiteral(StringBuffer sbuf,
                                                String value,
                                                boolean standardConformingStrings)
                                         throws SQLException
Escape the given literal value and append it to the string buffer sbuf. If sbuf is null, a new StringBuffer will be returned. The argument standardConformingStrings defines whether the backend expects standard-conforming string literals or allows backslash escape sequences.

Parameters:
sbuf - the string buffer to append to; or null
value - the string value
standardConformingStrings -
Returns:
the sbuf argument; or a new string buffer for sbuf == null
Throws:
SQLException - if the string contains a \0 character

appendEscapedIdentifier

public static StringBuffer appendEscapedIdentifier(StringBuffer sbuf,
                                                   String value)
                                            throws SQLException
Escape the given identifier value and append it to the string buffer * sbuf. If sbuf is null, a new StringBuffer will be returned. This method is different from appendEscapedLiteral in that it includes the quoting required for the identifier while appendEscapedLiteral does not.

Parameters:
sbuf - the string buffer to append to; or null
value - the string value
Returns:
the sbuf argument; or a new string buffer for sbuf == null
Throws:
SQLException - if the string contains a \0 character


Copyright © 2013. All Rights Reserved.