Package com.reportmill.base
Class StringUtils
- java.lang.Object
- 
- com.reportmill.base.StringUtils
 
- 
 public class StringUtils extends java.lang.ObjectThis class is a collection of convenient static String utils.
- 
- 
Constructor SummaryConstructors Constructor Description StringUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringadd(java.lang.String s1, java.lang.String s2)Adds the two strings together (treats nulls as empty strings).static java.lang.Stringadd(java.lang.String s1, java.lang.String s2, java.lang.String aSeparator)Adds the two strings together with separator (treats nulls as empty strings, ommitting sep if either is null).static java.lang.Stringdelete(java.lang.String aString, java.lang.String aSearch)Returns the result of deleting from the given string any occurance of the search string.static java.lang.StringdeleteIC(java.lang.String aString, java.lang.String aSearch)Returns the result of deleting from the given string any occurance of the search string (ignores case).static java.lang.StringdeleteLastPathComponent(java.lang.String aString)Returns the given path string minus the last part.static java.lang.StringdeletePathExtension(java.lang.String aString)Returns the given path string minus its extension.static doubledoubleValue(java.lang.String aString)Returns an double value by parsing the given string.static doubledoubleValue(java.lang.String aString, int aStart)Returns an double value by parsing the given string starting at the given index.static booleanendsWithIC(java.lang.String s1, java.lang.String s2)Returns whether s1 ends with s2, ignoring case.static booleanequalsIC(java.lang.String s1, java.lang.String s2)Returns whether s1 equals s2, ignoring case.static java.lang.StringfirstCharLowerCase(java.lang.String aString)Returns the given string with the first char demoted to lowercase.static java.lang.StringfirstCharUpperCase(java.lang.String aString)Returns the given string with the first char promoted to uppercase.static floatfloatValue(java.lang.String aString)Returns an float value by parsing the given string.static byte[]getBytes(java.lang.String aString)Returns the ASCII bytes of the given string (ISO-Latin).static byte[]getBytes(java.lang.String aString, java.lang.String enc)Returns the bytes of the given string in the requested char encoding.static java.lang.StringgetISOLatinString(byte[] bytes)Returns a string from the given ASCII bytes.static java.lang.StringgetISOLatinString(byte[] bytes, int offset, int length)Returns a string from the given ASCII bytes (from offset to offset+length).static intindexOfIC(java.lang.String s1, java.lang.String s2)Returns the index of search string s2 in given string s1, ignores case.static intindexOfIC(java.lang.String s1, java.lang.String s2, int start)Returns the index of search string s2 in given string s1, ignores case and starts at start char index.static intintValue(java.lang.String aString)Returns an int value by parsing the given string.static java.lang.Stringjoin(java.lang.Object[] parts, java.lang.String separator)Allows you to take an array of strings and concatenate them together with a separatorstatic java.lang.Stringjoin(java.lang.Object[] parts, java.lang.String separator, int numElements)Allows you to take an array of strings and concatenate them together with a separatorstatic java.lang.StringlastPathComponent(java.lang.String aString)Returns the last part of a path string.static java.lang.StringlastPathComponentNoExt(java.lang.String aString)Returns the file name of the given path string (minus parent directory and extension).static intlength(java.lang.String aString)Returns the length of given string (supports null).static java.lang.Stringmax(java.lang.String s)String promotion - returns either the given string or empty string (if given string is null).static java.lang.Stringmin(java.lang.String s)String demotion - returns either the given string or null (if given string length is zero).static RMRangenextKeyRangeAfterIndex(java.lang.String aString, int anIndex, RMRange aRange)Returns the range of the next occurance of @delimited@ text.static java.lang.Stringor(java.lang.String s1, java.lang.String s2)Returns the first non-null string of the two given strings (or null).static java.lang.StringpathExtension(java.lang.String aString)Returns the extension of the given string (or null if no extension).static java.lang.StringpathExtension2(java.lang.String aString)Returns the extension of the given string (or the string if no extension).static java.lang.Stringreplace(java.lang.String s, int start, int end, java.lang.String withString)Returns the result of replacing in the given string the char range with the with-string.static java.lang.Stringreplace(java.lang.String aString, java.lang.String search, char replace)Returns the result of replacing in the given string any occurance of the search string with the replace-char.static java.lang.Stringreplace(java.lang.String aString, java.lang.String search, java.lang.String replace)Returns the result of replacing in the given string any occurance of the search string with the replace-string.static java.lang.StringreplaceIC(java.lang.String aString, java.lang.String search, java.lang.String replace)Returns the result of replacing in given string any occurance of search string with replace-string (ignore case).static java.util.Listseparate(java.lang.String aString, java.lang.String aSeparator)Returns a list of parts of given string separated by the given delimiter.static java.util.Listseparate(java.lang.String aString, java.lang.String aSeparator, boolean stripLeadingSpaces)Returns a list of parts of given string separated by the given delimiter, with option to strip leading space.static booleanstartsWithIC(java.lang.String s1, java.lang.String s2)Returns whether s1 starts with s2, ignoring case.static java.lang.StringtoString(float aValue)Returns a string representation of the given float to (at most) 3 significant digits.static java.lang.StringtoString(float aValue, int significantDigits)Returns a string representation of the given float to the given number of significant digits.static java.lang.Stringwrap(java.lang.String aString, int approximateWidth)Returns string wrapped to approximate width (quick and dirty line wrapping for use in things like option panes).
 
- 
- 
- 
Method Detail- 
lengthpublic static int length(java.lang.String aString) Returns the length of given string (supports null).
 - 
addpublic static java.lang.String add(java.lang.String s1, java.lang.String s2)Adds the two strings together (treats nulls as empty strings).
 - 
addpublic static java.lang.String add(java.lang.String s1, java.lang.String s2, java.lang.String aSeparator)Adds the two strings together with separator (treats nulls as empty strings, ommitting sep if either is null).
 - 
minpublic static java.lang.String min(java.lang.String s) String demotion - returns either the given string or null (if given string length is zero).
 - 
maxpublic static java.lang.String max(java.lang.String s) String promotion - returns either the given string or empty string (if given string is null).
 - 
orpublic static java.lang.String or(java.lang.String s1, java.lang.String s2)Returns the first non-null string of the two given strings (or null).
 - 
toStringpublic static java.lang.String toString(float aValue) Returns a string representation of the given float to (at most) 3 significant digits.
 - 
toStringpublic static java.lang.String toString(float aValue, int significantDigits)Returns a string representation of the given float to the given number of significant digits.
 - 
nextKeyRangeAfterIndexpublic static RMRange nextKeyRangeAfterIndex(java.lang.String aString, int anIndex, RMRange aRange) Returns the range of the next occurance of @delimited@ text.
 - 
pathExtensionpublic static java.lang.String pathExtension(java.lang.String aString) Returns the extension of the given string (or null if no extension).
 - 
pathExtension2public static java.lang.String pathExtension2(java.lang.String aString) Returns the extension of the given string (or the string if no extension).
 - 
deletePathExtensionpublic static java.lang.String deletePathExtension(java.lang.String aString) Returns the given path string minus its extension.
 - 
lastPathComponentpublic static java.lang.String lastPathComponent(java.lang.String aString) Returns the last part of a path string.
 - 
deleteLastPathComponentpublic static java.lang.String deleteLastPathComponent(java.lang.String aString) Returns the given path string minus the last part.
 - 
lastPathComponentNoExtpublic static java.lang.String lastPathComponentNoExt(java.lang.String aString) Returns the file name of the given path string (minus parent directory and extension).
 - 
deletepublic static java.lang.String delete(java.lang.String aString, java.lang.String aSearch)Returns the result of deleting from the given string any occurance of the search string.
 - 
deleteICpublic static java.lang.String deleteIC(java.lang.String aString, java.lang.String aSearch)Returns the result of deleting from the given string any occurance of the search string (ignores case).
 - 
replacepublic static java.lang.String replace(java.lang.String s, int start, int end, java.lang.String withString)Returns the result of replacing in the given string the char range with the with-string.
 - 
replacepublic static java.lang.String replace(java.lang.String aString, java.lang.String search, char replace)Returns the result of replacing in the given string any occurance of the search string with the replace-char.
 - 
replacepublic static java.lang.String replace(java.lang.String aString, java.lang.String search, java.lang.String replace)Returns the result of replacing in the given string any occurance of the search string with the replace-string.
 - 
replaceICpublic static java.lang.String replaceIC(java.lang.String aString, java.lang.String search, java.lang.String replace)Returns the result of replacing in given string any occurance of search string with replace-string (ignore case).
 - 
separatepublic static java.util.List separate(java.lang.String aString, java.lang.String aSeparator)Returns a list of parts of given string separated by the given delimiter.
 - 
separatepublic static java.util.List separate(java.lang.String aString, java.lang.String aSeparator, boolean stripLeadingSpaces)Returns a list of parts of given string separated by the given delimiter, with option to strip leading space.
 - 
intValuepublic static int intValue(java.lang.String aString) Returns an int value by parsing the given string.
 - 
floatValuepublic static float floatValue(java.lang.String aString) Returns an float value by parsing the given string.
 - 
doubleValuepublic static double doubleValue(java.lang.String aString) Returns an double value by parsing the given string.
 - 
doubleValuepublic static double doubleValue(java.lang.String aString, int aStart)Returns an double value by parsing the given string starting at the given index.
 - 
getBytespublic static byte[] getBytes(java.lang.String aString) Returns the ASCII bytes of the given string (ISO-Latin).
 - 
getBytespublic static byte[] getBytes(java.lang.String aString, java.lang.String enc)Returns the bytes of the given string in the requested char encoding.
 - 
getISOLatinStringpublic static java.lang.String getISOLatinString(byte[] bytes) Returns a string from the given ASCII bytes.
 - 
getISOLatinStringpublic static java.lang.String getISOLatinString(byte[] bytes, int offset, int length)Returns a string from the given ASCII bytes (from offset to offset+length).
 - 
indexOfICpublic static int indexOfIC(java.lang.String s1, java.lang.String s2)Returns the index of search string s2 in given string s1, ignores case.
 - 
indexOfICpublic static int indexOfIC(java.lang.String s1, java.lang.String s2, int start)Returns the index of search string s2 in given string s1, ignores case and starts at start char index.
 - 
equalsICpublic static boolean equalsIC(java.lang.String s1, java.lang.String s2)Returns whether s1 equals s2, ignoring case.
 - 
endsWithICpublic static boolean endsWithIC(java.lang.String s1, java.lang.String s2)Returns whether s1 ends with s2, ignoring case.
 - 
startsWithICpublic static boolean startsWithIC(java.lang.String s1, java.lang.String s2)Returns whether s1 starts with s2, ignoring case.
 - 
firstCharUpperCasepublic static java.lang.String firstCharUpperCase(java.lang.String aString) Returns the given string with the first char promoted to uppercase.
 - 
firstCharLowerCasepublic static java.lang.String firstCharLowerCase(java.lang.String aString) Returns the given string with the first char demoted to lowercase.
 - 
wrappublic static java.lang.String wrap(java.lang.String aString, int approximateWidth)Returns string wrapped to approximate width (quick and dirty line wrapping for use in things like option panes).
 - 
joinpublic static java.lang.String join(java.lang.Object[] parts, java.lang.String separator)Allows you to take an array of strings and concatenate them together with a separator- Parameters:
- parts- an array of Strings
- separator- a string to place between elements
- Returns:
 
 - 
joinpublic static java.lang.String join(java.lang.Object[] parts, java.lang.String separator, int numElements)Allows you to take an array of strings and concatenate them together with a separator- Parameters:
- parts- an array to be conacatenated
- separator- a string to place between elements
- numElements- how many to include in the result
- Returns:
 
 
- 
 
-