Package org.locationtech.jtstest.util
Class StringUtil
java.lang.Object
org.locationtech.jtstest.util.StringUtil
Useful string utilities
- Version:
- 1.7
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
capitalize
(String s) Capitalizes the given string.static boolean
Returns true if substring is indeed a substring of string.static boolean
containsIgnoreCase
(String string, String substring) Returns true if substring is indeed a substring of string.static String
private static String
Decodes strings returned by #encodeStartingVowelsprivate static String
Replaces vowels that start words with a special codestatic String
escapeHTML
(String s) static String
format
(double d, int decimals) Returns d as a string truncated to the specified number of decimal placesstatic List
Converts the comma-delimited string into a List of trimmed strings.static String
Returns an throwable's stack tracestatic String
getStackTrace
(Throwable t, int depth) static String
getTimeString
(long milliseconds) Converts the milliseconds value into a String of the form "9d 22h 15m 8s".static String
static int
indexOfIgnoreParentheses
(char c, String s, int start) Returns the position of the first occurrence of the given character found in s starting at start.static boolean
Returns true if s can be converted to an int.static String
Pads the String with the given character until it has the given length.static String
Replaces consecutive instances of characters with single instances.static String
removeFromEnd
(String s, String strToRemove) static String
Removes vowels from the string.static String
Removes vowels from the string except those that start words.static void
replace
(StringBuffer orig, String o, String n, boolean all) Replaces all instances of the String o with the String n in the StringBuffer orig if all is true, or only the first instance if all is false.static String
Returns a string with all occurrences of oldChar replaced by newStrstatic String
Returns original with occurrences of oldSubstring replaced by newSubstring.static String
replaceAll
(String original, String oldSubstring, String newSubstring) Returns original with all occurrences of oldSubstring replaced by newSubstringstatic String
replaceFirst
(String original, String oldSubstring, String newSubstring) Returns original with the first occurrenc of oldSubstring replaced by newSubstringstatic String
Pads the String with the given character until it has the given length.static String
stringOfChar
(char ch, int count) Returns a String of the given length consisting entirely of the given characterstatic String
stripHTMLTags
(String original) Removes the HTML tags from the given String, inserting line breaks at appropriate places.static String
Returns the elements of c separated by commas.static String
Returns the elements of c separated by commas and enclosed in single-quotesstatic Vector
toLowerCase
(List v) Returns the elements of v in lowercasestatic String
If s is null, returns "null"; otherwise, returns s.static Vector
Returns the elements of v in uppercasestatic String
Line-wraps a string s by inserting CR-LF instead of the first space after the nth columns.
-
Field Details
-
newLine
-
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
removeFromEnd
-
capitalize
Capitalizes the given string.- Parameters:
s
- the string to capitalize- Returns:
- the capitalized string
-
isInteger
Returns true if s can be converted to an int. -
getStackTrace
Returns an throwable's stack trace -
getStackTrace
-
getTimeString
Converts the milliseconds value into a String of the form "9d 22h 15m 8s". -
containsIgnoreCase
Returns true if substring is indeed a substring of string. Case-insensitive. -
contains
Returns true if substring is indeed a substring of string. -
replace
Returns a string with all occurrences of oldChar replaced by newStr -
stringOfChar
Returns a String of the given length consisting entirely of the given character -
indent
-
toUpperCase
Returns the elements of v in uppercase -
toLowerCase
Returns the elements of v in lowercase -
toCommaDelimitedStringInQuotes
Returns the elements of c separated by commas and enclosed in single-quotes -
toCommaDelimitedString
Returns the elements of c separated by commas. c must not be empty. -
fromCommaDelimitedString
Converts the comma-delimited string into a List of trimmed strings. -
toStringNeverNull
If s is null, returns "null"; otherwise, returns s. -
replace
Replaces all instances of the String o with the String n in the StringBuffer orig if all is true, or only the first instance if all is false. Posted by Steve Chapel invalid input: '<'schapel@breakthr.com> on UseNet -
replaceAll
Returns original with all occurrences of oldSubstring replaced by newSubstring -
replaceFirst
Returns original with the first occurrenc of oldSubstring replaced by newSubstring -
leftPad
Pads the String with the given character until it has the given length. If original is longer than the given length, returns original. -
rightPad
Pads the String with the given character until it has the given length. If original is longer than the given length, returns original. -
stripHTMLTags
Removes the HTML tags from the given String, inserting line breaks at appropriate places. Needs a little work. -
format
Returns d as a string truncated to the specified number of decimal places -
wrap
Line-wraps a string s by inserting CR-LF instead of the first space after the nth columns. -
removeVowels
Removes vowels from the string. Case-insensitive. -
removeVowelsSkipStarts
Removes vowels from the string except those that start words. Case-insensitive. -
removeConsecutiveDuplicates
Replaces consecutive instances of characters with single instances. Case-insensitive. -
indexOfIgnoreParentheses
Returns the position of the first occurrence of the given character found in s starting at start. Ignores text within pairs of parentheses. Returns -1 if no occurrence is found. -
replace
public static String replace(String original, String oldSubstring, String newSubstring, boolean all) Returns original with occurrences of oldSubstring replaced by newSubstring. Set all to true to replace all occurrences, or false to replace the first occurrence only. -
encodeStartingVowels
Replaces vowels that start words with a special code -
decodeStartingVowels
Decodes strings returned by #encodeStartingVowels -
escapeHTML
-
currentMethodName
-