Package com.reportmill.base
Class StringUtils
java.lang.Object
com.reportmill.base.StringUtils
This class is a collection of convenient static String utils.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Adds the two strings together (treats nulls as empty strings).static String
Adds the two strings together with separator (treats nulls as empty strings, ommitting sep if either is null).static String
Returns the result of deleting from the given string any occurance of the search string.static String
Returns the result of deleting from the given string any occurance of the search string (ignores case).static String
deleteLastPathComponent
(String aString) Returns the given path string minus the last part.static String
deletePathExtension
(String aString) Returns the given path string minus its extension.static double
doubleValue
(String aString) Returns an double value by parsing the given string.static double
doubleValue
(String aString, int aStart) Returns an double value by parsing the given string starting at the given index.static boolean
endsWithIC
(String s1, String s2) Returns whether s1 ends with s2, ignoring case.static boolean
Returns whether s1 equals s2, ignoring case.static String
firstCharLowerCase
(String aString) Returns the given string with the first char demoted to lowercase.static String
firstCharUpperCase
(String aString) Returns the given string with the first char promoted to uppercase.static float
floatValue
(String aString) Returns an float value by parsing the given string.static byte[]
Returns the ASCII bytes of the given string (ISO-Latin).static byte[]
Returns the bytes of the given string in the requested char encoding.static String
getISOLatinString
(byte[] bytes) Returns a string from the given ASCII bytes.static String
getISOLatinString
(byte[] bytes, int offset, int length) Returns a string from the given ASCII bytes (from offset to offset+length).static int
Returns the index of search string s2 in given string s1, ignores case.static int
Returns the index of search string s2 in given string s1, ignores case and starts at start char index.static int
Returns an int value by parsing the given string.static String
Allows you to take an array of strings and concatenate them together with a separatorstatic String
Allows you to take an array of strings and concatenate them together with a separatorstatic String
lastPathComponent
(String aString) Returns the last part of a path string.static String
lastPathComponentNoExt
(String aString) Returns the file name of the given path string (minus parent directory and extension).static int
Returns the length of given string (supports null).static String
String promotion - returns either the given string or empty string (if given string is null).static String
String demotion - returns either the given string or null (if given string length is zero).static RMRange
nextKeyRangeAfterIndex
(String aString, int anIndex, RMRange aRange) Returns the range of the next occurance of @delimited@ text.static String
Returns the first non-null string of the two given strings (or null).static String
pathExtension
(String aString) Returns the extension of the given string (or null if no extension).static String
pathExtension2
(String aString) Returns the extension of the given string (or the string if no extension).static String
Returns the result of replacing in the given string the char range with the with-string.static String
Returns the result of replacing in the given string any occurance of the search string with the replace-char.static String
Returns the result of replacing in the given string any occurance of the search string with the replace-string.static String
Returns the result of replacing in given string any occurance of search string with replace-string (ignore case).static List
Returns a list of parts of given string separated by the given delimiter.static List
Returns a list of parts of given string separated by the given delimiter, with option to strip leading space.static boolean
startsWithIC
(String s1, String s2) Returns whether s1 starts with s2, ignoring case.static String
toString
(float aValue) Returns a string representation of the given float to (at most) 3 significant digits.static String
toString
(float aValue, int significantDigits) Returns a string representation of the given float to the given number of significant digits.static String
Returns string wrapped to approximate width (quick and dirty line wrapping for use in things like option panes).
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
length
Returns the length of given string (supports null). -
add
Adds the two strings together (treats nulls as empty strings). -
add
Adds the two strings together with separator (treats nulls as empty strings, ommitting sep if either is null). -
min
String demotion - returns either the given string or null (if given string length is zero). -
max
String promotion - returns either the given string or empty string (if given string is null). -
or
Returns the first non-null string of the two given strings (or null). -
toString
Returns a string representation of the given float to (at most) 3 significant digits. -
toString
Returns a string representation of the given float to the given number of significant digits. -
nextKeyRangeAfterIndex
Returns the range of the next occurance of @delimited@ text. -
pathExtension
Returns the extension of the given string (or null if no extension). -
pathExtension2
Returns the extension of the given string (or the string if no extension). -
deletePathExtension
Returns the given path string minus its extension. -
lastPathComponent
Returns the last part of a path string. -
deleteLastPathComponent
Returns the given path string minus the last part. -
lastPathComponentNoExt
Returns the file name of the given path string (minus parent directory and extension). -
delete
Returns the result of deleting from the given string any occurance of the search string. -
deleteIC
Returns the result of deleting from the given string any occurance of the search string (ignores case). -
replace
Returns the result of replacing in the given string the char range with the with-string. -
replace
Returns the result of replacing in the given string any occurance of the search string with the replace-char. -
replace
Returns the result of replacing in the given string any occurance of the search string with the replace-string. -
replaceIC
Returns the result of replacing in given string any occurance of search string with replace-string (ignore case). -
separate
Returns a list of parts of given string separated by the given delimiter. -
separate
Returns a list of parts of given string separated by the given delimiter, with option to strip leading space. -
intValue
Returns an int value by parsing the given string. -
floatValue
Returns an float value by parsing the given string. -
doubleValue
Returns an double value by parsing the given string. -
doubleValue
Returns an double value by parsing the given string starting at the given index. -
getBytes
Returns the ASCII bytes of the given string (ISO-Latin). -
getBytes
Returns the bytes of the given string in the requested char encoding. -
getISOLatinString
Returns a string from the given ASCII bytes. -
getISOLatinString
Returns a string from the given ASCII bytes (from offset to offset+length). -
indexOfIC
Returns the index of search string s2 in given string s1, ignores case. -
indexOfIC
Returns the index of search string s2 in given string s1, ignores case and starts at start char index. -
equalsIC
Returns whether s1 equals s2, ignoring case. -
endsWithIC
Returns whether s1 ends with s2, ignoring case. -
startsWithIC
Returns whether s1 starts with s2, ignoring case. -
firstCharUpperCase
Returns the given string with the first char promoted to uppercase. -
firstCharLowerCase
Returns the given string with the first char demoted to lowercase. -
wrap
Returns string wrapped to approximate width (quick and dirty line wrapping for use in things like option panes). -
join
Allows you to take an array of strings and concatenate them together with a separator- Parameters:
parts
- an array of Stringsseparator
- a string to place between elements- Returns:
-
join
Allows you to take an array of strings and concatenate them together with a separator- Parameters:
parts
- an array to be conacatenatedseparator
- a string to place between elementsnumElements
- how many to include in the result- Returns:
-