public class Utils
extends java.lang.Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.StringBuilder |
escapeIdentifier(java.lang.StringBuilder sbuf,
java.lang.String value)
Escape the given identifier
value and append it to the string builder sbuf . |
static java.lang.StringBuilder |
escapeLiteral(java.lang.StringBuilder sbuf,
java.lang.String value,
boolean standardConformingStrings)
Escape the given literal
value and append it to the string builder sbuf . |
static int |
parseServerVersionStr(java.lang.String serverVersion)
Deprecated.
use specific
Version instance |
static java.lang.String |
toHexString(byte[] data)
Turn a bytearray into a printable form, representing each byte in hex.
|
public static java.lang.String toHexString(byte[] data)
data
- the bytearray to stringizedata
public static java.lang.StringBuilder escapeLiteral(java.lang.StringBuilder sbuf, java.lang.String value, boolean standardConformingStrings) throws java.sql.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 usedjava.sql.SQLException
- if the string contains a \0
characterpublic static java.lang.StringBuilder escapeIdentifier(java.lang.StringBuilder sbuf, java.lang.String value) throws java.sql.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 valuejava.sql.SQLException
- if the string contains a \0
character@Deprecated public static int parseServerVersionStr(java.lang.String serverVersion) throws java.lang.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 version in a XXYYZZ formjava.lang.NumberFormatException
Copyright © 2024 PostgreSQL Global Development Group. All rights reserved.