Package com.webmethods.caf.common
Class StringTools
java.lang.Object
com.webmethods.caf.common.StringTools
Various string utility functions and operations
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
String variable 'false'static final String
String variable 'on'static final String
String variable 'off'static final String
String variable 'on'static final String
String variable 'true'static final String
String variable 'yes'static final char
Standard char back slashstatic final char
Standard char dotstatic final char
Standard char forward slashstatic final char
Standard char tabstatic final String
static final String
static String
Cached line separator to concatenate stringsstatic final int
Values used intruncateArray(java.lang.Object[], int[])
to specify that no truncation should be madestatic final String
static final String
Standard string ampersandstatic final String
static final String
Standard string commastatic final String
static final String
Standard string equalsstatic final String
Escaped single quotestatic final String
Standard string for failedstatic final String
Standard string question markstatic final String
Standard string semicolonstatic final String
Single quotestatic final String
Standard string spacestatic final String
Standard string for successfulprotected static final String
For TLSstatic final String
Standard system encoding (UTF-8) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
capitalizeName
(String name) Capitalizes name stringstatic String
Changes occurrences of a specified pattern to a replacement string.static String
Changes occurrences of a specified pattern to a replacement string.static String
Changes occurrences of a specified pattern to a replacement string.static String
Changes occurrences of a specified pattern to a replacement string.static String
Changes occurrences of a specified pattern to a replacement string.static String
Changes occurrences of a specified pattern to a replacement string.static String
charStr
(char character, int count) Creates a string consisting of the given characterstatic void
checkValueForControlCharacters
(String key, String value) static int
compareStrings
(String s1, String s2, boolean ignoreCase) Compare two strings, always treating null as greater thanstatic String
Fast 2 string concatenation usingStringBuffer
.static String
Fast 3 strings concatenation usingStringBuffer
static String
Fast 4 string concatenation usingStringBuffer
Convert comma-separated line toSet
of strings.static String
ensureLeading
(String value, String prefix) Ensures that string starts with specified symbolstatic String
ensureTrailing
(String value, String suffix) Ensures that string ends with specified symbolstatic boolean
equals
(char c1, char c2, boolean ignoreCase) Checks if two characters are equal.static boolean
Checks if two strings are equal.static long
fastParseLong
(String str) Fast implementation ofLong.parseLong(java.lang.String, int)
It assumes that it parses decimal radix number It doesn't not check Long constraints It doesn't handle unicode stringstatic String[]
Parses comma (",") delimited string to string array.static boolean[]
getBooleanArrayFromCsv
(String data) Parses csv string and returns array of boolean as a result of parsing.static byte[]
getByteArrayFromCsv
(String data) Parses csv string and returns array of boolean as a result of parsing.static String
getCsvFromList
(List<?> list) Constructs string from list of valuesgetDelimitedList
(String value, String delims) GetArrayList
of tokens from delimited original stringgetDelimitedList
(String value, String delims, boolean includeDelim) GetArrayList
of tokens from delimited original stringstatic double[]
getDoubleArrayFromCsv
(String data) Parses csv string and returns array of double as a result of parsing.static String
getFirstSegment
(String value, String separator) Get first string segment separated by passed separatorstatic float[]
getFloatArrayFromCsv
(String data) Parses csv string and returns array of float as a result of parsing.static String
Utility function to construct full exception stack trace information.static int[]
getIntArrayFromCsv
(String data) Parses csv string and returns array of ints as a result of parsing.static int[]
getIntArrayFromDelimitedString
(String data, String delimiter) Parses string with the specified delimiter and returns array of ints as a result of parsing.static String
getLastSegment
(String value, String separator) Get last string segment separated by passed separatorstatic String
getLastSegment
(String value, String separator, boolean includeSeperator) Get last string segment separated by passed separatorgetListFromCsv
(String value) getListFromCsv
(String value, boolean allowDups) getListFromDelimitedString
(String data, String delimiter) Parses data with the specified delimiterstatic long[]
getLongArrayFromCsv
(String data) Parses csv string and returns array of long as a result of parsing.getLongsListFromCsv
(String value) static String
getSegment
(String str, String separator, int segment) Returns the segment, null if not found, first segment is segment 0static short[]
getShortArrayFromCsv
(String data) Parses csv string and returns array of short as a result of parsing.static String
Utility function to recieve exception stack trace as a stringstatic String
hasSuccess
(Object instance) Checks instance to be not null, and returns either success or failed stringstatic String
humanizeName
(String name) Converts identifiers like "myJavaCompliantName123" into "My Java Compliant Name 123"static int
Returns the index of the first ocurrence of the specified string.static String
intToHex
(int value, boolean padding) Convert integer to hex, optionally padding with 0sstatic boolean
Verifies whether passed string is empty or not.static boolean
Checks whether one of the 2 strings is emptystatic boolean
isEmptyString
(Object obj) Verifies whether passed string is a String or String[] and whether empty or not.static boolean
Checks whether specified value convertable to floatstatic boolean
isFormatCharsOnly
(String value) Verifies that string contains only formatting charactersstatic String
loadStringFromReader
(Reader reader) Loads and return string from a reader.static String
loadStringfromStream
(InputStream input) Loads and return string from anInputStream
static String
Lower cases first character of a stringstatic boolean
Checks that string is not empty.static boolean
Checks that 2 strings are not emptystatic boolean
Checks if two strings are NOT equal.static boolean
Checks that 2 strings are not nullsstatic int
occurrencesOf
(String s, int ch, int start) counts characters in string, case sensitivestatic int
occurrencesOf
(String s, String c, int start, boolean ignoreCase) Returns the number of occurrences of the specified string.static String
static boolean
parseBooleanDef
(String s, boolean def) Parses string and returns converted boolean value.static int
parseIntDef
(String s, int def) Parses string and returns converted integer value.static long
parseLongDef
(String s, long def) Parses string and returns converted boolean value.static void
parseParameters
(String url, int start, Map<String, String> parameters) Adds parameters from url query string to specified map.static String
removeChars
(String orig, String chars) Replaces all chars with the replacement charstatic String
Replaces all CR(\n) symbols in string via " "(space) characterstatic String
replaceChars
(String orig, String chars, char replace) Replaces all chars with the replacement charstatic String
replaceChars
(String orig, String chars, String replace) Replaces all chars with the replacement charstatic String
replaceHiAsciChars
(String orig, char replacementChar) Strips out the hi ascii chars (>127) and replaces them with a replacement charstatic String
replaceParams
(String source, String[] params) Replace placeholders, or parameters, in a string that are of the format %[number].static String
smallIntToHex
(int value, boolean padding) Convert small int to hex, optionally padding with 0sstatic String
stripFirstSegment
(String value, String separator) Strips string first segment, defined by separator and returns stripped stringstatic String
stripLastSegment
(String value, String separator) Strips string last segment, defined by separator and returns stripped stringstatic String
substituteBatch
(String source, Map<String, String> valuesMap) Replace all patterns in the string with the ones given in the givenHashMap
instance.static String
tabStr
(int count) Return string containing the specified quantity of '\t' characterstatic boolean
Converts string to boolean.static String
toCsv
(boolean[] array) Convert array of boolean to comma-separated stringstatic String
toCsv
(byte[] array) Convert array of byte to comma-separated stringstatic String
toCsv
(double[] array) Convert array of double to comma-separated stringstatic String
toCsv
(float[] array) Convert array of float to comma-separated stringstatic String
toCsv
(int[] array) Convert array of int to comma-separated stringstatic String
toCsv
(long[] array) Convert array of long to comma-separated stringstatic String
toCsv
(short[] array) Convert array of short to comma-separated stringstatic String
Convert array of objects to comma-separated string using the toString() method to retrieve the value for each entry.static String
Convert array of strings to comma-separated stringstatic String
ConvertList
of strings to comma-separated stringstatic String
toString
(InputStream stream) Loads stream contents to the streamstatic String
Load string from readerstatic String
ToString objectstatic String
To string an array of objects separated by ',' and surrounded by '[' and ']'.static String
Convert array to single string presentation for debugging purposesstatic String
Convert array of strings to single string presentation for debug purposesstatic String
toString
(Collection<?> collection, String lineSeperator) ConvertCollection
of object to single string for debugging purposesstatic String
Prints out a map with key value pairs combined with '=' separated by ',' and surrounded by { and }static String
Prints out a map with key value pairs combined with '=' separated by ',' and surrounded by { and }static String
trimString
(String s, String charsToTrim) Trims specified characters from the beginning and end of the stringstatic String
Truncates input string to the specified sizestatic void
truncateArray
(Object[] values, int[] actions) Truncate array of strings using specified list of lengths (actions).static String
Unwraps string using selected prefix and postfixstatic String
Capilizes first character of a stringstatic String
Wrap string value with prefix and postfix.
-
Field Details
-
OPENING_BRACE
- See Also:
-
CLOSING_BRACE
- See Also:
-
DOLLAR_SIGN
- See Also:
-
STR_EMPTY
- See Also:
-
STR_COLON
- See Also:
-
STR_SUCCESSFUL
Standard string for successful- See Also:
-
STR_FAILED
Standard string for failed- See Also:
-
SYSTEM_ENCODING
Standard system encoding (UTF-8) -
BOOLEAN_ON
String variable 'on'- See Also:
-
BOOLEAN_OFF
String variable 'off'- See Also:
-
BOOLEAN_YES
String variable 'yes'- See Also:
-
BOOLEAN_NO
String variable 'on'- See Also:
-
BOOLEAN_FALSE
String variable 'false' -
BOOLEAN_TRUE
String variable 'true' -
STR_COMMA
Standard string comma- See Also:
-
STR_SEMICOLON
Standard string semicolon- See Also:
-
STR_QUESTION
Standard string question mark- See Also:
-
STR_EQUALS
Standard string equals- See Also:
-
STR_AND
Standard string ampersand- See Also:
-
STR_SPACE
Standard string space- See Also:
-
CHR_DOT
public static final char CHR_DOTStandard char dot- See Also:
-
CHR_FORWARD_SLASH
public static final char CHR_FORWARD_SLASHStandard char forward slash- See Also:
-
CHR_BACK_SLASH
public static final char CHR_BACK_SLASHStandard char back slash- See Also:
-
CHR_TAB
public static final char CHR_TABStandard char tab- See Also:
-
STR_SINGLE_QUOTE
Single quote- See Also:
-
STR_ESCAPED_SINGLE_QUOTE
Escaped single quote- See Also:
-
LINE_SEPARATOR
Cached line separator to concatenate strings -
NO_ACTION
public static final int NO_ACTIONValues used intruncateArray(java.lang.Object[], int[])
to specify that no truncation should be made- See Also:
-
STRING_TOOLS_TLS_KEY
For TLS
-
-
Constructor Details
-
StringTools
public StringTools()
-
-
Method Details
-
hasSuccess
Checks instance to be not null, and returns either success or failed string- Parameters:
instance
- object instance to check
-
getListFromDelimitedString
Parses data with the specified delimiter- Parameters:
data
- Original data to parsedelimiter
- Delimiter to use for data parsing- Returns:
LinkedList
of tokens parsed, delimiters are not returned
-
getIntArrayFromDelimitedString
Parses string with the specified delimiter and returns array of ints as a result of parsing. Of course this appliable only when you do know that string contains integers- Parameters:
data
- Original data to parsedelimiter
- Delimiter to use for data parsing- Returns:
- array of integers
-
getArrayFromCsvString
Parses comma (",") delimited string to string array. No quotes (") supported- Parameters:
csv
- Comma separated values- Returns:
- array of
String
extracted from line
-
getListFromCsv
-
getListFromCsv
-
getLongsListFromCsv
-
getCsvFromList
Constructs string from list of values- Parameters:
list
- source list of values- Returns:
- Comma-separated string as a result of values concatenation
-
getFirstSegment
Get first string segment separated by passed separator- Parameters:
value
- initial stringseparator
- is separator string- Returns:
- stripped segment or null
-
getLastSegment
Get last string segment separated by passed separator- Parameters:
value
- initial stringseparator
- is separator string- Returns:
- stripped segment or null
-
getLastSegment
Get last string segment separated by passed separator- Parameters:
value
- initial stringseparator
- is separator stringincludeSeperator
- true to include the seperator character in the result, false otherwise- Returns:
- stripped segment or null
-
getSegment
Returns the segment, null if not found, first segment is segment 0- Parameters:
str
- Source stringseparator
- Parsing separatorsegment
- String segment number- Returns:
- Specified segment of the string extracted
-
stripFirstSegment
Strips string first segment, defined by separator and returns stripped string- Parameters:
value
- initial stringseparator
- is separator string- Returns:
- stripped value string
-
stripLastSegment
Strips string last segment, defined by separator and returns stripped string- Parameters:
value
- initial stringseparator
- is separator string- Returns:
- stripped value string
-
isEmpty
Verifies whether passed string is empty or not.- Parameters:
str
- Source string to analyze- Returns:
- True, if string is empty, False - otherwise
-
notEmpty
Checks that string is not empty. Can be opposed to usage ofisEmpty(java.lang.String)
- Parameters:
str
- String value to analyze- Returns:
- true, if string is empty, false otherwise
- See Also:
-
removeCR
Replaces all CR(\n) symbols in string via " "(space) character- Parameters:
s
- Source string- Returns:
- String with all CR(\n) chars replaced with space(" ")
-
parseIntDef
Parses string and returns converted integer value. If parsing failes the default value is taken.- Parameters:
s
- string to parsedef
- default int value, if string is unparsable- Returns:
- int as a result string to int conversion
-
parseBooleanDef
Parses string and returns converted boolean value. If parsing fails the default value is taken.- Parameters:
s
- String to parsedef
- Default boolean value- Returns:
- boolean value that is parsed from the string
-
parseLongDef
Parses string and returns converted boolean value. If parsing fails the default value is taken.- Parameters:
s
- String to parsedef
- Default boolean value- Returns:
- boolean value that is parsed from the string
-
parseParameters
Adds parameters from url query string to specified map.- Parameters:
url
- Url with query string.start
- Index at which to start parse (ie url.indexOf('?')).parameters
- Map into which to put parsed param name=value pairs.
-
change
public static String change(String s, String oldp, String newp, int start, int maxChanges, boolean ignoreCase) Changes occurrences of a specified pattern to a replacement string. The maximum number of changes and a starting position can be specified. You can specify that case should be ignored.- Parameters:
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringstart
- the starting position for the searchmaxChanges
- the maximum number of changesignoreCase
- if true case is ignored when comparing characters- Returns:
- a string with the specified patterns changed.
-
change
Changes occurrences of a specified pattern to a replacement string. The starting position can be specified. You can specify that case should be ignored.- Parameters:
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing characters- Returns:
- a string with the specified patterns changed.
-
change
Changes occurrences of a specified pattern to a replacement string. The maximum number of changes and a starting position can be specified.- Parameters:
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringstart
- the starting position for the searchmaxChanges
- the maximum number of changes- Returns:
- a string with the specified patterns changed.
-
change
Changes occurrences of a specified pattern to a replacement string. A starting position can be specified.- Parameters:
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringstart
- the starting position for the search- Returns:
- a string with the specified patterns changed.
-
change
Changes occurrences of a specified pattern to a replacement string. You can specify that case should be ignored.- Parameters:
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement stringignoreCase
- if true case is ignored when comparing characters- Returns:
- a string with the specified patterns changed.
-
change
Changes occurrences of a specified pattern to a replacement string.- Parameters:
s
- the input stringoldp
- the pattern to be replacednewp
- the replacement string- Returns:
- a string with the specified patterns changed.
-
occurrencesOf
Returns the number of occurrences of the specified string. You can specify that case should be ignored.- Parameters:
s
- the string to be inspectedc
- the string to search forstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing characters- Returns:
- the number of occurrences of the specified string. If the string is not found -1 is returned.
-
occurrencesOf
counts characters in string, case sensitive- Parameters:
s
- string to analyzech
- character we are looking forstart
- start offset inside the string- Returns:
- quantity of character occurrences inside the specified string
-
indexOf
Returns the index of the first ocurrence of the specified string. You can specify that case should be ignored.- Parameters:
s
- the string to be inspectedc
- the string to be searched forstart
- the starting position for the searchignoreCase
- if true case is ignored when comparing characters- Returns:
- the index of the first ocurrence of the specified string.
- See Also:
-
equals
public static boolean equals(char c1, char c2, boolean ignoreCase) Checks if two characters are equal. You can specify that case should be ignored.- Parameters:
c1
- first characterc2
- second characterignoreCase
- if true case is ignored when comparing characters- Returns:
- true if the characters are equal, false otherwise
- See Also:
-
equals
Checks if two strings are equal. You can specify that case should be ignored.- Parameters:
s1
- first strings2
- second stringignoreCase
- if true case is ignored when comparing string- Returns:
- true if the characters are equal, false otherwise, true if they are both null
- See Also:
-
notEquals
Checks if two strings are NOT equal. You can specify that case should be ignored.- Parameters:
s1
- first strings2
- second stringignoreCase
- if true case is ignored when comparing string- Returns:
- true if the characters are NOT equal, false otherwise, true if they are both null
- See Also:
-
compareStrings
Compare two strings, always treating null as greater than- Parameters:
s1
- first strings2
- second stringignoreCase
- if true case is ignored when comparing string- Returns:
- >0 if greater than <0 if less than, 0 if equal
- See Also:
-
substituteBatch
Replace all patterns in the string with the ones given in the givenHashMap
instance. Example:// This string is obtained on run-time. For example, template inner text String toChangeIn = "<H1> ${SomeVarName} </H1>\r\n<td>${AnotherVarName}</td>"; hashMap.put("${SomeVarName}", SomeRunTimeVarValue); hashMap.put("${AnotherVarName}", AnotherVarRuntime); String changedString = StringTools.substituteBatch(toChangeIn, hashMap);
-
intToHex
Convert integer to hex, optionally padding with 0s- Parameters:
value
- int value to convertpadding
- do we want to pad int with 0's- Returns:
- String hexadecimal presentation of the specified value (optionally padded)
-
smallIntToHex
Convert small int to hex, optionally padding with 0s- Parameters:
value
- small int value to convertpadding
- do we want to pad int with 0's- Returns:
- String hexadecimal presentation of the specified value (optionally padded)
-
ensureTrailing
Ensures that string ends with specified symbol- Parameters:
value
- string value to ensuresuffix
- suffex to append (if not yet)- Returns:
- String with guaranteed suffix
-
ensureLeading
Ensures that string starts with specified symbol- Parameters:
value
- string value to ensureprefix
- prefix to append (if not yet)- Returns:
- String with guaranteed prefix
-
toString
Loads stream contents to the stream- Parameters:
stream
-InputStream
to load- Returns:
- String presentation of the input stream
- Throws:
IOException
-
toString
Load string from reader- Parameters:
reader
- Source reader- Returns:
- String that contains all information from the specified reader
-
toString
Prints out a map with key value pairs combined with '=' separated by ',' and surrounded by { and }- Parameters:
map
- map to be printed- Returns:
- String representation of map
-
toString
Prints out a map with key value pairs combined with '=' separated by ',' and surrounded by { and }- Parameters:
map
- map to be printed- Returns:
- String representation of map
-
toString
To string an array of objects separated by ',' and surrounded by '[' and ']'.- Parameters:
array
- array to be printed- Returns:
- String representation of object array
-
toString
ToString object- Parameters:
object
- object to be printed- Returns:
- string representation of object
-
toString
Convert array to single string presentation for debugging purposes- Parameters:
array
- Source string array- Returns:
- String presentation of the array
-
toString
ConvertCollection
of object to single string for debugging purposes- Parameters:
collection
- Source data collectionlineSeperator
- Line separator to use- Returns:
- Single string presentation of the specified
Collection
-
toString
Convert array of strings to single string presentation for debug purposes- Parameters:
array
- Source array of stringslineSeparator
- Line separator to delimit items- Returns:
- Single string array presentation
-
replaceHiAsciChars
Strips out the hi ascii chars (>127) and replaces them with a replacement char- Parameters:
orig
- Original stringreplacementChar
- Replacement character to use- Returns:
- Original string with all chars higher than 127 replaced with replacement char
-
replaceChars
Replaces all chars with the replacement char- Parameters:
orig
- Original stringchars
- Characters we want to replacereplace
- Replacement character- Returns:
- Modified original string with all chars replaced with replacement character
-
replaceChars
Replaces all chars with the replacement char- Parameters:
orig
- Original stringchars
- Characters we want to replacereplace
- Replacement character- Returns:
- Modified original string with all chars replaced with replacement character
-
toBoolean
Converts string to boolean. The difference is that is understands "on" and "off" values as true and false respectively- Parameters:
value
- Source string value to convert- Returns:
- true or false depending on string content. If string is empty - false is returned
-
wrap
Wrap string value with prefix and postfix. Result looks as follows:result := prefix + value + postfix
- Parameters:
value
- Source string value to wrapprefix
- Prefix to usepostfix
- Postfix to use- Returns:
- Original string with specified prefix and postfix
-
unwrap
Unwraps string using selected prefix and postfix- Parameters:
value
- Previously wrapped stringprefix
- Prefix to usepostfix
- Postfix to use- Returns:
- Original value used inside
wrap(java.lang.String, java.lang.String, java.lang.String)
call - See Also:
-
truncate
Truncates input string to the specified size- Parameters:
value
- Source string to analyzemaxLength
- Maximum string length- Returns:
- Source string truncated using specified size
-
truncateArray
Truncate array of strings using specified list of lengths (actions). Sample usage:String[] values = new String[] { "one", "Some reallllllllllllllllllllly big value", "Anotherrrrrrrrrrrrrrrrrrrrrrrrrrrr big value" }; int[] actions = new int[] { NO_ACTION // See
In this sample 1st element of the values will be left unchanged, but all others will be truncated using 20 as a string length limitNO_ACTION
20, 20 }; StringTools.truncateArray(values, actions);- Parameters:
values
- Original array of stringsactions
- Lengths(actions) to be taken over string values- See Also:
-
isFloat
Checks whether specified value convertable to float- Parameters:
value
-- Returns:
- True if value converts and False otherwise
-
toCsv
ConvertList
of strings to comma-separated string- Parameters:
strings
- Original strings container- Returns:
- Comma-separated list of values taken from original container
-
toCsv
Convert array of strings to comma-separated string- Parameters:
array
- Original strings container- Returns:
- Comma-separated list of values
-
toCsv
Convert array of objects to comma-separated string using the toString() method to retrieve the value for each entry.- Parameters:
array
- Original strings container- Returns:
- Comma-separated list of values
-
toCsv
Convert array of int to comma-separated string- Parameters:
array
- Original int container- Returns:
- Comma-separated list of values
-
toCsv
Convert array of short to comma-separated string- Parameters:
array
- Original short container- Returns:
- Comma-separated list of values
-
toCsv
Convert array of long to comma-separated string- Parameters:
array
- Original long container- Returns:
- Comma-separated list of values
-
toCsv
Convert array of boolean to comma-separated string- Parameters:
array
- Original boolean container- Returns:
- Comma-separated list of values
-
toCsv
Convert array of float to comma-separated string- Parameters:
array
- Original float container- Returns:
- Comma-separated list of values
-
toCsv
Convert array of double to comma-separated string- Parameters:
array
- Original double container- Returns:
- Comma-separated list of values
-
toCsv
Convert array of byte to comma-separated string- Parameters:
array
- Original byte container- Returns:
- Comma-separated list of values
-
getIntArrayFromCsv
Parses csv string and returns array of ints as a result of parsing. Of course this appliable only when you do know that string contains integers- Parameters:
data
- Original data to parse- Returns:
- array of integers
-
getShortArrayFromCsv
Parses csv string and returns array of short as a result of parsing. Of course this appliable only when you do know that string contains shorts- Parameters:
data
- Original data to parse- Returns:
- array of integers
-
getLongArrayFromCsv
Parses csv string and returns array of long as a result of parsing. Of course this appliable only when you do know that string contains longs- Parameters:
data
- Original data to parse- Returns:
- array of integers
-
getFloatArrayFromCsv
Parses csv string and returns array of float as a result of parsing. Of course this appliable only when you do know that string contains floats- Parameters:
data
- Original data to parse- Returns:
- array of integers
-
getDoubleArrayFromCsv
Parses csv string and returns array of double as a result of parsing. Of course this appliable only when you do know that string contains doubles- Parameters:
data
- Original data to parse- Returns:
- array of integers
-
getBooleanArrayFromCsv
Parses csv string and returns array of boolean as a result of parsing. Of course this appliable only when you do know that string contains booleans- Parameters:
data
- Original data to parse- Returns:
- array of integers
-
getByteArrayFromCsv
Parses csv string and returns array of boolean as a result of parsing. Of course this appliable only when you do know that string contains booleans- Parameters:
data
- Original data to parse- Returns:
- array of integers
-
csvToSet
Convert comma-separated line toSet
of strings. This is especially useful when you do know that line can convert duplicates and you don't want to deal with them.- Parameters:
csvLine
- Original comma-separated line- Returns:
- Set of values represented in the comma-separated line
-
concat
Fast 2 string concatenation usingStringBuffer
.- Parameters:
s1
- source string #1s2
- source string #2- Returns:
- 2 strings concatenated
-
concat
Fast 3 strings concatenation usingStringBuffer
- Parameters:
s1
- source string #1s2
- source string #2s3
- source string #3- Returns:
- 3 strings concatenated
-
concat
Fast 4 string concatenation usingStringBuffer
- Parameters:
s1
- source string #1s2
- source string #2s3
- source string #3s4
- source string #4- Returns:
- 4 strings concatenated
-
fastParseLong
Fast implementation ofLong.parseLong(java.lang.String, int)
- It assumes that it parses decimal radix number
- It doesn't not check Long constraints
- It doesn't handle unicode string
- Parameters:
str
- string to convert- Returns:
- long value obtained as a result of string conversion
- Throws:
NumberFormatException
-
getDelimitedList
GetArrayList
of tokens from delimited original string- Parameters:
value
- Original string valuedelims
- Delimiters used to make tokens- Returns:
- list of tokens produced as a result of string parsing
-
getDelimitedList
GetArrayList
of tokens from delimited original string- Parameters:
value
- Original string valuedelims
- Delimiters used to make tokens- Returns:
- list of tokens produced as a result of string parsing
-
charStr
Creates a string consisting of the given character- Parameters:
character
- original charactercount
- length of the string to construct- Returns:
- String containing count characters
-
tabStr
Return string containing the specified quantity of '\t' character- Parameters:
count
- Quantity of tabs you want to recieve- Returns:
- String containing the given quantity of TAB characters
- See Also:
-
isEmpty
Checks whether one of the 2 strings is empty- Parameters:
s1
- source string #1s2
- source string #2- Returns:
- True, if one of the strings are empty, False - otherwise
-
notEmpty
Checks that 2 strings are not empty- Parameters:
s1
- string to check #1s2
- string to check #2- Returns:
- True, if both strings are not empty, False - otherwise
-
notNulls
Checks that 2 strings are not nulls- Parameters:
value1
- source string #1value2
- source string #2- Returns:
- True, if both strings are not nulls, False - otherwise
-
removeChars
Replaces all chars with the replacement char- Parameters:
orig
- Original stringchars
- Chars to remove- Returns:
- Original string with all specified characters removed
-
isFormatCharsOnly
Verifies that string contains only formatting characters- Parameters:
value
- Original string- Returns:
- True, if string contains only '\t\n' characters, False otherwise
-
replaceParams
Replace placeholders, or parameters, in a string that are of the format %[number].Example: Calling on string "Error locating resource %0 for user %1" with array {"root", "admin"} would result in "Error locating resource root for user admin"
- Parameters:
source
- a string with parameters, starting with 0params
- the values for the parameters, the index corresponding to the parameter value + 1- Returns:
- the string with the values in place
-
trimString
Trims specified characters from the beginning and end of the string- Parameters:
s
-charsToTrim
-
-
capitalizeName
Capitalizes name string -
humanizeName
Converts identifiers like "myJavaCompliantName123" into "My Java Compliant Name 123"- Parameters:
name
- the value to humanize- Returns:
- the humanized value
-
lowerCaseFirstChar
Lower cases first character of a string- Parameters:
s
- null or String- Returns:
- s with lowercase first character
-
upperCaseFirstChar
Capilizes first character of a string- Parameters:
s
- null or String- Returns:
- s with a capital first character
-
getStackTrace
Utility function to recieve exception stack trace as a string- Parameters:
t
- Throwable to work with- Returns:
- Throwable stack trace as a String
-
loadStringfromStream
Loads and return string from anInputStream
- Returns:
- All contents of the file as one string
- Throws:
IOException
- in case of any I/O error
-
loadStringFromReader
Loads and return string from a reader. HACK is used to speed-up string getting fromStringAccessReader
- Parameters:
reader
- Source reader- Returns:
- String contents of the reader
- Throws:
IOException
- See Also:
-
StringAccessReader
-
padLeft
-
isEmptyString
Verifies whether passed string is a String or String[] and whether empty or not.- Parameters:
str
- Source string to analyze- Returns:
- True, if string is empty, False - otherwise
-
getFullStackTrace
Utility function to construct full exception stack trace information. This is useful when you are dealing with nested exceptions what can contain many levels of stack traces inside- Parameters:
t
- Throwable to analyze- Returns:
- String stack trace representation
-
checkValueForControlCharacters
-