public class Utils extends Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static StringBuilder |
escapeIdentifier(@Nullable StringBuilder sbuf,
String value)
Escape the given identifier
value and append it to the string builder sbuf . |
static StringBuilder |
escapeLiteral(@Nullable StringBuilder sbuf,
String value,
boolean standardConformingStrings)
Escape the given literal
value and append it to the string builder sbuf . |
static int |
parseServerVersionStr(@Nullable String serverVersion)
Deprecated.
use specific
Version instance |
static String |
toHexString(byte[] data)
Turn a bytearray into a printable form, representing each byte in hex.
|
public static String toHexString(byte[] data)
data
- the bytearray to stringizedata
public static StringBuilder escapeLiteral(@Nullable StringBuilder sbuf, String value, boolean standardConformingStrings) throws SQLException
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.sbuf
- the string builder to append to; or null
value
- the string valuestandardConformingStrings
- if standard conforming strings should be usedSQLException
- if the string contains a \0
characterpublic static StringBuilder escapeIdentifier(@Nullable StringBuilder sbuf, String value) throws SQLException
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.sbuf
- the string builder to append to; or null
value
- the string valueSQLException
- if the string contains a \0
character@Deprecated public static int parseServerVersionStr(@Nullable String serverVersion) throws NumberFormatException
Version
instanceAttempt 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.
serverVersion
- server vertion in a XXYYZZ formNumberFormatException
Copyright © 1997-2020 PostgreSQL Global Development Group. All Rights Reserved.