Interface StringFunctionsLocal


  • public interface StringFunctionsLocal
    String methods for data processing
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String MAPPED_NAME  
      static java.lang.CharSequence NEWLINE  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.String> base64decode​(java.util.List<java.lang.String> input)
      Base64 decode all input strings.
      java.util.List<java.lang.String> base64encode​(java.util.List<java.lang.String> input, int chunkSize)
      Base64 encode all input strings
      java.util.List<java.lang.String> capitalize​(java.util.List<java.lang.String> input)
      Capitalize strings, i.e.: convert all word starts to uppercase
      java.util.List<java.lang.String> defaultStringIfNoResult​(java.util.List<java.lang.String> in, java.lang.String defaultString)
      Returns a default string for each element in the input list, which is null resp.
      java.util.List<java.lang.String> emptyStringIfNoResult​(java.util.List<java.lang.String> in)
      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.
      java.util.List<java.lang.String> formatPrice​(java.util.List<java.lang.String> input, java.lang.String decimalPlaceCharacter, java.lang.String formatString)
      Format price with decimalPlaceCharacter and formatString using FormatUtils class.
      java.util.List<java.lang.String> htmlToPlainText​(java.util.List<java.lang.String> input)
      Convert HTML to plain text, i.e.
      java.util.List<java.lang.String> inverseMatch​(java.util.List<java.lang.String> input, java.lang.String pattern)
      Return strings that do NOT match the given regular expression
      java.util.List<java.lang.String> join​(java.util.List<java.lang.String> input, java.lang.String prefix, java.lang.String delimiter, java.lang.String suffix, int minimumElements)
      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
      java.util.List<java.lang.String> leftPad​(java.util.List<java.lang.String> input, int maxLength, java.lang.String pad, boolean truncate)
      Left pad a string up to a maximum length.
      java.util.List<java.lang.String> leftTrim​(java.util.List<java.lang.String> input)
      Trim whitespaces from start of all strings
      java.util.List<java.lang.String> lowercase​(java.util.List<java.lang.String> input)
      Turn all strings to lowercase
      java.util.List<java.lang.String> match​(java.util.List<java.lang.String> input, java.lang.String pattern)
      Return strings that match the given regular expression
      java.util.List<java.lang.String> md5​(java.util.List<java.lang.String> input)
      Calculate and return the md5 checksum for each string.
      java.util.List<java.lang.String> replace​(java.util.List<java.lang.String> input, java.lang.String search, java.lang.String replace)
      Replace all occurrences of String search by replace
      java.util.List<java.lang.String> replaceHtmlBreaks​(java.util.List<java.lang.String> input)
      Replace all HTML breaks by new lines
      java.util.List<java.lang.String> replaceRegEx​(java.util.List<java.lang.String> input, java.lang.String searchPattern, java.lang.String replace)
      Replace all occurrences of regular expression searchPattern by replace
      java.util.List<java.lang.String> reverse​(java.util.List<java.lang.String> input)
      Reverse strings
      java.util.List<java.lang.String> rightPad​(java.util.List<java.lang.String> input, int maxLength, java.lang.String pad, boolean truncate)
      Right pad a string up to a maximum length.
      java.util.List<java.lang.String> rightTrim​(java.util.List<java.lang.String> input)
      Trim whitespaces from end of all strings
      java.util.List<java.lang.String> sanitize​(java.util.List<java.lang.String> input)
      "Sanitize" strings, i.e.: remove double whitespaces remove all non-printable characters
      java.util.List<java.lang.String> smartTruncate​(java.util.List<java.lang.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).
      java.util.List<java.lang.String> split​(java.util.List<java.lang.String> input, java.lang.String prefix, java.lang.String delimiter, java.lang.String suffix, int minimumElements)
      Reverse function for join.
      java.util.List<java.lang.String> substring​(java.util.List<java.lang.String> input, int beginIndex, int endIndex)
      Calculate substrings.
      java.util.List<java.lang.String> trim​(java.util.List<java.lang.String> input)
      Trim whitespaces from start and end of all strings
      java.util.List<java.lang.String> truncate​(java.util.List<java.lang.String> input, int maxLength, int threshold)
      Truncate strings to the given maximum length.
      java.util.List<java.lang.String> uppercase​(java.util.List<java.lang.String> input)
      Turn all strings to uppercase
    • Field Detail

      • NEWLINE

        static final java.lang.CharSequence NEWLINE
    • Method Detail

      • base64decode

        java.util.List<java.lang.String> base64decode​(java.util.List<java.lang.String> input)
                                               throws PubServerException
        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

        java.util.List<java.lang.String> base64encode​(java.util.List<java.lang.String> input,
                                                      int chunkSize)
                                               throws PubServerException
        Base64 encode all input strings
        Parameters:
        input - result from query or previous functions in the processing chain
        chunkSize - Chunk size. Negative values including zero means: no chunks.
        Returns:
        the processed list
        Throws:
        PubServerException
      • capitalize

        java.util.List<java.lang.String> capitalize​(java.util.List<java.lang.String> input)
                                             throws PubServerException
        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

        java.util.List<java.lang.String> htmlToPlainText​(java.util.List<java.lang.String> input)
                                                  throws PubServerException
        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

        java.util.List<java.lang.String> inverseMatch​(java.util.List<java.lang.String> input,
                                                      java.lang.String pattern)
                                               throws PubServerException
        Return strings that do NOT match the given regular expression
        Parameters:
        input - result from query or previous functions in the processing chain
        pattern - inverse match strings against this regular expression
        Returns:
        the processed list
        Throws:
        PubServerException
      • join

        java.util.List<java.lang.String> join​(java.util.List<java.lang.String> input,
                                              java.lang.String prefix,
                                              java.lang.String delimiter,
                                              java.lang.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 chain
        prefix - prefix for first string
        delimiter - delimiter for each string except the last one
        suffix - suffix for last string
        minimumElements - 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

        java.util.List<java.lang.String> leftPad​(java.util.List<java.lang.String> input,
                                                 int maxLength,
                                                 java.lang.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 chain
        maxLength - maximum length
        pad - 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

        java.util.List<java.lang.String> leftTrim​(java.util.List<java.lang.String> input)
                                           throws PubServerException
        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

        java.util.List<java.lang.String> lowercase​(java.util.List<java.lang.String> input)
                                            throws PubServerException
        Turn all strings to lowercase
        Parameters:
        input - result from query or previous functions in the processing chain
        Returns:
        the processed list
        Throws:
        PubServerException
      • match

        java.util.List<java.lang.String> match​(java.util.List<java.lang.String> input,
                                               java.lang.String pattern)
                                        throws PubServerException
        Return strings that match the given regular expression
        Parameters:
        input - result from query or previous functions in the processing chain
        pattern - match strings against this regular expression
        Returns:
        the processed list
        Throws:
        PubServerException
      • md5

        java.util.List<java.lang.String> md5​(java.util.List<java.lang.String> input)
                                      throws PubServerException
        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

        java.util.List<java.lang.String> replace​(java.util.List<java.lang.String> input,
                                                 java.lang.String search,
                                                 java.lang.String replace)
                                          throws PubServerException
        Replace all occurrences of String search by replace
        Parameters:
        input - result from query or previous functions in the processing chain
        search - search string
        replace - replace string
        Returns:
        the processed list
        Throws:
        PubServerException
      • replaceHtmlBreaks

        java.util.List<java.lang.String> replaceHtmlBreaks​(java.util.List<java.lang.String> input)
                                                    throws PubServerException
        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

        java.util.List<java.lang.String> replaceRegEx​(java.util.List<java.lang.String> input,
                                                      java.lang.String searchPattern,
                                                      java.lang.String replace)
                                               throws PubServerException
        Replace all occurrences of regular expression searchPattern by replace
        Parameters:
        input - result from query or previous functions in the processing chain
        searchPattern - regular expression for search string
        replace - replace string
        Returns:
        the processed list
        Throws:
        PubServerException
      • reverse

        java.util.List<java.lang.String> reverse​(java.util.List<java.lang.String> input)
                                          throws PubServerException
        Reverse strings
        Parameters:
        input - result from query or previous functions in the processing chain
        Returns:
        the processed list
        Throws:
        PubServerException
      • rightPad

        java.util.List<java.lang.String> rightPad​(java.util.List<java.lang.String> input,
                                                  int maxLength,
                                                  java.lang.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 chain
        maxLength - maximum length
        pad - pad character or string. Default is whitespace
        truncate - truncate if input is longer. In this case, the string is truncated from RIGHT
        Returns:
        the processed list
        Throws:
        PubServerException
      • rightTrim

        java.util.List<java.lang.String> rightTrim​(java.util.List<java.lang.String> input)
                                            throws PubServerException
        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

        java.util.List<java.lang.String> sanitize​(java.util.List<java.lang.String> input)
                                           throws PubServerException
        "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

        java.util.List<java.lang.String> smartTruncate​(java.util.List<java.lang.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 chain
        maxLength - maximum length
        wordSafe - regard words and try to truncate at word ends
        threshold - threshold for truncation, -1 means no threshold
        Returns:
        the processed list
        Throws:
        PubServerException
      • split

        java.util.List<java.lang.String> split​(java.util.List<java.lang.String> input,
                                               java.lang.String prefix,
                                               java.lang.String delimiter,
                                               java.lang.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 chain
        prefix - prefix to strip from the first string
        delimiter - delimiter
        suffix - suffix to strip from the last string
        minimumElements - 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

        java.util.List<java.lang.String> substring​(java.util.List<java.lang.String> input,
                                                   int beginIndex,
                                                   int endIndex)
                                            throws PubServerException
        Calculate substrings.
        Parameters:
        input - result from query or previous functions in the processing chain
        beginIndex - begin index
        endIndex - end index. -1 means: to end of input string
        Returns:
        the processed list
        Throws:
        PubServerException
      • trim

        java.util.List<java.lang.String> trim​(java.util.List<java.lang.String> input)
                                       throws PubServerException
        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

        java.util.List<java.lang.String> truncate​(java.util.List<java.lang.String> input,
                                                  int maxLength,
                                                  int threshold)
                                           throws PubServerException
        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 chain
        maxLength - maximum length
        threshold - threshold for truncation, -1 means no threshold
        Returns:
        the processed list
        Throws:
        PubServerException
      • uppercase

        java.util.List<java.lang.String> uppercase​(java.util.List<java.lang.String> input)
                                            throws PubServerException
        Turn all strings to uppercase
        Parameters:
        input - result from query or previous functions in the processing chain
        Returns:
        the processed list
        Throws:
        PubServerException
      • formatPrice

        java.util.List<java.lang.String> formatPrice​(java.util.List<java.lang.String> input,
                                                     java.lang.String decimalPlaceCharacter,
                                                     java.lang.String formatString)
                                              throws PubServerException
        Format price with decimalPlaceCharacter and formatString using FormatUtils class.
        Parameters:
        input - result from query or previous functions in the processing chain
        decimalPlaceCharacter - 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

        java.util.List<java.lang.String> emptyStringIfNoResult​(java.util.List<java.lang.String> in)

        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

        java.util.List<java.lang.String> defaultStringIfNoResult​(java.util.List<java.lang.String> in,
                                                                 java.lang.String defaultString)

        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