| java.lang.Object com.mysql.jdbc.StringUtils
StringUtils | public class StringUtils (Code) | | Various utility methods for converting to/from byte arrays in the platform
encoding
author: Mark Matthews |
Method Summary | |
public static String | consistentToString(BigDecimal decimal) | final public static String | dumpAsHex(byte[] byteBuffer, int length) Dumps the given bytes to STDOUT as a hex dump (up to length bytes). | public static byte[] | escapeEasternUnicodeByteStream(byte[] origBytes, String origString, int offset, int length) 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 format Parameters: origString - the string that had .getBytes() called on it Parameters: offset - where to start converting from Parameters: length - how many characters to convert. | public static char | firstNonWsCharUc(String searchIn) | public static char | firstNonWsCharUc(String searchIn, int startAt) | final public static String | fixDecimalExponent(String dString) | final public static byte[] | getBytes(char[] c, SingleByteCharsetConverter converter, String encoding, String serverEncoding, boolean parserKnowsUnicode) | final public static byte[] | getBytes(char[] c, SingleByteCharsetConverter converter, String encoding, String serverEncoding, int offset, int length, boolean parserKnowsUnicode) | final public static byte[] | getBytes(char[] c, String encoding, String serverEncoding, boolean parserKnowsUnicode, ConnectionImpl conn) | final public static byte[] | getBytes(String s, SingleByteCharsetConverter converter, String encoding, String serverEncoding, boolean parserKnowsUnicode) Returns the byte[] representation of the given string (re)using the given
charset converter, and the given encoding. | final public static byte[] | getBytes(String s, SingleByteCharsetConverter converter, String encoding, String serverEncoding, int offset, int length, boolean parserKnowsUnicode) | final public static byte[] | getBytes(String s, String encoding, String serverEncoding, boolean parserKnowsUnicode, ConnectionImpl conn) Returns the byte[] representation of the given string using given
encoding. | final public static byte[] | getBytesWrapped(String s, char beginWrap, char endWrap, SingleByteCharsetConverter converter, String encoding, String serverEncoding, boolean parserKnowsUnicode) | public static int | getInt(byte[] buf, int offset, int endPos) | public static int | getInt(byte[] buf) | public static long | getLong(byte[] buf) | public static long | getLong(byte[] buf, int offset, int endpos) | public static short | getShort(byte[] buf) | public static int | indexOf(byte[] s, char c) | final public static int | indexOfIgnoreCase(int startingPosition, String searchIn, String searchFor) | final public static int | indexOfIgnoreCase(String searchIn, String searchFor) | public static int | indexOfIgnoreCaseRespectMarker(int startAt, String src, String target, String marker, String markerCloses, boolean allowBackslashEscapes) | public static int | indexOfIgnoreCaseRespectQuotes(int startAt, String src, String target, char quoteChar, boolean allowBackslashEscapes) | final public static boolean | isEmptyOrWhitespaceOnly(String str) | public static boolean | isNullOrEmpty(String toTest) | public static int | lastIndexOf(byte[] s, char c) | static byte[] | s2b(String s, ConnectionImpl conn) | final public static List | split(String stringToSplit, String delimitter, boolean trim) | final public static List | split(String stringToSplit, String delimiter, String markers, String markerCloses, boolean trim) | public static boolean | startsWithIgnoreCase(String searchIn, int startAt, String searchFor) | public static boolean | startsWithIgnoreCase(String searchIn, String searchFor) Determines whether or not the string 'searchIn' contains the string
'searchFor', dis-regarding case. | public static boolean | startsWithIgnoreCaseAndNonAlphaNumeric(String searchIn, String searchFor) Determines whether or not the sting 'searchIn' contains the string
'searchFor', disregarding case,leading whitespace and non-alphanumeric
characters. | public static boolean | startsWithIgnoreCaseAndWs(String searchIn, String searchFor) | public static boolean | startsWithIgnoreCaseAndWs(String searchIn, String searchFor, int beginPos) | public static String | stripComments(String src, String stringOpens, String stringCloses, boolean slashStarComments, boolean slashSlashComments, boolean hashComments, boolean dashDashComments) | public static byte[] | stripEnclosure(byte[] source, String prefix, String suffix) | final public static String | toAsciiString(byte[] buffer) Returns the bytes as an ASCII String. | final public static String | toAsciiString(byte[] buffer, int startPos, int length) Returns the bytes as an ASCII String. | public static int | wildCompare(String searchIn, String searchForWildcard) |
WILD_COMPARE_MATCH_NO_WILD | final static int WILD_COMPARE_MATCH_NO_WILD(Code) | | |
WILD_COMPARE_MATCH_WITH_WILD | final static int WILD_COMPARE_MATCH_WITH_WILD(Code) | | |
WILD_COMPARE_NO_MATCH | final static int WILD_COMPARE_NO_MATCH(Code) | | |
consistentToString | public static String consistentToString(BigDecimal decimal)(Code) | | 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 a string representation of 'decimal' |
dumpAsHex | final public static String dumpAsHex(byte[] byteBuffer, int length)(Code) | | Dumps the given bytes to STDOUT as a hex dump (up to length bytes).
Parameters: byteBuffer - the data to print as hex Parameters: length - the number of bytes to print ... |
escapeEasternUnicodeByteStream | public static byte[] escapeEasternUnicodeByteStream(byte[] origBytes, String origString, int offset, int length)(Code) | | 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 format Parameters: origString - the string that had .getBytes() called on it Parameters: offset - where to start converting from Parameters: length - how many characters to convert. byte[] with 0x5c escaped |
firstNonWsCharUc | public static char firstNonWsCharUc(String searchIn)(Code) | | Returns the first non whitespace char, converted to upper case
Parameters: searchIn - the string to search in the first non-whitespace character, upper cased. |
firstNonWsCharUc | public static char firstNonWsCharUc(String searchIn, int startAt)(Code) | | |
fixDecimalExponent | final public static String fixDecimalExponent(String dString)(Code) | | Adds '+' to decimal numbers that are positive (MySQL doesn't understand
them otherwise
Parameters: dString - The value as a string String the string with a '+' added (if needed) |
getBytes | final public static byte[] getBytes(String s, SingleByteCharsetConverter converter, String encoding, String serverEncoding, boolean parserKnowsUnicode) throws SQLException(Code) | | Returns the byte[] representation of the given string (re)using the given
charset converter, and the given encoding.
Parameters: s - the string to convert Parameters: converter - the converter to reuse Parameters: encoding - the character encoding to use Parameters: serverEncoding - DOCUMENT ME! Parameters: parserKnowsUnicode - DOCUMENT ME! byte[] representation of the string throws: SQLException - if an encoding unsupported by the JVM is supplied. |
getBytes | final public static byte[] getBytes(String s, SingleByteCharsetConverter converter, String encoding, String serverEncoding, int offset, int length, boolean parserKnowsUnicode) throws SQLException(Code) | | DOCUMENT ME!
Parameters: s - DOCUMENT ME! Parameters: converter - DOCUMENT ME! Parameters: encoding - DOCUMENT ME! Parameters: serverEncoding - DOCUMENT ME! Parameters: offset - DOCUMENT ME! Parameters: length - DOCUMENT ME! Parameters: parserKnowsUnicode - DOCUMENT ME! DOCUMENT ME! throws: SQLException - DOCUMENT ME! |
getBytes | final public static byte[] getBytes(String s, String encoding, String serverEncoding, boolean parserKnowsUnicode, ConnectionImpl conn) throws SQLException(Code) | | Returns the byte[] representation of the given string using given
encoding.
Parameters: s - the string to convert Parameters: encoding - the character encoding to use Parameters: parserKnowsUnicode - DOCUMENT ME! byte[] representation of the string throws: SQLException - if an encoding unsupported by the JVM is supplied. |
indexOf | public static int indexOf(byte[] s, char c)(Code) | | |
indexOfIgnoreCase | final public static int indexOfIgnoreCase(int startingPosition, String searchIn, String searchFor)(Code) | | |
indexOfIgnoreCase | final public static int indexOfIgnoreCase(String searchIn, String searchFor)(Code) | | DOCUMENT ME!
Parameters: searchIn - DOCUMENT ME! Parameters: searchFor - DOCUMENT ME! DOCUMENT ME! |
indexOfIgnoreCaseRespectMarker | public static int indexOfIgnoreCaseRespectMarker(int startAt, String src, String target, String marker, String markerCloses, boolean allowBackslashEscapes)(Code) | | |
indexOfIgnoreCaseRespectQuotes | public static int indexOfIgnoreCaseRespectQuotes(int startAt, String src, String target, char quoteChar, boolean allowBackslashEscapes)(Code) | | |
isEmptyOrWhitespaceOnly | final public static boolean isEmptyOrWhitespaceOnly(String str)(Code) | | |
isNullOrEmpty | public static boolean isNullOrEmpty(String toTest)(Code) | | |
lastIndexOf | public static int lastIndexOf(byte[] s, char c)(Code) | | |
split | final public static List split(String stringToSplit, String delimitter, boolean trim)(Code) | | Splits stringToSplit into a list, using the given delimitter
Parameters: stringToSplit - the string to split Parameters: delimitter - the string to split on Parameters: trim - should the split strings be whitespace trimmed? the list of strings, split by delimitter throws: IllegalArgumentException - DOCUMENT ME! |
split | final public static List split(String stringToSplit, String delimiter, String markers, String markerCloses, boolean trim)(Code) | | Splits stringToSplit into a list, using the given delimitter
Parameters: stringToSplit - the string to split Parameters: delimitter - the string to split on Parameters: trim - should the split strings be whitespace trimmed? the list of strings, split by delimiter throws: IllegalArgumentException - DOCUMENT ME! |
startsWithIgnoreCase | public static boolean startsWithIgnoreCase(String searchIn, int startAt, String searchFor)(Code) | | 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 in Parameters: startAt - the position to start at Parameters: searchFor - the string to search for whether searchIn starts with searchFor, ignoring case |
startsWithIgnoreCase | public static boolean startsWithIgnoreCase(String searchIn, String searchFor)(Code) | | 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 in Parameters: searchFor - the string to search for whether searchIn starts with searchFor, ignoring case |
startsWithIgnoreCaseAndNonAlphaNumeric | public static boolean startsWithIgnoreCaseAndNonAlphaNumeric(String searchIn, String searchFor)(Code) | | Determines whether or not the sting 'searchIn' contains the string
'searchFor', disregarding case,leading whitespace and non-alphanumeric
characters.
Parameters: searchIn - the string to search in Parameters: searchFor - the string to search for true if the string starts with 'searchFor' ignoring whitespace |
startsWithIgnoreCaseAndWs | public static boolean startsWithIgnoreCaseAndWs(String searchIn, String searchFor)(Code) | | Determines whether or not the sting 'searchIn' contains the string
'searchFor', disregarding case and leading whitespace
Parameters: searchIn - the string to search in Parameters: searchFor - the string to search for true if the string starts with 'searchFor' ignoring whitespace |
startsWithIgnoreCaseAndWs | public static boolean startsWithIgnoreCaseAndWs(String searchIn, String searchFor, int beginPos)(Code) | | Determines whether or not the sting 'searchIn' contains the string
'searchFor', disregarding case and leading whitespace
Parameters: searchIn - the string to search in Parameters: searchFor - the string to search for Parameters: beginPos - where to start searching true if the string starts with 'searchFor' ignoring whitespace |
stripComments | public static String stripComments(String src, String stringOpens, String stringCloses, boolean slashStarComments, boolean slashSlashComments, boolean hashComments, boolean dashDashComments)(Code) | | Returns the given string, with comments removed
Parameters: src - the source string Parameters: stringOpens - characters which delimit the "open" of a string Parameters: stringCloses - characters which delimit the "close" of a string, incounterpart order to stringOpens Parameters: slashStarComments - strip slash-star type "C" style comments Parameters: slashSlashComments - strip slash-slash C++ style comments to end-of-line Parameters: hashComments - strip #-style comments to end-of-line Parameters: dashDashComments - strip "--" style comments to end-of-line the input string with all comment-delimited data removed |
stripEnclosure | public static byte[] stripEnclosure(byte[] source, String prefix, String suffix)(Code) | | Parameters: bytesToStrip - Parameters: prefix - Parameters: suffix - |
toAsciiString | final public static String toAsciiString(byte[] buffer)(Code) | | Returns the bytes as an ASCII String.
Parameters: buffer - the bytes representing the string The ASCII String. |
toAsciiString | final public static String toAsciiString(byte[] buffer, int startPos, int length)(Code) | | Returns the bytes as an ASCII String.
Parameters: buffer - the bytes to convert Parameters: startPos - the position to start converting Parameters: length - the length of the string to convert the ASCII string |
wildCompare | public static int wildCompare(String searchIn, String searchForWildcard)(Code) | | Compares searchIn against searchForWildcard with wildcards (heavily
borrowed from strings/ctype-simple.c in the server sources)
Parameters: searchIn - the string to search in Parameters: searchForWildcard - the string to search for, using the 'standard' SQL wildcardchars of '%' and '_' WILD_COMPARE_MATCH_NO_WILD if matched, WILD_COMPARE_NO_MATCH ifnot matched with wildcard, WILD_COMPARE_MATCH_WITH_WILD ifmatched with wildcard |
|
|