Class StringUtils
java.lang.Object
com.mysql.jdbc.StringUtils
Various utility methods for converting to/from byte arrays in the platform encoding
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Set<StringUtils.SearchMode> Full search mode: allow backslash escape, skip between markers, skip block comments, skip line comments and skip white space.static final Set<StringUtils.SearchMode> Search mode: allow backslash escape, skip block comments, skip line comments and skip white space.static final Set<StringUtils.SearchMode> Search mode: allow backslash escape, skip between markers and skip white space.static final Set<StringUtils.SearchMode> Search mode: skip block comments, skip line comments and skip white space.static final Set<StringUtils.SearchMode> Search mode: skip between markers, skip block comments, skip line comments and skip white space.static final Set<StringUtils.SearchMode> Search mode: skip between markers and skip white space.static final Set<StringUtils.SearchMode> Empty search mode.(package private) static final char(package private) static final char(package private) static final char -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendAsHex(StringBuilder builder, byte[] bytes) static voidappendAsHex(StringBuilder builder, int value) static StringconsistentToString(BigDecimal decimal) Takes care of the fact that Sun changed the output of BigDecimal.toString() between JDK-1.4 and JDK 5static StringdumpAsHex(byte[] byteBuffer, int length) Dumps the given bytes to STDOUT as a hex dump (up to length bytes).static byte[]escapeEasternUnicodeByteStream(byte[] origBytes, String origString) Unfortunately, SJIS has 0x5c as a high byte in some of its double-byte characters, so we need to escape it.static StringescapeQuote(String src, String quotChar) (package private) static CharsetfindCharset(String alias) static charfirstAlphaCharUc(String searchIn, int startAt) static charfirstNonWsCharUc(String searchIn) Returns the first non whitespace char, converted to upper casestatic charfirstNonWsCharUc(String searchIn, int startAt) static StringfixDecimalExponent(String dString) Adds '+' to decimal numbers that are positive (MySQL doesn't understand them otherwisestatic byte[]getBytes(char[] value) static byte[]getBytes(char[] value, int offset, int length) static byte[]static byte[]getBytes(char[] c, SingleByteCharsetConverter converter, String encoding, String serverEncoding, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) Returns the byte[] representation of the given char[] (re)using the given charset converter, and the given encoding.static byte[]getBytes(char[] c, SingleByteCharsetConverter converter, String encoding, String serverEncoding, int offset, int length, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) Returns the byte[] representation of subset of the given char[] (re)using the given charset converter, and the given encoding.static byte[]static byte[]getBytes(char[] c, String encoding, String serverEncoding, boolean parserKnowsUnicode, MySQLConnection conn, ExceptionInterceptor exceptionInterceptor) Returns the byte[] representation of the given char[] (re)using a cached charset converter, and the given encoding.static byte[]static byte[]static byte[]static byte[]getBytes(String s, SingleByteCharsetConverter converter, String encoding, String serverEncoding, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) Returns the byte[] representation of the given string (re)using the given charset converter, and the given encoding.static byte[]getBytes(String s, SingleByteCharsetConverter converter, String encoding, String serverEncoding, int offset, int length, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) Returns the byte[] representation of a substring of the given string (re)using the given charset converter, and the given encoding.static byte[]static byte[]getBytes(String s, String encoding, String serverEncoding, boolean parserKnowsUnicode, MySQLConnection conn, ExceptionInterceptor exceptionInterceptor) Returns the byte[] representation of the given string (re)using a cached charset converter, and the given encoding.static final byte[]getBytes(String s, String encoding, String serverEncoding, int offset, int length, boolean parserKnowsUnicode, MySQLConnection conn, ExceptionInterceptor exceptionInterceptor) Returns the byte[] representation of a substring of the given string (re)using a cached charset converter, and the given encoding.static byte[]getBytesNullTerminated(String value, String encoding) static byte[]getBytesWrapped(String s, char beginWrap, char endWrap, SingleByteCharsetConverter converter, String encoding, String serverEncoding, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) Returns the byte[] representation of the given string properly wrapped between the given char delimiters, (re)using the given charset converter, and the given encoding.static intgetInt(byte[] buf) static intgetInt(byte[] buf, int offset, int endPos) static longgetLong(byte[] buf) static longgetLong(byte[] buf, int offset, int endpos) static shortgetShort(byte[] buf) static shortgetShort(byte[] buf, int offset, int endpos) static intindexOf(byte[] s, char c) static intindexOfIgnoreCase(int startingPosition, String searchIn, String searchFor) Finds the position of a substring within a string ignoring case.static intindexOfIgnoreCase(int startingPosition, String searchIn, String[] searchForSequence, String openingMarkers, String closingMarkers, Set<StringUtils.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 intindexOfIgnoreCase(int startingPosition, String searchIn, String searchFor, String openingMarkers, String closingMarkers, String overridingMarkers, Set<StringUtils.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 intindexOfIgnoreCase(int startingPosition, String searchIn, String searchFor, String openingMarkers, String closingMarkers, Set<StringUtils.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 intindexOfIgnoreCase(String searchIn, String searchFor) Finds the position of a substring within a string ignoring case.static intindexOfQuoteDoubleAware(String searchIn, String quoteChar, int startFrom) static booleanstatic booleanisNullOrEmpty(String toTest) static booleanChecks is the CharSequence contains digits only.static final booleanisValidIdChar(char c) static intlastIndexOf(byte[] s, char c) static StringquoteIdentifier(String identifier, boolean isPedantic) Surrounds identifier with "`" and duplicates these symbols inside the identifier.static StringquoteIdentifier(String identifier, String quoteChar, boolean isPedantic) Surrounds identifier with quoteChar and duplicates these symbols inside the identifier.(package private) static byte[]s2b(String s, MySQLConnection conn) static StringNext 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.Splits stringToSplit into a list, using the given delimitersplit(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.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.splitDBdotName(String source, String catalog, String quoteId, boolean isNoBslashEscSet) Splits an entity identifier into its parts (database and entity name) and returns a list containing the two elements.static booleanstartsWithIgnoreCase(String searchIn, int startAt, String searchFor) Determines whether or not the string 'searchIn' contains the string 'searchFor', dis-regarding case starting at 'startAt' Shorthand for a String.regionMatch(...)static booleanstartsWithIgnoreCase(String searchIn, String searchFor) Determines whether or not the string 'searchIn' contains the string 'searchFor', dis-regarding case.static booleanstartsWithIgnoreCaseAndNonAlphaNumeric(String searchIn, String searchFor) Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case,leading whitespace and non-alphanumeric characters.static booleanstartsWithIgnoreCaseAndWs(String searchIn, String searchFor) Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case and leading whitespacestatic intstartsWithIgnoreCaseAndWs(String searchIn, String[] searchFor) Determines whether or not the string 'searchIn' starts with one of the strings in 'searchFor', disregarding case and leading whitespacestatic booleanstartsWithIgnoreCaseAndWs(String searchIn, String searchFor, int beginPos) Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case and leading whitespacestatic StringstripComments(String src, String stringOpens, String stringCloses, boolean slashStarComments, boolean slashSlashComments, boolean hashComments, boolean dashDashComments) Returns the given string, with comments removedstatic byte[]stripEnclosure(byte[] source, String prefix, String suffix) static StringtoAsciiString(byte[] buffer) Returns the bytes as an ASCII String.static StringtoAsciiString(byte[] buffer, int startPos, int length) Returns the bytes as an ASCII String.static StringtoString(byte[] value) static StringtoString(byte[] value, int offset, int length) static Stringstatic Stringstatic StringunQuoteIdentifier(String identifier, String quoteChar) Trims identifier, removes quote chars from first and last positions and replaces double occurrences of quote char from entire identifier, i.e converts quoted identifier into form as it is stored in database.static booleanwildCompareIgnoreCase(String searchIn, String searchFor) Compares searchIn against searchForWildcard with wildcards, in a case insensitive manner.
-
Field Details
-
SEARCH_MODE__ALL
Full search mode: allow backslash escape, skip between markers, skip block comments, skip line comments and skip white space. -
SEARCH_MODE__MRK_COM_WS
Search mode: skip between markers, skip block comments, skip line comments and skip white space. -
SEARCH_MODE__BSESC_COM_WS
Search mode: allow backslash escape, skip block comments, skip line comments and skip white space. -
SEARCH_MODE__BSESC_MRK_WS
Search mode: allow backslash escape, skip between markers and skip white space. -
SEARCH_MODE__COM_WS
Search mode: skip block comments, skip line comments and skip white space. -
SEARCH_MODE__MRK_WS
Search mode: skip between markers and skip white space. -
SEARCH_MODE__NONE
Empty search mode. -
WILDCARD_MANY
static final char WILDCARD_MANY- See Also:
-
WILDCARD_ONE
static final char WILDCARD_ONE- See Also:
-
WILDCARD_ESCAPE
static final char WILDCARD_ESCAPE- See Also:
-
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
findCharset
- Throws:
UnsupportedEncodingException
-
consistentToString
Takes care of the fact that Sun changed the output of BigDecimal.toString() between JDK-1.4 and JDK 5- Parameters:
decimal- the big decimal to stringify- Returns:
- a string representation of 'decimal'
-
dumpAsHex
Dumps the given bytes to STDOUT as a hex dump (up to length bytes).- Parameters:
byteBuffer- the data to print as hexlength- the number of bytes to print- Returns:
- ...
-
escapeEasternUnicodeByteStream
Unfortunately, SJIS has 0x5c as a high byte in some of its double-byte characters, so we need to escape it.- Parameters:
origBytes- the original bytes in SJIS formatorigString- the string that had .getBytes() called on it- Returns:
- byte[] with 0x5c escaped
-
firstNonWsCharUc
Returns the first non whitespace char, converted to upper case- Parameters:
searchIn- the string to search in- Returns:
- the first non-whitespace character, upper cased.
-
firstNonWsCharUc
-
firstAlphaCharUc
-
fixDecimalExponent
-
getBytes
public static byte[] getBytes(char[] c, SingleByteCharsetConverter converter, String encoding, String serverEncoding, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) throws SQLException Returns the byte[] representation of the given char[] (re)using the given charset converter, and the given encoding.- Throws:
SQLException
-
getBytes
public static byte[] getBytes(char[] c, SingleByteCharsetConverter converter, String encoding, String serverEncoding, int offset, int length, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) throws SQLException Returns the byte[] representation of subset of the given char[] (re)using the given charset converter, and the given encoding.- Throws:
SQLException
-
getBytes
public static byte[] getBytes(char[] c, String encoding, String serverEncoding, boolean parserKnowsUnicode, MySQLConnection conn, ExceptionInterceptor exceptionInterceptor) throws SQLException Returns the byte[] representation of the given char[] (re)using a cached charset converter, and the given encoding.- Throws:
SQLException
-
getBytes
public static byte[] getBytes(String s, SingleByteCharsetConverter converter, String encoding, String serverEncoding, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) throws SQLException Returns the byte[] representation of the given string (re)using the given charset converter, and the given encoding.- Throws:
SQLException
-
getBytes
public static byte[] getBytes(String s, SingleByteCharsetConverter converter, String encoding, String serverEncoding, int offset, int length, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) throws SQLException Returns the byte[] representation of a substring of the given string (re)using the given charset converter, and the given encoding.- Throws:
SQLException
-
getBytes
public static byte[] getBytes(String s, String encoding, String serverEncoding, boolean parserKnowsUnicode, MySQLConnection conn, ExceptionInterceptor exceptionInterceptor) throws SQLException Returns the byte[] representation of the given string (re)using a cached charset converter, and the given encoding.- Throws:
SQLException
-
getBytes
public static final byte[] getBytes(String s, String encoding, String serverEncoding, int offset, int length, boolean parserKnowsUnicode, MySQLConnection conn, ExceptionInterceptor exceptionInterceptor) throws SQLException Returns the byte[] representation of a substring of the given string (re)using a cached charset converter, and the given encoding.- Throws:
SQLException
-
getBytesWrapped
public static byte[] getBytesWrapped(String s, char beginWrap, char endWrap, SingleByteCharsetConverter converter, String encoding, String serverEncoding, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) throws SQLException Returns the byte[] representation of the given string properly wrapped between the given char delimiters, (re)using the given charset converter, and the given encoding.- Throws:
SQLException
-
getInt
- Throws:
NumberFormatException
-
getInt
- Throws:
NumberFormatException
-
getLong
- Throws:
NumberFormatException
-
getLong
- Throws:
NumberFormatException
-
getShort
- Throws:
NumberFormatException
-
getShort
- Throws:
NumberFormatException
-
indexOfIgnoreCase
Finds the position of a substring within a string ignoring case.- Parameters:
searchIn- the string to search insearchFor- the array of strings to search for- Returns:
- the position where
searchForis found withinsearchInstarting fromstartingPosition.
-
indexOfIgnoreCase
Finds the position of a substring within a string ignoring case.- Parameters:
startingPosition- the position to start the search fromsearchIn- the string to search insearchFor- the array of strings to search for- Returns:
- the position where
searchForis found withinsearchInstarting fromstartingPosition.
-
indexOfIgnoreCase
public static int indexOfIgnoreCase(int startingPosition, String searchIn, String[] searchForSequence, String openingMarkers, String closingMarkers, Set<StringUtils.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.Independently of the
searchModeprovided, when searching for the second and following stringsSearchMode.SKIP_WHITE_SPACEwill be added andSearchMode.SKIP_BETWEEN_MARKERSremoved.- Parameters:
startingPosition- the position to start the search fromsearchIn- the string to search inopeningMarkers- characters which delimit the beginning of a text block to skipclosingMarkers- characters which delimit the end of a text block to skipsearchMode- aSet, ideally anEnumSet, containing the flags from the enumStringUtils.SearchModethat determine the behavior of the searchsearchFor- the array of strings to search for- Returns:
- the position where
searchForis found withinsearchInstarting fromstartingPosition.
-
indexOfIgnoreCase
public static int indexOfIgnoreCase(int startingPosition, String searchIn, String searchFor, String openingMarkers, String closingMarkers, Set<StringUtils.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.- Parameters:
startingPosition- the position to start the search fromsearchIn- the string to search insearchFor- the string to search foropeningMarkers- characters which delimit the beginning of a text block to skipclosingMarkers- characters which delimit the end of a text block to skipsearchMode- aSet, ideally anEnumSet, containing the flags from the enumStringUtils.SearchModethat determine the behavior of the search- Returns:
- the position where
searchForis found withinsearchInstarting fromstartingPosition.
-
indexOfIgnoreCase
public static int indexOfIgnoreCase(int startingPosition, String searchIn, String searchFor, String openingMarkers, String closingMarkers, String overridingMarkers, Set<StringUtils.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.- Parameters:
startingPosition- the position to start the search fromsearchIn- the string to search insearchFor- the string to search foropeningMarkers- characters which delimit the beginning of a text block to skipclosingMarkers- characters which delimit the end of a text block to skipoverridingMarkers- the subset ofopeningMarkersthat override the remaining markers, e.g., ifopeningMarkers = "'("andoverridingMarkers = "'"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- aSet, ideally anEnumSet, containing the flags from the enumStringUtils.SearchModethat determine the behavior of the search- Returns:
- the position where
searchForis found withinsearchInstarting fromstartingPosition.
-
split
Splits stringToSplit into a list, using the given delimiter- Parameters:
stringToSplit- the string to splitdelimiter- the string to split ontrim- should the split strings be whitespace trimmed?- Returns:
- the list of strings, split by delimiter
- Throws:
IllegalArgumentException
-
split
public 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.- Parameters:
stringToSplit- the string to splitdelimiter- the string to split onopeningMarkers- characters which delimit the beginning of a text block to skipclosingMarkers- characters which delimit the end of a text block to skiptrim- should the split strings be whitespace trimmed?- Returns:
- the list of strings, split by delimiter
- Throws:
IllegalArgumentException
-
split
public 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.- Parameters:
stringToSplit- the string to splitdelimiter- the string to split onopeningMarkers- characters which delimit the beginning of a text block to skipclosingMarkers- characters which delimit the end of a text block to skipoverridingMarkers- the subset ofopeningMarkersthat override the remaining markers, e.g., ifopeningMarkers = "'("andoverridingMarkers = "'"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?- Returns:
- the list of strings, split by delimiter
- Throws:
IllegalArgumentException
-
startsWithIgnoreCase
Determines whether or not the string 'searchIn' contains the string 'searchFor', dis-regarding case starting at 'startAt' Shorthand for a String.regionMatch(...)- Parameters:
searchIn- the string to search instartAt- the position to start atsearchFor- the string to search for- Returns:
- whether searchIn starts with searchFor, ignoring case
-
startsWithIgnoreCase
Determines whether or not the string 'searchIn' contains the string 'searchFor', dis-regarding case. Shorthand for a String.regionMatch(...)- Parameters:
searchIn- the string to search insearchFor- the string to search for- Returns:
- whether searchIn starts with searchFor, ignoring case
-
startsWithIgnoreCaseAndNonAlphaNumeric
Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case,leading whitespace and non-alphanumeric characters.- Parameters:
searchIn- the string to search insearchFor- the string to search for- Returns:
- true if the string starts with 'searchFor' ignoring whitespace
-
startsWithIgnoreCaseAndWs
Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case and leading whitespace- Parameters:
searchIn- the string to search insearchFor- the string to search for- Returns:
- true if the string starts with 'searchFor' ignoring whitespace
-
startsWithIgnoreCaseAndWs
Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case and leading whitespace- Parameters:
searchIn- the string to search insearchFor- the string to search forbeginPos- where to start searching- Returns:
- true if the string starts with 'searchFor' ignoring whitespace
-
startsWithIgnoreCaseAndWs
Determines whether or not the string 'searchIn' starts with one of the strings in 'searchFor', disregarding case and leading whitespace- Parameters:
searchIn- the string to search insearchFor- the string array to search for- Returns:
- the 'searchFor' array index that matched or -1 if none matches
-
stripEnclosure
-
toAsciiString
Returns the bytes as an ASCII String.- Parameters:
buffer- the bytes representing the string- Returns:
- The ASCII String.
-
toAsciiString
Returns the bytes as an ASCII String.- Parameters:
buffer- the bytes to convertstartPos- the position to start convertinglength- the length of the string to convert- Returns:
- the ASCII string
-
wildCompareIgnoreCase
Compares searchIn against searchForWildcard with wildcards, in a case insensitive manner.- Parameters:
searchIn- the string to search insearchFor- the string to search for, using the 'standard' SQL wildcard chars of '%' and '_'
-
s2b
- Throws:
SQLException
-
lastIndexOf
public static int lastIndexOf(byte[] s, char c) -
indexOf
public static int indexOf(byte[] s, char c) -
isNullOrEmpty
-
stripComments
public static String stripComments(String src, String stringOpens, String stringCloses, boolean slashStarComments, boolean slashSlashComments, boolean hashComments, boolean dashDashComments) Returns the given string, with comments removed- Parameters:
src- the source stringstringOpens- characters which delimit the "open" of a stringstringCloses- characters which delimit the "close" of a string, in counterpart order tostringOpensslashStarComments- strip slash-star type "C" style commentsslashSlashComments- strip slash-slash C++ style comments to end-of-linehashComments- strip #-style comments to end-of-linedashDashComments- strip "--" style comments to end-of-line- Returns:
- the input string with all comment-delimited data removed
-
sanitizeProcOrFuncName
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. If string is NULL or wildcard (%), returns null and exits. First, we sanitize...- Parameters:
src- the source string- Returns:
- the input string with all comment-delimited data removed
-
splitDBdotName
public static List<String> splitDBdotName(String source, String catalog, String quoteId, boolean isNoBslashEscSet) Splits an entity identifier into its parts (database and entity name) and returns a list containing the two elements. If the identifier doesn't contain the database part then the argumentcatalogis used in its place andsourcecorresponds to the full entity name. If argumentsourceis NULL or wildcard (%), returns an empty list.- Parameters:
source- the source stringcatalog- Catalog, if availablequoteId- quote character as defined on serverisNoBslashEscSet- is our connection in no BackSlashEscape mode- Returns:
- the input string with all comment-delimited data removed
-
isEmptyOrWhitespaceOnly
-
escapeQuote
-
quoteIdentifier
Surrounds identifier with quoteChar and duplicates these symbols inside the identifier.- Parameters:
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.quoteChar- ` or "isPedantic- are we in pedantic mode- Returns:
- With quoteChar="`":
- null -> null
- abc -> `abc`
- ab`c -> `ab``c`
- ab"c -> `ab"c`
- `ab``c` -> `ab``c` in non-pedantic mode or ```ab````c``` in pedantic mode
- null -> null
- abc -> "abc"
- ab`c -> "ab`c"
- ab"c -> "ab""c"
- "ab""c" -> "ab""c" in non-pedantic mode or """ab""""c""" in pedantic mode
-
quoteIdentifier
Surrounds identifier with "`" and duplicates these symbols inside the identifier.- Parameters:
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- Returns:
- null -> null
- abc -> `abc`
- ab`c -> `ab``c`
- ab"c -> `ab"c`
- `ab``c` -> `ab``c` in non-pedantic mode or ```ab````c``` in pedantic mode
-
unQuoteIdentifier
Trims identifier, removes quote chars from first and last positions and replaces double occurrences of quote char from entire identifier, i.e converts quoted identifier into form as it is stored in database.- Parameters:
identifier-quoteChar- ` or "- Returns:
- null -> null
- abc -> abc
- `abc` -> abc
- `ab``c` -> ab`c
- `"ab`c"` -> "ab`c"
- `ab"c` -> ab"c
- "abc" -> abc
- "`ab""c`" -> `ab"c`
- "ab`c" -> ab`c
-
indexOfQuoteDoubleAware
-
toString
public static String toString(byte[] value, int offset, int length, String encoding) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
toString
- Throws:
UnsupportedEncodingException
-
toString
-
toString
-
getBytes
public static byte[] getBytes(char[] value) -
getBytes
public static byte[] getBytes(char[] value, int offset, int length) -
getBytes
- Throws:
UnsupportedEncodingException
-
getBytes
public static byte[] getBytes(char[] value, int offset, int length, String encoding) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
getBytes
-
getBytes
-
getBytes
- Throws:
UnsupportedEncodingException
-
getBytes
public static byte[] getBytes(String value, int offset, int length, String encoding) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
isValidIdChar
public static final boolean isValidIdChar(char c) -
appendAsHex
-
appendAsHex
-
getBytesNullTerminated
public static byte[] getBytesNullTerminated(String value, String encoding) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
isStrictlyNumeric
Checks is the CharSequence contains digits only. No leading sign and thousands or decimal separators are allowed.- Parameters:
cs- The CharSequence to check.- Returns:
trueif the CharSequence not empty and contains only digits,falseotherwise.
-