| java.lang.Object workbench.util.StringUtil
StringUtil | public class StringUtil (Code) | | author: support@sql-workbench.net |
Method Summary | |
final public static boolean | arraysEqual(String[] one, String[] other) | final public static String | capitalize(String word) Capitalize the first word of the passed String. | public static int | compareStrings(String value1, String value2, boolean ignoreCase) | public static String | decodeUnicode(String theString) | public static void | dump(String value) | final public static StringBuilder | emptyBuffer() | public static boolean | endsWith(CharSequence s, String end) | public static boolean | endsWith(CharSequence s, char c) | final public static boolean | equalString(String one, String other) | final public static boolean | equalStringIgnoreCase(String one, String other) | final public static boolean | equalStringOrEmpty(String one, String other) Checks if both Strings are equal considering null values. | public static String | escapeUnicode(String value, CharacterRange range) | public static String | escapeUnicode(String value, String specialSaveChars, CharacterRange range) | public static String | escapeUnicode(String value, String specialSaveChars, CharacterRange range, boolean alwaysUnicode) | public static int | findFirstWhiteSpace(CharSequence data) Find the first non-quoted whitespace in the given String. | public static int | findPattern(String regex, String data, int startAt) | public static int | findPattern(Pattern p, String data, int startAt) | public static int | findPreviousWhitespace(String data, int pos) | public static int | findWordBoundary(String data, int pos, String wordBoundaries) | public static String | formatNumber(int value, int length, boolean fillRight) | final public static String | getCurrentTimestampWithTZString() | public static double | getDoubleValue(String aValue, double aDefault) | public static int | getIntValue(String aValue) | public static int | getIntValue(String aValue, int aDefault) | public static long | getLongValue(String aValue, long aDefault) | final public static String | getMaxSubstring(String s, int maxLen, String add) | final public static String | getMaxSubstring(String s, int maxLen) | public static CharSequence | getOctalString(int input) | public static String | getPathSeparator() | public static int | getRealLineLength(String line) | final public static String | getStartingWhiteSpace(String aLine) | final public static String | getWordLeftOfCursor(String text, int pos, String wordBoundaries) | final public static boolean | hasOpenQuotes(String data, char quoteChar) | public static int | hashCode(CharSequence val) | public static int | indexOf(CharSequence value, char c) | public static int | indexOf(CharSequence value, char c, int occurance) | final public static boolean | isEmptyString(CharSequence value) Checks if the given String is null or has a zero length. | public static boolean | isInteger(String value) | public static boolean | isLowerCase(String s) | public static boolean | isMixedCase(String s) | public static boolean | isNumber(String value) | public static boolean | isUpperCase(String s) | public static boolean | isWhitespace(CharSequence s) | final public static boolean | isWhitespaceOrEmpty(CharSequence value) | final public static int | lastIndexOf(CharSequence s, char c) Replacement for StringBuilder.lastIndexOf() which does
a lot of object creation and copying to achieve this. | public static boolean | lineStartsWith(CharSequence text, int lineStartPos, String compareTo) | final public static String | listToString(Collection aList, char aDelimiter) | final public static String | listToString(Collection aList, char aDelimiter, boolean quoteEntries) | final public static String | makeFilename(String input) Remove all characters that might not be allowed in a filename from the input string. | public static String | makePlainLinefeed(String input) Replace various combinations of linefeeds in the input string with \n. | public static int | numDigits(int x) | public static String | padRight(String input, int length) | public static String | quoteRegexMeta(String str) Quote the characters in a String that have a special meaning
in regular expression. | final public static String | replace(String haystack, String needle, String replacement) | final public static StringBuilder | replaceToBuffer(StringBuilder target, String haystack, String needle, String replacement) Replaces all occurances of needle in haystack with replacement and appends the resulting
String to the passed target.
Parameters: target - the buffer to append the result to. | public static String | rtrim(String s) | public static boolean | stringToBool(String aString) | final public static List<String> | stringToList(String aString) | final public static List<String> | stringToList(String aString, String aDelimiter) | final public static List<String> | stringToList(String aString, String aDelimiter, boolean removeEmpty) | final public static List<String> | stringToList(String aString, String aDelimiter, boolean removeEmpty, boolean trimEntries) | final public static List<String> | stringToList(String aString, String aDelimiter, boolean removeEmpty, boolean trimEntries, boolean checkBrackets) | final public static String[] | toArray(Collection<String> strings) | final public static String | trimQuotes(String input) | public static void | trimTrailingWhitespace(StringBuilder value) |
ISO_DATE_FORMAT | final public static String ISO_DATE_FORMAT(Code) | | |
ISO_TIMESTAMP_FORMAT | final public static String ISO_TIMESTAMP_FORMAT(Code) | | |
ISO_TZ_TIMESTAMP_FORMAT | final public static String ISO_TZ_TIMESTAMP_FORMAT(Code) | | |
LINE_TERMINATOR | final public static String LINE_TERMINATOR(Code) | | |
REGEX_SPECIAL_CHARS | final public static String REGEX_SPECIAL_CHARS(Code) | | |
capitalize | final public static String capitalize(String word)(Code) | | Capitalize the first word of the passed String.
(write the first character in uppercase, the rest in lower case)
This does not loop through the entire string to capitalize every word.
|
compareStrings | public static int compareStrings(String value1, String value2, boolean ignoreCase)(Code) | | Parameters: value1 - the first String, maybe null Parameters: value2 - the second String, maybe null 0 if both are null |
equalStringIgnoreCase | final public static boolean equalStringIgnoreCase(String one, String other)(Code) | | |
equalStringOrEmpty | final public static boolean equalStringOrEmpty(String one, String other)(Code) | | Checks if both Strings are equal considering null values.
A null String and an empty String (length==0 or all whitespace) are
considered equal as well (because both are "empty")
See Also: StringUtil.isWhitespaceOrEmpty(CharSequence) |
findFirstWhiteSpace | public static int findFirstWhiteSpace(CharSequence data)(Code) | | Find the first non-quoted whitespace in the given String.
Parameters: data - the data in which to search the position of the first whitespace or -1 if no whitespace was found. |
findPreviousWhitespace | public static int findPreviousWhitespace(String data, int pos)(Code) | | |
findWordBoundary | public static int findWordBoundary(String data, int pos, String wordBoundaries)(Code) | | |
formatNumber | public static String formatNumber(int value, int length, boolean fillRight)(Code) | | |
getCurrentTimestampWithTZString | final public static String getCurrentTimestampWithTZString()(Code) | | |
getDoubleValue | public static double getDoubleValue(String aValue, double aDefault)(Code) | | |
getIntValue | public static int getIntValue(String aValue)(Code) | | |
getIntValue | public static int getIntValue(String aValue, int aDefault)(Code) | | |
getLongValue | public static long getLongValue(String aValue, long aDefault)(Code) | | |
getPathSeparator | public static String getPathSeparator()(Code) | | |
getRealLineLength | public static int getRealLineLength(String line)(Code) | | Returns the length of the line without any line ending characters
|
hasOpenQuotes | final public static boolean hasOpenQuotes(String data, char quoteChar)(Code) | | |
isEmptyString | final public static boolean isEmptyString(CharSequence value)(Code) | | Checks if the given String is null or has a zero length.
A String containing only whitespaces is not considered empty.
Parameters: value - the String to test |
isInteger | public static boolean isInteger(String value)(Code) | | |
isLowerCase | public static boolean isLowerCase(String s)(Code) | | |
isMixedCase | public static boolean isMixedCase(String s)(Code) | | |
isUpperCase | public static boolean isUpperCase(String s)(Code) | | |
isWhitespaceOrEmpty | final public static boolean isWhitespaceOrEmpty(CharSequence value)(Code) | | Checks if the given parameter is "empty",
i.e: either null, length == 0 or contains only whitespace
|
lastIndexOf | final public static int lastIndexOf(CharSequence s, char c)(Code) | | Replacement for StringBuilder.lastIndexOf() which does
a lot of object creation and copying to achieve this.
This implementation should be a lot faster for StringBuilder
and StringBuffer, and will basically be the same for String
objects.
Parameters: s - the string to search in Parameters: c - the character to look for -1 if c was not found, the position of c in s otherwise |
listToString | final public static String listToString(Collection aList, char aDelimiter)(Code) | | Create a String from the given Collection, where the elements are delimited
with the supplied delimiter
The elements of the Collection as a String Parameters: aList - The list to process Parameters: aDelimiter - The delimiter to use |
listToString | final public static String listToString(Collection aList, char aDelimiter, boolean quoteEntries)(Code) | | Create a String from the given list, where the elements are delimited
with the supplied delimiter
The elements of the Collection as a String Parameters: aList - The list to process Parameters: aDelimiter - The delimiter to use Parameters: quoteEntries - if true, all entries are quoted with a double quote |
makeFilename | final public static String makeFilename(String input)(Code) | | Remove all characters that might not be allowed in a filename from the input string.
Parameters: input - the value to be used as a filename input value without any characters that might not be allowed for a filename converted to lowercase |
makePlainLinefeed | public static String makePlainLinefeed(String input)(Code) | | Replace various combinations of linefeeds in the input string with \n.
Parameters: input - input string with only \n linefeeds See Also: StringUtil.PATTERN_NON_LF |
numDigits | public static int numDigits(int x)(Code) | | Returns the number of Digits of the value
Parameters: x - the value to check the number of digits that x consists of |
quoteRegexMeta | public static String quoteRegexMeta(String str)(Code) | | Quote the characters in a String that have a special meaning
in regular expression.
|
replaceToBuffer | final public static StringBuilder replaceToBuffer(StringBuilder target, String haystack, String needle, String replacement)(Code) | | Replaces all occurances of needle in haystack with replacement and appends the resulting
String to the passed target.
Parameters: target - the buffer to append the result to. If target is null a new StringBuilder will be created Parameters: haystack - the String in which to search the value Parameters: needle - the value to search for Parameters: replacement - the value with which needle is replaced the resulting buffer |
stringToBool | public static boolean stringToBool(String aString)(Code) | | |
stringToList | final public static List<String> stringToList(String aString, String aDelimiter, boolean removeEmpty, boolean trimEntries)(Code) | | |
stringToList | final public static List<String> stringToList(String aString, String aDelimiter, boolean removeEmpty, boolean trimEntries, boolean checkBrackets)(Code) | | Parses the given String and creates a List containing the elements
of the string that are separated by aDelimiter
Parameters: aString - the value to be parsed Parameters: aDelimiter - the delimiter to user Parameters: removeEmpty - flag to remove empty entries Parameters: trimEntries - flag to trim entries (will be applied beore checking for empty entries) Parameters: checkBrackets - flag to check for opening and closing brackets (delimiter inside brackets will not be taken into account) A List of Strings |
|
|