Interface StringFunctionsLocal
public interface StringFunctionsLocal
String methods for data processing
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbase64decode(List<String> input) Base64 decode all input strings.base64encode(List<String> input, int chunkSize) Base64 encode all input stringscapitalize(List<String> input) Capitalize strings, i.e.: convert all word starts to uppercasedefaultStringIfNoResult(List<String> in, String defaultString) Returns a default string for each element in the input list, which is null resp.Returns an empty string for each element in the input list, which is null or a single empty string, if the input list is null or empty.formatPrice(List<String> input, String decimalPlaceCharacter, String formatString) Format price with decimalPlaceCharacter and formatString using FormatUtils class.htmlToPlainText(List<String> input) Convert HTML to plain text, i.e.inverseMatch(List<String> input, String pattern) Return strings that do NOT match the given regular expressionJoin strings from input list and return a single string containing all strings concatenated according to these instructions: insert prefix before the first string append delimiter to each string except the last one append suffix to the last string omit prefix and suffix if the input list contains less than minimum elementsLeft pad a string up to a maximum length.Trim whitespaces from start of all stringsTurn all strings to lowercaseReturn strings that match the given regular expressionCalculate and return the md5 checksum for each string.Replace all occurrences of String search by replacereplaceHtmlBreaks(List<String> input) Replace all HTML breaks by new linesreplaceRegEx(List<String> input, String searchPattern, String replace) Replace all occurrences of regular expression searchPattern by replaceReverse stringsRight pad a string up to a maximum length.Trim whitespaces from end of all strings"Sanitize" strings, i.e.: remove double whitespaces remove all non-printable characterssmartTruncate(List<String> input, int maxLength, boolean wordSafe, int threshold) Truncate strings to the given maximum length.
If the string is longer, append three dots at the end, so that the result string including the dots has a maximum length of maxLength characters.
If wordSafe is set to true, also try to truncate at word ends - unless this would result in a string shorter then (maxLength - threshold), in this case ignore the wordSafe option.
Regardless of the wordSafe option, the entire string is returned, if it's length doesn't exceed (maxLength+threshold).Reverse function for join.Calculate substrings.Trim whitespaces from start and end of all stringsTruncate strings to the given maximum length.Turn all strings to uppercase
-
Field Details
-
MAPPED_NAME
- See Also:
-
NEWLINE
-
-
Method Details
-
base64decode
Base64 decode all input strings. Chunked input will be detected and decoded also.- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
base64encode
Base64 encode all input strings- Parameters:
input- result from query or previous functions in the processing chainchunkSize- Chunk size. Negative values including zero means: no chunks.- Returns:
- the processed list
- Throws:
PubServerException
-
capitalize
Capitalize strings, i.e.: convert all word starts to uppercase- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
htmlToPlainText
Convert HTML to plain text, i.e.- replace all HTML breaks by new lines
- convert all numeric and named entities to their character equivalent
- strip all HTML tags
- strip all XML / HTML comments
- remove HTML declarations (e.g. <![CDATA...)
- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
inverseMatch
Return strings that do NOT match the given regular expression- Parameters:
input- result from query or previous functions in the processing chainpattern- inverse match strings against this regular expression- Returns:
- the processed list
- Throws:
PubServerException
-
join
List<String> join(List<String> input, String prefix, String delimiter, String suffix, int minimumElements) throws PubServerException Join strings from input list and return a single string containing all strings concatenated according to these instructions:- insert prefix before the first string
- append delimiter to each string except the last one
- append suffix to the last string
- omit prefix and suffix if the input list contains less than minimum elements
- Parameters:
input- result from query or previous functions in the processing chainprefix- prefix for first stringdelimiter- delimiter for each string except the last onesuffix- suffix for last stringminimumElements- omit prefix and suffix, if input contains less than minimumElements elements. 0 means: always include prefix and suffix- Returns:
- the processed list
- Throws:
PubServerException
-
leftPad
List<String> leftPad(List<String> input, int maxLength, String pad, boolean truncate) throws PubServerException Left pad a string up to a maximum length.- Parameters:
input- result from query or previous functions in the processing chainmaxLength- maximum lengthpad- pad character or string. Default is whitespace.truncate- truncate if input is longer. In this case, the string is truncated from LEFT- Returns:
- the processed list
- Throws:
PubServerException
-
leftTrim
Trim whitespaces from start of all strings- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
lowercase
Turn all strings to lowercase- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
match
Return strings that match the given regular expression- Parameters:
input- result from query or previous functions in the processing chainpattern- match strings against this regular expression- Returns:
- the processed list
- Throws:
PubServerException
-
md5
Calculate and return the md5 checksum for each string.- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
replace
Replace all occurrences of String search by replace- Parameters:
input- result from query or previous functions in the processing chainsearch- search stringreplace- replace string- Returns:
- the processed list
- Throws:
PubServerException
-
replaceHtmlBreaks
Replace all HTML breaks by new lines- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list of strings
- Throws:
PubServerException
-
replaceRegEx
List<String> replaceRegEx(List<String> input, String searchPattern, String replace) throws PubServerException Replace all occurrences of regular expression searchPattern by replace- Parameters:
input- result from query or previous functions in the processing chainsearchPattern- regular expression for search stringreplace- replace string- Returns:
- the processed list
- Throws:
PubServerException
-
reverse
Reverse strings- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
rightPad
List<String> rightPad(List<String> input, int maxLength, String pad, boolean truncate) throws PubServerException Right pad a string up to a maximum length.- Parameters:
input- result from query or previous functions in the processing chainmaxLength- maximum lengthpad- pad character or string. Default is whitespacetruncate- truncate if input is longer. In this case, the string is truncated from RIGHT- Returns:
- the processed list
- Throws:
PubServerException
-
rightTrim
Trim whitespaces from end of all strings- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
sanitize
"Sanitize" strings, i.e.:- remove double whitespaces
- remove all non-printable characters
- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
smartTruncate
List<String> smartTruncate(List<String> input, int maxLength, boolean wordSafe, int threshold) throws PubServerException Truncate strings to the given maximum length.
If the string is longer, append three dots at the end, so that the result string including the dots has a maximum length of maxLength characters.
If wordSafe is set to true, also try to truncate at word ends - unless this would result in a string shorter then (maxLength - threshold), in this case ignore the wordSafe option.
Regardless of the wordSafe option, the entire string is returned, if it's length doesn't exceed (maxLength+threshold).- Parameters:
input- Result from query or previous functions in the processing chainmaxLength- maximum lengthwordSafe- regard words and try to truncate at word endsthreshold- threshold for truncation, -1 means no threshold- Returns:
- the processed list
- Throws:
PubServerException
-
split
List<String> split(List<String> input, String prefix, String delimiter, String suffix, int minimumElements) throws PubServerException Reverse function for join. Split strings according to these instructions:- prefix to strip from the first string
- delimiter
- suffix to strip from the last string
- do not strip prefix and suffix if the result list contains less than minimum elements
- Parameters:
input- result from query or previous functions in the processing chainprefix- prefix to strip from the first stringdelimiter- delimitersuffix- suffix to strip from the last stringminimumElements- do not strip prefix and suffix, if the result list contains less than minimum elements. 0 means: always strip prefix and suffix.- Returns:
- the processed list
- Throws:
PubServerException
-
substring
Calculate substrings.- Parameters:
input- result from query or previous functions in the processing chainbeginIndex- begin indexendIndex- end index. -1 means: to end of input string- Returns:
- the processed list
- Throws:
PubServerException
-
trim
Trim whitespaces from start and end of all strings- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
truncate
Truncate strings to the given maximum length. If length of the input string doesn't exceed (maxLength + threshold) do not truncate.- Parameters:
input- result from query or previous functions in the processing chainmaxLength- maximum lengththreshold- threshold for truncation, -1 means no threshold- Returns:
- the processed list
- Throws:
PubServerException
-
uppercase
Turn all strings to uppercase- Parameters:
input- result from query or previous functions in the processing chain- Returns:
- the processed list
- Throws:
PubServerException
-
formatPrice
List<String> formatPrice(List<String> input, String decimalPlaceCharacter, String formatString) throws PubServerException Format price with decimalPlaceCharacter and formatString using FormatUtils class.- Parameters:
input- result from query or previous functions in the processing chaindecimalPlaceCharacter- It is needed for parsing the rawPrice string to find the position of the decimal character.
It can only be the single character dot (.) or comma (,).formatString- Defines how the price will be formatted.
To identify the decimalPlace the strings before the decimal is formatted with '#', the string after as '0' (e.g.: #.###.###,000 or #.00).
Allowed #-patterns (here shown with a dot as thousands separator) are: #, #.##, #.###, #.##.##, #.###.###
Allowed decimal separator: ",", "."
Allowed thousands separator: ",", ".", "'"
At the beginning or the end of the formatString are all known currency symbols and currency short texts allowed also, separated with or without a blank.- Returns:
- the processed list
- Throws:
PubServerException
-
emptyStringIfNoResult
Returns an empty string for each element in the input list, which is null or a single empty string, if the input list is null or empty.
Returns an empty string for each element in the input list, which is null or a single empty string, if the input list is null or empty.
Non empty and non null elements are added to the result list unchanged.- Parameters:
in- list of Strings from query or data mapping result- Returns:
- processed list as described above
-
defaultStringIfNoResult
Returns a default string for each element in the input list, which is null resp. empty a single default string, if the input list is null or empty.
Returns a default string for each element in the input list, which is null resp. empty or a single default string, if the input list is null or empty.
Non empty and non null elements are added to the result list unchanged.- Parameters:
in- list of Strings from query or data mapping result- Returns:
- processed list as described above
-