Class StringHelper
java.lang.Object
net.simplace.core.service.StringHelper
Static helper methods for string manipulation, parsing and formatting.
- Author:
- Andreas Enders
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classUnicode constants for special characters (mainly German umlauts). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarrayToList(Object[] aArray) Converts an array into an ArrayList.static StringarrayToString(String[] aSplit, String aSeparator) Joins the elements of an array with a separator.static <T> StringarrayToString(T[][] aSumOfCutValues, String aSeperator) Formats a matrix as text: values separated by the separator, each row ending with CR LF.static booleancontainsAnyCharacter(String aStringToCheck, String aCharactersToLookFor) Checks whether any of the characters in aCharactersToLookFor occurs in aStringToCheck.static booleancontainsProblematicCharacters(String aStringToCheck) Searches the given string for problematic characters (without checking for HTML entities).static booleancontainsProblematicCharacters(String aStringToCheck, boolean aAlsoCheckForHTMLEntity) Searches the given string for any of the characters< > $ " ' \ # %andStringHelper.UNICODE.EURO.static booleancontainsSpecialCharacters(String aStringToCheck) Searches the given string for special characters, i.e.static booleancontainsWebEuroSign(String aStringToCheck) Searches the given string for the Euro sign as it is transmitted via the browser, or its HTML entity.static booleancontainsWebEuroSign(String aStringToCheck, boolean aAlsoCheckForHTMLEntity) Searches the given string for the Euro sign as it is transmitted via the browser (FWFrameworkHelper.WEBEUROSIGN).static StringconvertEncoding(String aContent, String aInputEncoding, String aOutputEncoding) Re-interprets the bytes of a string in another encoding.static <T> TconvertFromString(String aValue, Class<? extends T> aType) Converts a string into an instance of a base type (string, character, number or boolean, also the primitive types).static StringconvertLineBreak(String aValue) Converts Windows line breaks (CR LF) to Unix line breaks (LF).static String[][]convertLinesToStringarray(Vector<String> aLinesVector, String aDivider) Splits lines into columns.convertStringToLines(String aString, Integer[] aLinesToRead) Splits a text into trimmed lines.static StringShortens a string to a maximum length, replacing the end with...if it is too long.static StringextractDigitsFromString(String aString) Removes every character that is not a digit 0-9.static StringfilterLineFeed(String aString) Replaces line feed characters with spaces.static StringfilterWhiteSpacesAndTabs(String aString) Replaces sequences of two or more white space characters (spaces, tabs, line breaks) with a single space.static Iterable<MatchResult> findMatches(String pattern, CharSequence s) Finds all matches of a regular expression in a character sequence.static StringBrings a string to a fixed length: longer strings are shortened with..., shorter strings are padded with spaces.static StringRemoves all tabs and surrounding white space (seeremoveCharacter(String, char)).static StringgetAfterDivider(String aString, String aDivider) Returns the part of a string after the last occurrence of a divider.static StringgetAfterFirstDivider(String aString, String aDivider) Returns the part of a string after the first occurrence of a divider.static StringgetBeforeDivider(String aString, String aDivider) Returns the part of a string before the first occurrence of a divider.static StringgetBeforeLastDivider(String aString, String aDivider) Returns the part of a string before the last occurrence of a divider.static final StringReturns the first characters of a string.static final StringgetInternationalisedString(String aInputString) Replaces German umlauts and sharp s by their ASCII transcriptions (e.g.static LinkedList<String> getListFromString(String aString, String aDivider) Splits a string into a list of trimmed tokens.static LinkedList<String> getListFromString(String aString, String aDivider, boolean doLeaveEmptyStringsOut, boolean doTrim) Splits a string into a list of tokens.static LongExtracts all digits of a string and parses them as long.getMapFromString(String aString, String aMapDivider, String aValueDevider) Parses a string like{key1=value1, key2=value2}into a map.getMatchesFromString(String aString, String aPattern) Returns all matches of a regular expression in a string.static final DecimalFormatgetNumberFormat(String aNumberString, int aLenthOfStirng) Creates a DecimalFormat matching a number string, i.e.static final StringReturns the last characters of a string.static StringgetTimeString(Long aTime) Formats a point in time as localized date and time (medium style, UTC).static StringgetTimeText(long aTime) Formats a duration ashh:mm:ss, e.g.static StringinsertLineBreaks(String aString, String aLineBreak, int aMaxLength, boolean aCountSpaces) Inserts line breaks into a string so that no line is longer than a maximum length.static booleanChecks whether a value is empty.static booleanChecks whether a string consists of digits only.static StringPrepares a text for a single log line: shortens it and replaces line breaks with following white space by a single space.static StringoutputToString(Map<String, ?> aMap) Formats a map as text with onekey : valueline per entry (for logging).static StringBuilds a string of a given length from a head, filler characters and a tail.static booleanparseBoolean(Object aString) Converts a value to a boolean, usingfalseas default.static BooleanparseBoolean(Object aObject, boolean aDefaultValue) Converts a value to a boolean.static LocalDateTimeparseDate(Object aParameterFromMap, LocalDateTime aDefaultValue) Converts a value to a date.static FloatparseFloatPart(String aLineString) Returns the first space separated word of a string that can be parsed as float.static IntegerparseIntegerPart(String aLineString) Returns the first space separated word of a string that can be parsed as integer.static Integer[]parseIntegerToArray(String aIndexString, boolean aConvertIndizes0To1) Parses an index list like1,3,5-8,10-into a sorted set of indices.parseParameters(String aInterceptorString, String aParameterDivider, String aBeginListDivider, String aEndListDivider) Extracts a parameter list from a string likename(a,b,c): takes the part between the begin and end divider and splits it.parseSeparatedListDouble(String aString, String aDivider) Splits a string and parses the elements as doubles.parseSeparatedListInteger(String aString, String aDivider) Splits a string and parses the elements as integers.parseSeparatedListString(String aString, String aDivider) Splits a string into trimmed elements.static StringremoveCharacter(String aString, char aChar) Removes all occurrences of a character from a string.static StringreplaceAll(String aString, Map aSubstitutionMap) Replaces all occurrences of each key of a map by its value (literally, in map iteration order).static StringreplaceHTMLEntities(String aHTML) Replaces German umlauts and sharp s by their HTML entities.static StringreplaceHTMLEntities(String aHTML, boolean aReplaceHTMLChars) Replaces German umlauts and sharp s by their HTML entities.static StringreplaceNullWithEmptyString(String aString) Replacesnullwith an empty string.static final StringreplacePlaceholder(String aDocument, String aPlaceholder, String aValue) Replaces all occurrences of a placeholder (e.g.static final StringBufferreplacePlaceholderAsBuffer(String aDocument, String aPlaceholder, String aValue) Replaces all occurrences of a placeholder (e.g.static StringreplaceTabulators(String aString, int aTabLength) Replaces tabulators by spaces, so that the following text starts at the next tab stop.static final StringreturnValidString(String aUncheckedString) Removes characters that may cause problems, e.g.static doubleround(double aValue, int aPlaces) Rounds a double to a number of decimal places (half up).static String[]splitBySize(String aStringToSplit, int i) Splits a string into chunks of a given size; the last chunk may be shorter.static LocalDateTime[]toDateArray(String aValueText) Parses a comma separated list of dates, optionally enclosed in braces or square brackets, e.g.static LocalDateTime[]toDateArray(String[] aValueText) Parses an array of date strings.static Double[]toDoubleArray(double[] aArray) Converts a primitive double array into a Double array.static Double[]toDoubleArray(int[] aArray) Converts a primitive int array into a Double array.static Double[]toDoubleArray(String aString) Parses an array string like{1.0,2.5,3}into doubles.static Double[]toDoubleArray(String[] aArray) Parses split array elements as doubles.static Double[][]toDoubleMatrix(String aValueText) Parses a matrix string like{{1,2},{3,4}}into doubles.static Double[][]toDoubleMatrix(String[][] aObject) Parses a matrix of strings row by row into doubles.static Integer[]toIntArray(int[] aArray) Converts a primitive int array into an Integer array.static Integer[]toIntArray(String aString) Parses an array string like{1,2,3}or[1,2,3]into integers.static Integer[]toIntArray(String[] aArray) Parses split array elements as integers.static String[]toStringArray(String aString) Parses an array string like{a,b,c}into strings.static StringtoStringForm(Double[] value) Formats an array as{v1,v2,...}.static StringtoStringForm(Double[][] matrix) Formats a matrix as{{v11,v12}{v21,v22}}(rows are not separated by commas).static StringtoStringForm(Integer[] value) Formats an array as{v1,v2,...}.static StringtoStringForm(String[] value) Formats an array as{v1,v2,...}.static ObjecttransformDataType(String aString, FWSimVariable<?> aVariable) Converts a string to the data type of a simulation variable.static StringunParseParameters(Collection<?> aElementCollection, String aParameterDivider) Joins the elements of a collection into a string.
-
Constructor Details
-
StringHelper
public StringHelper()
-
-
Method Details
-
arrayToList
-
convertLineBreak
-
convertEncoding
public static String convertEncoding(String aContent, String aInputEncoding, String aOutputEncoding) throws UnsupportedEncodingException Re-interprets the bytes of a string in another encoding. The string is converted to bytes with the platform default charset and decoded with the input encoding, then again with the output encoding. This can repair strings that were decoded with the wrong charset. Input and/or output encoding can be left empty ornullto skip that step.- Parameters:
aContent- string to convertaInputEncoding- charset for the first decoding step, or empty/nullaOutputEncoding- charset for the second decoding step, or empty/null- Returns:
- the converted string
- Throws:
UnsupportedEncodingException- if a charset is not supported
-
containsAnyCharacter
Checks whether any of the characters in aCharactersToLookFor occurs in aStringToCheck. Note that this method returns true if ANY single character in aCharactersToLookFor is contained in aStringToCheck.- Parameters:
aStringToCheck- string to be searchedaCharactersToLookFor- string containing the characters to look for in aStringToCheck- Returns:
trueif any of the characters is contained in aStringToCheck;falseif either string is empty ornull
-
extractDigitsFromString
-
filterLineFeed
-
filterWhiteSpacesAndTabs
-
getAfterDivider
Returns the part of a string after the last occurrence of a divider.- Parameters:
aString- string to splitaDivider- divider to search for- Returns:
- the part after the last divider, or the whole string if the divider does not occur
- See Also:
-
getAfterFirstDivider
Returns the part of a string after the first occurrence of a divider.- Parameters:
aString- string to splitaDivider- divider to search for- Returns:
- the part after the first divider, or the whole string if the divider does not occur
-
getBeforeDivider
Returns the part of a string before the first occurrence of a divider.- Parameters:
aString- string to splitaDivider- divider to search for- Returns:
- the part before the first divider, the whole string if the divider does not occur, or
nullif aString isnull
-
getBeforeLastDivider
Returns the part of a string before the last occurrence of a divider.- Parameters:
aString- string to splitaDivider- divider to search for- Returns:
- the part before the last divider, the whole string if the divider does not occur, or
nullif aString isnull
-
getHead
-
replacePlaceholder
Replaces all occurrences of a placeholder (e.g.$Example$) in a text with a value. The placeholder is matched literally, not as regular expression.- Parameters:
aDocument- text containing the placeholderaPlaceholder- placeholder to replaceaValue- replacement value; ifnull(e.g. an environment variable that is not set), the placeholder stays in the text- Returns:
- the resulting text, or
nullif aDocument isnull
-
replacePlaceholderAsBuffer
public static final StringBuffer replacePlaceholderAsBuffer(String aDocument, String aPlaceholder, String aValue) Replaces all occurrences of a placeholder (e.g.$Example$) in a text with a value and returns the result as StringBuffer.- Parameters:
aDocument- text containing the placeholderaPlaceholder- placeholder to replace; must not be emptyaValue- replacement value- Returns:
- the resulting text, or
nullif aDocument isnull
-
getInternationalisedString
-
getListFromString
Splits a string into a list of trimmed tokens. Empty tokens are kept.- Parameters:
aString- string to splitaDivider- divider; a single character is matched literally, a longer divider is used as regular expression- Returns:
- the tokens; empty if aString is
null - See Also:
-
getListFromString
public static LinkedList<String> getListFromString(String aString, String aDivider, boolean doLeaveEmptyStringsOut, boolean doTrim) Splits a string into a list of tokens.- Parameters:
aString- string to splitaDivider- divider; a single character is matched literally, a longer divider is used as regular expressiondoLeaveEmptyStringsOut- iftrue, empty tokens are skipped (after trimming, if doTrim is set)doTrim- iftrue, the tokens are trimmed- Returns:
- the tokens; empty if aString is
nullor the divider is empty
-
getMapFromString
public static Map<String,String> getMapFromString(String aString, String aMapDivider, String aValueDevider) Parses a string like{key1=value1, key2=value2}into a map. Surrounding curly braces are removed. Keys and values are not trimmed.- Parameters:
aString- string to parseaMapDivider- characters separating the entries (used as StringTokenizer delimiters)aValueDevider- divider between key and value; the key is the part before the first, the value the part after the last occurrence- Returns:
- map in the order of the entries; empty if aString is
null
-
getLong
Extracts all digits of a string and parses them as long. If there are more than 18 digits, only the first 18 are used (so the value always fits into a long).- Parameters:
aString- string to parse- Returns:
- the digits as long
- Throws:
NumberFormatException- if the string contains no digits
-
getMatchesFromString
-
getNumberFormat
Creates a DecimalFormat matching a number string, i.e. with the same number of decimal places and a total width of the given length. The number must use.as decimal separator.- Parameters:
aNumberString- example number, e.g.12.345aLenthOfStirng- total length of the formatted number; used to set the number of#characters- Returns:
- the number format, or
nullif aNumberString isnullor not a number
-
getTail
-
getTimeString
-
getTimeText
Formats a duration ashh:mm:ss, e.g.08:25:14.- Parameters:
aTime- duration in milliseconds- Returns:
- the formatted duration
-
insertLineBreaks
public static String insertLineBreaks(String aString, String aLineBreak, int aMaxLength, boolean aCountSpaces) Inserts line breaks into a string so that no line is longer than a maximum length. Existing line breaks reset the character count.- Parameters:
aString- the string in which the line breaks should be insertedaLineBreak- the line break string, e.g.<br>or\naMaxLength- maximum number of characters per lineaCountSpaces- iffalse, the character count is reset at each space, so only words longer than aMaxLength are broken- Returns:
- the string with inserted line breaks
-
isEmpty
Checks whether a value is empty. A value counts as empty if it isnull, a blank string, the string"null"orLocaleProvider.DEFAULT_EMPTY.- Parameters:
aValue- value to check- Returns:
trueif the value is empty
-
isNumber
Checks whether a string consists of digits only. An empty string counts as number.- Parameters:
aString- string to check- Returns:
trueif the string contains only the digits 0-9
-
outputToString
-
pad
Builds a string of a given length from a head, filler characters and a tail. Example:pad(6, '0', null, "14")results in"000014".- Parameters:
aStringLength- the length of the result stringaFiller- the character inserted between head and tailaHead- the start of the result string;nullis treated as emptyaTail- the end of the result string;nullis treated as empty- Returns:
- the padded string
- Throws:
IllegalArgumentException- if head and tail together are longer than the requested length
-
parseBoolean
Converts a value to a boolean, usingfalseas default.- Parameters:
aString- value to convert- Returns:
- the boolean value, or
falseif it cannot be determined - See Also:
-
parseDate
Converts a value to a date. Supported are LocalDateTime,FWFormattedDate, java.sql.Date, Timestamp,FWSimVariable(its value is used) and strings with at least 6 characters in a format understood byFWFormattedDate.- Parameters:
aParameterFromMap- value to convertaDefaultValue- value returned if the value isnull, of an unsupported type or cannot be parsed- Returns:
- the date, or aDefaultValue
-
parseBoolean
Converts a value to a boolean.- Integer: 1 →
true, 0 →false, -1 →null - Boolean: returned as is
- String (case insensitive):
true/1/yes/oui/ja/wahr→true,false/0/no/non/nein/falsch→false,null→null
- Parameters:
aObject- value to convertaDefaultValue- value returned fornull, unsupported types and unknown values- Returns:
- the boolean value,
null(see above) or aDefaultValue
- Integer: 1 →
-
parseParameters
public static List<String> parseParameters(String aInterceptorString, String aParameterDivider, String aBeginListDivider, String aEndListDivider) Extracts a parameter list from a string likename(a,b,c): takes the part between the begin and end divider and splits it.- Parameters:
aInterceptorString- string containing the parameter listaParameterDivider- divider between the parameters (regular expression)aBeginListDivider- divider before the list, e.g.(; the last occurrence is usedaEndListDivider- divider after the list, e.g.); the first occurrence after the begin divider is used- Returns:
- the trimmed parameters
- See Also:
-
parseSeparatedListDouble
Splits a string and parses the elements as doubles. Empty elements are skipped.- Parameters:
aString- string to splitaDivider- characters separating the elements (used as StringTokenizer delimiters)- Returns:
- the parsed values; empty if aString is
null - Throws:
NumberFormatException- if an element is not a number
-
removeCharacter
-
containsSpecialCharacters
Searches the given string for special characters, i.e. characters other than 0-9 a-z A-Z - _.- Parameters:
aStringToCheck- string to be searched for special characters- Returns:
trueif the string contains special characters;falseif it is empty
-
containsProblematicCharacters
Searches the given string for problematic characters (without checking for HTML entities).- Parameters:
aStringToCheck- string to be searched- Returns:
trueif the string contains problematic characters- See Also:
-
containsProblematicCharacters
public static boolean containsProblematicCharacters(String aStringToCheck, boolean aAlsoCheckForHTMLEntity) Searches the given string for any of the characters< > $ " ' \ # %andStringHelper.UNICODE.EURO.- Parameters:
aStringToCheck- string to be searchedaAlsoCheckForHTMLEntity- iftrue, the HTML entities< > " €are checked for as well- Returns:
trueif one of the characters is found;falsefornull
-
containsWebEuroSign
Searches the given string for the Euro sign as it is transmitted via the browser, or its HTML entity.- Parameters:
aStringToCheck- string to be searched- Returns:
trueif the string contains the Euro sign- See Also:
-
containsWebEuroSign
Searches the given string for the Euro sign as it is transmitted via the browser (FWFrameworkHelper.WEBEUROSIGN).- Parameters:
aStringToCheck- string to be searchedaAlsoCheckForHTMLEntity- iftrue, the HTML entity€is checked for as well- Returns:
trueif the string contains the Euro sign;falsefornull
-
cutString
-
findMatches
Finds all matches of a regular expression in a character sequence.- Parameters:
pattern- regular expressions- character sequence to search in- Returns:
- the match results in order of occurrence
-
replaceNullWithEmptyString
-
parseSeparatedListString
-
parseSeparatedListInteger
Splits a string and parses the elements as integers. Empty elements are skipped.- Parameters:
aString- string to splitaDivider- characters separating the elements (used as StringTokenizer delimiters)- Returns:
- the parsed values; empty if aString is
null - Throws:
NumberFormatException- if an element is not an integer
-
unParseParameters
Joins the elements of a collection into a string.nullelements become empty strings.- Parameters:
aElementCollection- elements to joinaParameterDivider- divider inserted between the elements- Returns:
- the joined string
-
replaceHTMLEntities
-
replaceHTMLEntities
Replaces German umlauts and sharp s by their HTML entities. Optionally, also HTML special characters and line breaks are converted.- Parameters:
aHTML- text to convertaReplaceHTMLChars- iftrue,& < > "and the Euro sign are replaced by entities and line breaks by<br>- Returns:
- the converted text;
nullor empty input is returned unchanged
-
replaceAll
Replaces all occurrences of each key of a map by its value (literally, in map iteration order). Entries with empty key ornullvalue are skipped.- Parameters:
aString- text to convertaSubstitutionMap- map from search string to replacement- Returns:
- the resulting text; aString unchanged if it or the map is
null
-
transformDataType
Converts a string to the data type of a simulation variable.- Parameters:
aString- string to convertaVariable- variable whose data type is used; its default value is used for unparsable dates- Returns:
- the converted value (Boolean, LocalDateTime, Double, Integer or an array), or aString for character data
- Throws:
NumberFormatException- if a numeric value cannot be parsed
-
toIntArray
-
toIntArray
Parses split array elements as integers. With a single element, surrounding square brackets are removed. With several elements, a leading empty element (from an opening{) is skipped and square brackets are removed, so{1,2,3},[1,2,3](split at{,}) and plain elements give the same values. Empty elements becomenull; other unparsable elements are logged and leftnull.- Parameters:
aArray- array elements as strings, e.g. the result of splitting{1,2,3}at{,}- Returns:
- the parsed values
-
toIntArray
Converts a primitive int array into an Integer array.- Parameters:
aArray- array to convert- Returns:
- the boxed values
-
toDoubleArray
-
toDateArray
Parses a comma separated list of dates, optionally enclosed in braces or square brackets, e.g.{01.01.2000,15.03.2000}; spaces around the dates are ignored, an empty list gives an empty array.- Parameters:
aValueText- comma separated dates in a format understood byFWFormattedDate- Returns:
- the parsed dates
- See Also:
-
toDateArray
Parses an array of date strings. Unparsable dates are logged.- Parameters:
aValueText- dates in a format understood byFWFormattedDate- Returns:
- the parsed dates
-
toDoubleMatrix
Parses a matrix string like{{1,2},{3,4}}into doubles. Rows are separated by}and{with any non-digit characters in between; values within a row by commas. Empty values becomenull.- Parameters:
aValueText- matrix string- Returns:
- the parsed matrix; rows may have different lengths
-
toDoubleArray
Parses split array elements as doubles. With a single element, surrounding square brackets are removed. With several elements, a leading empty element (from an opening{) is skipped. Empty elements becomenull; other unparsable elements are logged and leftnull.- Parameters:
aArray- array elements as strings- Returns:
- the parsed values, or
nullif aArray is empty
-
toDoubleArray
Converts a primitive int array into a Double array.- Parameters:
aArray- array to convert- Returns:
- the converted values
-
toDoubleArray
Converts a primitive double array into a Double array.- Parameters:
aArray- array to convert- Returns:
- the boxed values
-
toDoubleMatrix
-
toStringArray
Parses an array string like{a,b,c}into strings. The elements are trimmed and cleaned withreturnValidString(String).- Parameters:
aString- array string- Returns:
- the elements, or
nullif aString isnull
-
returnValidString
Removes characters that may cause problems, e.g. in file names or array strings:[ ] < > ? " | ! ^ ; + ', carriage returns, line feeds and tabs. Backslashes are replaced by slashes and double spaces by single spaces.If you add or remove characters, also change IOHelper.isValidFilename/getInvalidFilenameCharacters.
- Parameters:
aUncheckedString- string to clean- Returns:
- the cleaned string
-
toStringForm
-
toStringForm
-
toStringForm
-
toStringForm
-
fullTrim
Removes all tabs and surrounding white space (seeremoveCharacter(String, char)).- Parameters:
aBeforePart- string to trim- Returns:
- the trimmed string
-
splitBySize
-
parseIntegerPart
-
parseFloatPart
-
parseIntegerToArray
Parses an index list like1,3,5-8,10-into a sorted set of indices. Supported elements are single numbers, rangesa-b, open rangesa-(up to 99999) and, as the only element,first(0) orlast(99999).- Parameters:
aIndexString- comma separated index listaConvertIndizes0To1- iftrue, the given indices are 1-based and are converted to 0-based by subtracting 1- Returns:
- the sorted, distinct indices
-
fitString
Brings a string to a fixed length: longer strings are shortened with..., shorter strings are padded with spaces.nullis formatted as"null".- Parameters:
aUserName- string to fitaLength- target length; must be larger than 3- Returns:
- the fitted string
-
round
public static double round(double aValue, int aPlaces) Rounds a double to a number of decimal places (half up).- Parameters:
aValue- value to roundaPlaces- number of decimal places- Returns:
- the rounded value
- Throws:
IllegalArgumentException- if aPlaces is negative
-
arrayToString
Formats a matrix as text: values separated by the separator, each row ending with CR LF.- Type Parameters:
T- element type- Parameters:
aSumOfCutValues- matrix to formataSeperator- separator between the values; should be a single character, as the last one of each row is replaced by the line break- Returns:
- the formatted text
- Throws:
IOException- declared but never thrown
-
arrayToString
-
convertStringToLines
Splits a text into trimmed lines. CR LF, LF and CR line breaks are recognised. The lines are selected likeIOHelper.readLinesOfStream(java.io.InputStream, Integer[], String)does for files: the first line (header) is always returned, followed by the selected data lines.- Parameters:
aString- text to splitaLinesToRead- indices of the data lines to return after the header (the first data line has index 1), ornullfor all lines- Returns:
- the trimmed lines
-
convertLinesToStringarray
Splits lines into columns. Double quotes are removed and the values are trimmed. The number of columns is taken from the first line; surplus columns in later lines are logged.- Parameters:
aLinesVector- lines to splitaDivider- column divider (used as regular expression)- Returns:
- the values as rows and columns, or
nullif there are no lines
-
logFormat
Prepares a text for a single log line: shortens it and replaces line breaks with following white space by a single space.- Parameters:
aContent- text to format;nullis formatted asNULLaStringMaxLength- maximum length; must be larger than 3- Returns:
- the formatted text
-
convertFromString
Converts a string into an instance of a base type (string, character, number or boolean, also the primitive types).- Type Parameters:
T- the destination type- Parameters:
aValue- the stringaType- the destination type- Returns:
- the converted value; the string itself for
String;nullif the type is no base type or (for all types exceptString) the string isnullor empty - Throws:
NumberFormatException- if the string is not a valid number of the destination type
-
replaceTabulators
-