public class StringUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
(package private) static char[] |
EMPTY_SPACE |
private static char[] |
HEX_DIGITS |
private static String |
VALID_ID_CHARS |
private static int |
WILD_COMPARE_CONTINUE_WITH_WILD |
private static int |
WILD_COMPARE_MATCH |
private static int |
WILD_COMPARE_NO_MATCH |
(package private) static char |
WILDCARD_ESCAPE |
(package private) static char |
WILDCARD_MANY |
(package private) static char |
WILDCARD_ONE |
| Constructor and Description |
|---|
StringUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendAsHex(StringBuilder builder,
byte[] bytes) |
static void |
appendAsHex(StringBuilder builder,
int value) |
static boolean |
canHandleAsServerPreparedStatementNoCache(String sql,
ServerVersion serverVersion,
boolean allowMultiQueries,
boolean noBackslashEscapes,
boolean useAnsiQuotes) |
static String |
dumpAsHex(byte[] byteBuffer,
int length)
Returns the given bytes as a hex and ASCII dump (up to length bytes).
|
private static boolean |
endsWith(byte[] dataFrom,
String suffix) |
static boolean |
endsWithIgnoreCase(String searchIn,
String searchFor)
Determines whether or not the string 'searchIn' ends with the string 'searchFor', dis-regarding case starting at 'startAt' Shorthand for a
String.regionMatch(...)
|
static void |
escapeBytes(ByteArrayOutputStream bOut,
byte[] x) |
static String |
escapeQuote(String str,
String quotChar) |
static StringBuilder |
escapeString(StringBuilder buf,
String x,
boolean useAnsiQuotedIdentifiers,
CharsetEncoder charsetEncoder) |
static char |
firstAlphaCharUc(String searchIn,
int startAt) |
static char |
firstNonWsCharUc(String searchIn)
Returns the first non-whitespace char, converted to upper case
|
static char |
firstNonWsCharUc(String searchIn,
int startAt) |
static String |
fixDecimalExponent(String dString)
Adds '+' to decimal numbers that are positive (MySQL doesn't understand
them otherwise
|
static byte[] |
getBytes(char[] value)
Returns the byte[] representation of subset of the given char[] using the default/platform encoding.
|
static byte[] |
getBytes(char[] value,
int offset,
int length) |
static byte[] |
getBytes(char[] value,
int offset,
int length,
String encoding)
Returns the byte[] representation of subset of the given char[] using the given encoding.
|
static byte[] |
getBytes(char[] c,
String encoding)
Returns the byte[] representation of subset of the given char[] using the given encoding.
|
static byte[] |
getBytes(String value) |
static byte[] |
getBytes(String value,
int offset,
int length) |
static byte[] |
getBytes(String value,
int offset,
int length,
String encoding) |
static byte[] |
getBytes(String s,
String encoding)
Returns the byte[] representation of the given string using the given encoding.
|
static byte[] |
getBytesNullTerminated(String value,
String encoding) |
static byte[] |
getBytesWrapped(String s,
char beginWrap,
char endWrap,
String encoding)
Returns the byte[] representation of the given string properly wrapped between the given char delimiters using the given encoding.
|
static String |
getFullyQualifiedName(String db,
String entity,
String quoteId,
boolean isPedantic)
Builds and returns a fully qualified name, quoted if necessary, for the given database entity.
|
static String |
getUniqueSavepointId() |
static boolean |
hasWildcards(String src)
Does the string contain wildcard symbols ('%' or '_').
|
static void |
hexEscapeBlock(byte[] buf,
int size,
BiConsumer<Byte,Byte> bc)
Used to escape binary data with hex
|
static int |
indexOf(byte[] s,
char c) |
static int |
indexOfIgnoreCase(int startingPosition,
String searchIn,
String searchFor)
Finds the position of a substring within a string ignoring case.
|
static int |
indexOfIgnoreCase(int startingPosition,
String searchIn,
String[] searchForSequence,
String openingMarkers,
String closingMarkers,
Set<SearchMode> searchMode)
Finds the position of the first of a consecutive sequence of strings within a string, ignoring case, with the option to skip text delimited by given
markers or within comments.
|
static int |
indexOfIgnoreCase(int startingPosition,
String searchIn,
String searchFor,
String openingMarkers,
String closingMarkers,
Set<SearchMode> searchMode)
Finds the position of a substring within a string, ignoring case, with the option to skip text delimited by given markers or within comments.
|
static int |
indexOfIgnoreCase(int startingPosition,
String searchIn,
String searchFor,
String openingMarkers,
String closingMarkers,
String overridingMarkers,
Set<SearchMode> searchMode)
Finds the position of a substring within a string, ignoring case, with the option to skip text delimited by given markers or within comments.
|
static int |
indexOfIgnoreCase(String searchIn,
String searchFor)
Finds the position of a substring within a string ignoring case.
|
static int |
indexOfNextAlphanumericChar(int startingPosition,
String searchIn,
String openingMarkers,
String closingMarkers,
String overridingMarkers,
Set<SearchMode> searchMode)
Finds the position of the next alphanumeric character within a string, with the option to skip text delimited by given markers or within comments.
|
static int |
indexOfNextNonWsChar(int startingPosition,
String searchIn,
String openingMarkers,
String closingMarkers,
String overridingMarkers,
Set<SearchMode> searchMode)
Finds the position of the next non-whitespace character within a string, with the option to skip text delimited by given markers or within comments.
|
static int |
indexOfNextWsChar(int startingPosition,
String searchIn,
String openingMarkers,
String closingMarkers,
String overridingMarkers,
Set<SearchMode> searchMode)
Finds the position of the next whitespace character within a string, with the option to skip text delimited by given markers or within comments.
|
static int |
indexOfQuoteDoubleAware(String searchIn,
String quoteChar,
int startFrom) |
private static boolean |
isCharAtPosNotEqualIgnoreCase(String searchIn,
int pos,
char firstCharOfSearchForUc,
char firstCharOfSearchForLc) |
protected static boolean |
isCharEqualIgnoreCase(char charToCompare,
char compareToCharUC,
char compareToCharLC) |
static boolean |
isEmptyOrWhitespaceOnly(String str) |
static boolean |
isNullOrEmpty(String str) |
static boolean |
isStrictlyNumeric(CharSequence cs)
Checks is the CharSequence contains digits only.
|
static boolean |
isValidIdChar(char c) |
static String |
joinWithSerialComma(List<?> elements)
Joins all elements of the given list using serial comma (Oxford comma) rules.
|
static int |
lastIndexOf(byte[] s,
char c) |
static boolean |
nullSafeEqual(String str1,
String str2)
Two given strings are considered equal if both are null or if they have the same string value.
|
static String |
padString(String stringVal,
int requiredLength) |
static byte[] |
quoteBytes(byte[] bytes) |
static String |
quoteIdentifier(String identifier,
boolean isPedantic)
Surrounds identifier with "`" and duplicates these symbols inside the identifier.
|
static String |
quoteIdentifier(String identifier,
String quoteChar,
boolean isPedantic)
Surrounds identifier with quoteChar and duplicates these symbols inside the identifier.
|
static boolean |
regionMatchesIgnoreCase(String searchIn,
int startAt,
String searchFor)
Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case and starting at 'startAt'.
|
static int |
safeIntParse(String intAsString) |
static String |
safeTrim(String toTrim) |
static String |
sanitizeProcOrFuncName(String src)
Next two functions are to help DBMD check if the given string is in form of database.name and return it as "database";"name" with comments removed.
|
static List<String> |
split(String stringToSplit,
String delimiter,
boolean trim)
Splits stringToSplit into a list, using the given delimiter
|
static List<String> |
split(String stringToSplit,
String delimiter,
String openingMarkers,
String closingMarkers,
boolean trim)
Splits stringToSplit into a list, using the given delimiter and skipping all between the given markers.
|
static List<String> |
split(String stringToSplit,
String delimiter,
String openingMarkers,
String closingMarkers,
boolean trim,
Set<SearchMode> searchMode)
Splits stringToSplit into a list, using the given delimiter and skipping all between the given markers.
|
static List<String> |
split(String stringToSplit,
String delimiter,
String openingMarkers,
String closingMarkers,
String overridingMarkers,
boolean trim)
Splits stringToSplit into a list, using the given delimiter and skipping all between the given markers.
|
static List<String> |
split(String stringToSplit,
String delimiter,
String openingMarkers,
String closingMarkers,
String overridingMarkers,
boolean trim,
Set<SearchMode> searchMode)
Splits stringToSplit into a list, using the given delimiter and skipping all between the given markers.
|
static List<String> |
splitDBdotName(String source,
String db,
String quoteId,
boolean isNoBslashEscSet)
Splits an entity identifier into its parts (database and entity name) and returns a list containing the two elements.
|
private static boolean |
startsWith(byte[] dataFrom,
String chars) |
static boolean |
startsWithIgnoreCase(String searchIn,
String searchFor)
Determines whether or not the string 'searchIn' starts with the string 'searchFor', dis-regarding case.
|
static boolean |
startsWithIgnoreCaseAndNonAlphaNumeric(String searchIn,
String searchFor)
Determines whether or not the string 'searchIn' starts with the string 'searchFor', disregarding case,leading whitespace and non-alphanumeric characters.
|
static boolean |
startsWithIgnoreCaseAndWs(String searchIn,
String searchFor)
Determines whether or not the string 'searchIn' starts with the string 'searchFor', disregarding case and leading whitespace
|
static int |
startsWithIgnoreCaseAndWs(String searchIn,
String[] searchFor)
Determines whether or not the string 'searchIn' starts with one of the strings in 'searchFor', disregarding case and leading whitespace
|
static boolean |
startsWithIgnoreCaseAndWs(String searchIn,
String searchFor,
int beginPos)
Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case and leading whitespace
|
static String |
stringArrayToString(String[] elems,
String prefix,
String midDelimiter,
String lastDelimiter,
String suffix)
Constructs a String containing all the elements in the String array bounded and joined by the provided concatenation elements.
|
static String |
stripCommentsAndHints(String source,
String openingMarkers,
String closingMarkers,
boolean allowBackslashEscapes)
Removes comments and hints from the given string.
|
static byte[] |
stripEnclosure(byte[] source,
String prefix,
String suffix) |
static char[] |
toAsciiCharArray(byte[] buffer,
int startPos,
int length)
Returns the bytes as an ASCII String.
|
static String |
toAsciiString(byte[] buffer)
Returns the bytes as an ASCII String.
|
static String |
toAsciiString(byte[] buffer,
int startPos,
int length)
Returns the bytes as an ASCII String.
|
static String |
toHexString(byte[] byteBuffer,
int length)
Converts the given byte array into Hex String, stopping at given length.
|
static String |
toString(byte[] value) |
static String |
toString(byte[] value,
Charset charset) |
static String |
toString(byte[] value,
int offset,
int length) |
static String |
toString(byte[] value,
int offset,
int length,
String encoding) |
static String |
toString(byte[] value,
String encoding) |
static byte[] |
unquoteBytes(byte[] bytes) |
static String |
unQuoteIdentifier(String identifier,
String quoteChar)
Trims the identifier, removes quote chars from first and last positions and replaces double occurrences of quote char from entire identifier, i.e.
|
static String |
urlEncode(String stringToEncode)
URL-encode the given string.
|
static boolean |
wildCompareIgnoreCase(String searchIn,
String searchFor)
Compares searchIn against searchForWildcard with wildcards, in a case insensitive manner.
|
private static int |
wildCompareInternal(String searchIn,
String searchFor)
Compares searchIn against searchForWildcard with wildcards (heavily borrowed from strings/ctype-simple.c in the server sources)
This method does a single passage matching for normal characters and WILDCARD_ONE (_), and recursive matching for WILDCARD_MANY (%) which may be repeated
for as many anchor chars are found.
|
private static final int WILD_COMPARE_MATCH
private static final int WILD_COMPARE_CONTINUE_WITH_WILD
private static final int WILD_COMPARE_NO_MATCH
static final char WILDCARD_MANY
static final char WILDCARD_ONE
static final char WILDCARD_ESCAPE
private static final String VALID_ID_CHARS
private static final char[] HEX_DIGITS
static final char[] EMPTY_SPACE
public static String dumpAsHex(byte[] byteBuffer, int length)
byteBuffer - the data to dump as hexlength - the number of bytes to printpublic static String toHexString(byte[] byteBuffer, int length)
byteBuffer - the byte array to convertlength - the number of bytes from the given array to convertprivate static boolean endsWith(byte[] dataFrom,
String suffix)
public static char firstNonWsCharUc(String searchIn)
searchIn - the string to search inpublic static char firstNonWsCharUc(String searchIn, int startAt)
public static char firstAlphaCharUc(String searchIn, int startAt)
public static String fixDecimalExponent(String dString)
dString - The value as a stringpublic static byte[] getBytes(String s, String encoding)
s - source stringencoding - java encodingpublic static byte[] getBytesWrapped(String s, char beginWrap, char endWrap, String encoding)
s - source stringbeginWrap - opening char delimiterendWrap - closing char delimiterencoding - java encodingpublic static int indexOfIgnoreCase(String searchIn, String searchFor)
searchIn - the string to search insearchFor - the array of strings to search forsearchFor is found within searchIn starting from startingPosition.public static int indexOfIgnoreCase(int startingPosition,
String searchIn,
String searchFor)
startingPosition - the position to start the search fromsearchIn - the string to search insearchFor - the array of strings to search forsearchFor is found within searchIn starting from startingPosition.public static int indexOfIgnoreCase(int startingPosition,
String searchIn,
String[] searchForSequence,
String openingMarkers,
String closingMarkers,
Set<SearchMode> searchMode)
Independently of the searchMode provided, when searching for the second and following strings SearchMode.SKIP_WHITE_SPACE will
be added and SearchMode.SKIP_BETWEEN_MARKERS removed.
startingPosition - the position to start the search fromsearchIn - the string to search insearchForSequence - searchForSequenceopeningMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skipsearchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the
behavior of the searchsearchFor is found within searchIn starting from startingPosition.public static int indexOfIgnoreCase(int startingPosition,
String searchIn,
String searchFor,
String openingMarkers,
String closingMarkers,
Set<SearchMode> searchMode)
startingPosition - the position to start the search fromsearchIn - the string to search insearchFor - the string to search foropeningMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skipsearchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the
behavior of the searchsearchFor is found within searchIn starting from startingPosition.public static int indexOfIgnoreCase(int startingPosition,
String searchIn,
String searchFor,
String openingMarkers,
String closingMarkers,
String overridingMarkers,
Set<SearchMode> searchMode)
startingPosition - the position to start the search fromsearchIn - the string to search insearchFor - the string to search foropeningMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skipoverridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and
overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed,
otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the
behavior of the searchsearchFor is found within searchIn starting from startingPosition.public static int indexOfNextAlphanumericChar(int startingPosition,
String searchIn,
String openingMarkers,
String closingMarkers,
String overridingMarkers,
Set<SearchMode> searchMode)
startingPosition - the position to start the search fromsearchIn - the string to search inopeningMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skipoverridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and
overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed,
otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the
behavior of the searchsearchIn starting from startingPosition.public static int indexOfNextNonWsChar(int startingPosition,
String searchIn,
String openingMarkers,
String closingMarkers,
String overridingMarkers,
Set<SearchMode> searchMode)
startingPosition - the position to start the search fromsearchIn - the string to search inopeningMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skipoverridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and
overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed,
otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the
behavior of the searchsearchIn starting from startingPosition.public static int indexOfNextWsChar(int startingPosition,
String searchIn,
String openingMarkers,
String closingMarkers,
String overridingMarkers,
Set<SearchMode> searchMode)
startingPosition - the position to start the search fromsearchIn - the string to search inopeningMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skipoverridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and
overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed,
otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the
behavior of the searchsearchIn starting from startingPosition.private static boolean isCharAtPosNotEqualIgnoreCase(String searchIn, int pos, char firstCharOfSearchForUc, char firstCharOfSearchForLc)
protected static boolean isCharEqualIgnoreCase(char charToCompare,
char compareToCharUC,
char compareToCharLC)
public static List<String> split(String stringToSplit, String delimiter, boolean trim)
stringToSplit - the string to splitdelimiter - the string to split ontrim - should the split strings be whitespace trimmed?IllegalArgumentException - if an error occurspublic static List<String> split(String stringToSplit, String delimiter, String openingMarkers, String closingMarkers, boolean trim)
stringToSplit - the string to splitdelimiter - the string to split onopeningMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skiptrim - should the split strings be whitespace trimmed?IllegalArgumentException - if an error occurspublic static List<String> split(String stringToSplit, String delimiter, String openingMarkers, String closingMarkers, boolean trim, Set<SearchMode> searchMode)
stringToSplit - the string to splitdelimiter - the string to split onopeningMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skiptrim - should the split strings be whitespace trimmed?searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the
behaviour of the searchIllegalArgumentException - if an error occurspublic static List<String> split(String stringToSplit, String delimiter, String openingMarkers, String closingMarkers, String overridingMarkers, boolean trim)
stringToSplit - the string to splitdelimiter - the string to split onopeningMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skipoverridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and
overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed,
otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.trim - should the split strings be whitespace trimmed?IllegalArgumentException - if an error occurspublic static List<String> split(String stringToSplit, String delimiter, String openingMarkers, String closingMarkers, String overridingMarkers, boolean trim, Set<SearchMode> searchMode)
stringToSplit - the string to splitdelimiter - the string to split onopeningMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skipoverridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and
overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed,
otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.trim - should the split strings be whitespace trimmed?searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the
behaviour of the searchIllegalArgumentException - if an error occursprivate static boolean startsWith(byte[] dataFrom,
String chars)
public static boolean regionMatchesIgnoreCase(String searchIn, int startAt, String searchFor)
searchIn - the string to search instartAt - the position to start atsearchFor - the string to search forpublic static boolean startsWithIgnoreCase(String searchIn, String searchFor)
searchIn - the string to search insearchFor - the string to search forpublic static boolean startsWithIgnoreCaseAndNonAlphaNumeric(String searchIn, String searchFor)
searchIn - the string to search insearchFor - the string to search forpublic static boolean startsWithIgnoreCaseAndWs(String searchIn, String searchFor)
searchIn - the string to search insearchFor - the string to search forpublic static boolean startsWithIgnoreCaseAndWs(String searchIn, String searchFor, int beginPos)
searchIn - the string to search insearchFor - the string to search forbeginPos - where to start searchingpublic static int startsWithIgnoreCaseAndWs(String searchIn, String[] searchFor)
searchIn - the string to search insearchFor - the string array to search forpublic static boolean endsWithIgnoreCase(String searchIn, String searchFor)
searchIn - the string to search insearchFor - the string to search forpublic static byte[] stripEnclosure(byte[] source,
String prefix,
String suffix)
source - bytes to stripprefix - prefixsuffix - suffixpublic static String toAsciiString(byte[] buffer)
buffer - the bytes representing the stringpublic static String toAsciiString(byte[] buffer, int startPos, int length)
buffer - the bytes to convertstartPos - the position to start convertinglength - the length of the string to convertpublic static char[] toAsciiCharArray(byte[] buffer,
int startPos,
int length)
buffer - the bytes to convertstartPos - the position to start convertinglength - the length of the string to convertpublic static boolean wildCompareIgnoreCase(String searchIn, String searchFor)
searchIn - the string to search insearchFor - the string to search for, using the 'standard' SQL wildcard chars of '%' and '_'private static int wildCompareInternal(String searchIn, String searchFor)
searchIn - the string to search insearchFor - the string to search for, using the 'standard' SQL wildcard chars of '%' and '_'public static int lastIndexOf(byte[] s,
char c)
public static int indexOf(byte[] s,
char c)
public static boolean isNullOrEmpty(String str)
public static boolean nullSafeEqual(String str1, String str2)
str1 - first string to comparestr2 - fecond string to comparetrue if both strings are null or have the same valuepublic static String stripCommentsAndHints(String source, String openingMarkers, String closingMarkers, boolean allowBackslashEscapes)
source - the query string to clean up.openingMarkers - characters that delimit the beginning of a text block to skipclosingMarkers - characters that delimit the end of a text block to skipallowBackslashEscapes - whether or not backslash escapes are allowedpublic static String sanitizeProcOrFuncName(String src)
src - the source stringpublic static List<String> splitDBdotName(String source, String db, String quoteId, boolean isNoBslashEscSet)
db is used in its place and source corresponds to the full entity name.
If argument source is NULL or wildcard (%), returns an empty list.source - the source stringdb - database, if availablequoteId - quote character as defined on serverisNoBslashEscSet - is our connection in no BackSlashEscape modepublic static String getFullyQualifiedName(String db, String entity, String quoteId, boolean isPedantic)
db - database nameentity - identifierquoteId - quote character as defined on serverisPedantic - are we in pedantic modepublic static boolean isEmptyOrWhitespaceOnly(String str)
public static String quoteIdentifier(String identifier, String quoteChar, boolean isPedantic)
quoteChar - ` or "identifier - in pedantic mode (connection property pedantic=true) identifier is treated as unquoted
(as it is stored in the database) even if it starts and ends with quoteChar;
in non-pedantic mode if identifier starts and ends with quoteChar method treats it as already quoted and doesn't modify.isPedantic - are we in pedantic mode-> null-> `abc`-> `ab``c`-> `ab"c`-> `ab``c` in non-pedantic mode or ```ab````c``` in pedantic mode-> null-> "abc"-> "ab`c"-> "ab""c"-> "ab""c" in non-pedantic mode or """ab""""c""" in pedantic modepublic static String quoteIdentifier(String identifier, boolean isPedantic)
identifier - in pedantic mode (connection property pedantic=true) identifier is treated as unquoted (as it is stored in the database) even if it starts and
ends with "`";
in non-pedantic mode if identifier starts and ends with "`" method treats it as already quoted and doesn't modify.isPedantic - are we in pedantic mode-> null-> `abc`-> `ab``c`-> `ab"c`-> `ab``c` in non-pedantic mode or ```ab````c``` in pedantic modepublic static String unQuoteIdentifier(String identifier, String quoteChar)
identifier - identifierquoteChar - ` or "-> null-> abc-> abc-> ab`c-> "ab`c"-> ab"c-> abc-> `ab"c`-> ab`cpublic static int indexOfQuoteDoubleAware(String searchIn, String quoteChar, int startFrom)
public static String toString(byte[] value, int offset, int length)
public static String toString(byte[] value)
public static byte[] getBytes(char[] value)
value - charspublic static byte[] getBytes(char[] c,
String encoding)
c - charsencoding - java encodingpublic static byte[] getBytes(char[] value,
int offset,
int length)
public static byte[] getBytes(char[] value,
int offset,
int length,
String encoding)
value - charsoffset - offsetlength - lengthencoding - java encodingpublic static byte[] getBytes(String value)
public static byte[] getBytes(String value, int offset, int length)
public static final boolean isValidIdChar(char c)
public static final void hexEscapeBlock(byte[] buf,
int size,
BiConsumer<Byte,Byte> bc)
buf - source bytessize - number of bytes to readbc - consumer for low and high bits of each bytepublic static void appendAsHex(StringBuilder builder, byte[] bytes)
public static void appendAsHex(StringBuilder builder, int value)
public static boolean canHandleAsServerPreparedStatementNoCache(String sql, ServerVersion serverVersion, boolean allowMultiQueries, boolean noBackslashEscapes, boolean useAnsiQuotes)
public static int safeIntParse(String intAsString)
public static boolean isStrictlyNumeric(CharSequence cs)
cs - The CharSequence to check.true if the CharSequence not empty and contains only digits, false otherwise.public static String stringArrayToString(String[] elems, String prefix, String midDelimiter, String lastDelimiter, String suffix)
elems - the String array from where to take the elements.prefix - the prefix of the resulting String.midDelimiter - the delimiter to be used between the N-1 elementslastDelimiter - the delimiter to be used before the last element.suffix - the suffix of the resulting String.public static boolean hasWildcards(String src)
src - stringpublic static String getUniqueSavepointId()
public static String joinWithSerialComma(List<?> elements)
elements - the elements to joinpublic static byte[] unquoteBytes(byte[] bytes)
public static byte[] quoteBytes(byte[] bytes)
public static StringBuilder escapeString(StringBuilder buf, String x, boolean useAnsiQuotedIdentifiers, CharsetEncoder charsetEncoder)
public static void escapeBytes(ByteArrayOutputStream bOut, byte[] x)