Top Description Constructors Methods
org.postgresql.core

public Class Utils

extends Object
Class Inheritance
Imports
org.postgresql.util.GT, .PSQLException, .PSQLState, org.checkerframework.checker.nullness.qual.Nullable, java.io.IOException, java.sql.SQLException

Collection of utilities used by the protocol-level code.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
doAppendEscapedIdentifier(Appendable
Either StringBuffer or StringBuilder as we do not expect any IOException to be thrown.
sbuf
,
String
value to append
value
)

Common part for appendEscapedIdentifier.

private static void
doAppendEscapedLiteral(Appendable
Either StringBuffer or StringBuilder as we do not expect any IOException to be thrown
sbuf
,
String
value to append
value
,
boolean
if standard conforming strings should be used
standardConformingStrings
)

Common part for escapeLiteral(StringBuilder, String, boolean).

public static StringBuilder

Returns:

the sbuf argument; or a new string builder for sbuf == null
escapeIdentifier
(@Nullable StringBuilder
the string builder to append to; or null
sbuf
,
String
the string value
value
)

Escape the given identifier value and append it to the string builder sbuf.

public static StringBuilder

Returns:

the sbuf argument; or a new string builder for sbuf == null
escapeLiteral
(@Nullable StringBuilder
the string builder to append to; or null
sbuf
,
String
the string value
value
,
boolean
if standard conforming strings should be used
standardConformingStrings
)

Escape the given literal value and append it to the string builder sbuf.

public static int

Returns:

server version in number form
parseServerVersionStr
(@Nullable String
server version in a XXYYZZ form
serverVersion
)
Deprecated use specific Version instance

Attempt to parse the server version string into an XXYYZZ form version number.

public static String

Returns:

a hex-encoded printable representation of data
toHexString
(byte[]
the bytearray to stringize
data
)

Turn a bytearray into a printable form, representing each byte in hex.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Utilsback to summary
public Utils()

Method Detail

doAppendEscapedIdentifierback to summary
private static void doAppendEscapedIdentifier(Appendable sbuf, String value) throws SQLException

Common part for appendEscapedIdentifier.

Parameters
sbuf:Appendable

Either StringBuffer or StringBuilder as we do not expect any IOException to be thrown.

value:String

value to append

doAppendEscapedLiteralback to summary
private static void doAppendEscapedLiteral(Appendable sbuf, String value, boolean standardConformingStrings) throws SQLException

Common part for escapeLiteral(StringBuilder, String, boolean).

Parameters
sbuf:Appendable

Either StringBuffer or StringBuilder as we do not expect any IOException to be thrown

value:String

value to append

standardConformingStrings:boolean

if standard conforming strings should be used

escapeIdentifierback to summary
public static StringBuilder escapeIdentifier(@Nullable StringBuilder sbuf, String value) throws SQLException

Escape the given identifier value and append it to the string builder sbuf. If sbuf is null, a new StringBuilder will be returned. This method is different from appendEscapedLiteral in that it includes the quoting required for the identifier while escapeLiteral(StringBuilder, String, boolean) does not.

Parameters
sbuf:@Nullable StringBuilder

the string builder to append to; or null

value:String

the string value

Returns:StringBuilder

the sbuf argument; or a new string builder for sbuf == null

Exceptions
SQLException:
if the string contains a \0 character
escapeLiteralback to summary
public static StringBuilder escapeLiteral(@Nullable StringBuilder sbuf, String value, boolean standardConformingStrings) throws SQLException

Escape the given literal value and append it to the string builder sbuf. If sbuf is null, a new StringBuilder will be returned. The argument standardConformingStrings defines whether the backend expects standard-conforming string literals or allows backslash escape sequences.

Parameters
sbuf:@Nullable StringBuilder

the string builder to append to; or null

value:String

the string value

standardConformingStrings:boolean

if standard conforming strings should be used

Returns:StringBuilder

the sbuf argument; or a new string builder for sbuf == null

Exceptions
SQLException:
if the string contains a \0 character
parseServerVersionStrback to summary
public static int parseServerVersionStr(@Nullable String serverVersion) throws NumberFormatException

Deprecated

use specific Version instance

Attempt to parse the server version string into an XXYYZZ form version number.

Returns 0 if the version could not be parsed.

Returns minor version 0 if the minor version could not be determined, e.g. devel or beta releases.

If a single major part like 90400 is passed, it's assumed to be a pre-parsed version and returned verbatim. (Anything equal to or greater than 10000 is presumed to be this form).

The yy or zz version parts may be larger than 99. A NumberFormatException is thrown if a version part is out of range.

Parameters
serverVersion:@Nullable String

server version in a XXYYZZ form

Returns:int

server version in number form

Annotations
@Deprecated
toHexStringback to summary
public static String toHexString(byte[] data)

Turn a bytearray into a printable form, representing each byte in hex.

Parameters
data:byte[]

the bytearray to stringize

Returns:String

a hex-encoded printable representation of data