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 StringAdds the two strings together (treats nulls as empty strings).static StringAdds the two strings together with separator (treats nulls as empty strings, ommitting sep if either is null).static StringReturns the result of deleting from the given string any occurance of the search string.static StringReturns the result of deleting from the given string any occurance of the search string (ignores case).static StringdeleteLastPathComponent(String aString) Returns the given path string minus the last part.static StringdeletePathExtension(String aString) Returns the given path string minus its extension.static doubledoubleValue(String aString) Returns an double value by parsing the given string.static doubledoubleValue(String aString, int aStart) Returns an double value by parsing the given string starting at the given index.static booleanendsWithIC(String s1, String s2) Returns whether s1 ends with s2, ignoring case.static booleanReturns whether s1 equals s2, ignoring case.static StringfirstCharLowerCase(String aString) Returns the given string with the first char demoted to lowercase.static StringfirstCharUpperCase(String aString) Returns the given string with the first char promoted to uppercase.static floatfloatValue(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 StringgetISOLatinString(byte[] bytes) Returns a string from the given ASCII bytes.static StringgetISOLatinString(byte[] bytes, int offset, int length) Returns a string from the given ASCII bytes (from offset to offset+length).static intReturns the index of search string s2 in given string s1, ignores case.static intReturns the index of search string s2 in given string s1, ignores case and starts at start char index.static intReturns an int value by parsing the given string.static StringAllows you to take an array of strings and concatenate them together with a separatorstatic StringAllows you to take an array of strings and concatenate them together with a separatorstatic StringlastPathComponent(String aString) Returns the last part of a path string.static StringlastPathComponentNoExt(String aString) Returns the file name of the given path string (minus parent directory and extension).static intReturns the length of given string (supports null).static StringString promotion - returns either the given string or empty string (if given string is null).static StringString demotion - returns either the given string or null (if given string length is zero).static RMRangenextKeyRangeAfterIndex(String aString, int anIndex, RMRange aRange) Returns the range of the next occurance of @delimited@ text.static StringReturns the first non-null string of the two given strings (or null).static StringpathExtension(String aString) Returns the extension of the given string (or null if no extension).static StringpathExtension2(String aString) Returns the extension of the given string (or the string if no extension).static StringReturns the result of replacing in the given string the char range with the with-string.static StringReturns the result of replacing in the given string any occurance of the search string with the replace-char.static StringReturns the result of replacing in the given string any occurance of the search string with the replace-string.static StringReturns the result of replacing in given string any occurance of search string with replace-string (ignore case).static ListReturns a list of parts of given string separated by the given delimiter.static ListReturns a list of parts of given string separated by the given delimiter, with option to strip leading space.static booleanstartsWithIC(String s1, String s2) Returns whether s1 starts with s2, ignoring case.static StringtoString(float aValue) Returns a string representation of the given float to (at most) 3 significant digits.static StringtoString(float aValue, int significantDigits) Returns a string representation of the given float to the given number of significant digits.static StringReturns 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:
-