psdi.util

Class StringUtility

  • java.lang.Object
    • psdi.util.StringUtility


  • public class StringUtility
    extends java.lang.Object
    String Utility functions
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static char quote 
    • Constructor Summary

      Constructors 
      Constructor and Description
      StringUtility() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.String blankBetweenParenthesis(java.lang.String statement) 
      static java.lang.String blankQuotes(java.lang.String strWithQuotes)
      This method creates a copy of the string where the contents of quoted strings are replaced by X's, so searches can be done while ignoring what's quoted.
      static java.lang.String createCommaString(java.util.Collection items)
      Returns elements of the list separated by commas.
      static java.lang.String createCommaString(java.lang.String[] items)
      Returns elements of the list separated by commas.
      static java.lang.String createCommaStringQuoted(java.util.Collection items)
      Returns elements of the list contained by single quotes and separated by commas.
      static java.lang.String createCommaStringQuoted(java.lang.String[] items)
      Returns elements of the array contained by single quotes and separated by commas.
      static java.lang.String createListString(java.lang.String separator, java.lang.String[] items)
      Returns items as a string with the the given separator.
      static java.lang.String delimit(java.util.List clauses, java.lang.String delimiter)
      Combine the elements of the array with the delimiter given.
      static java.lang.String delimit(java.lang.String[] keys, java.lang.String delimiter)
      Combine the elements of the array with the delimiter given.
      static java.lang.String generateNextName(java.lang.String modifyablePreifx, java.lang.String suffix, int maxLength) 
      static java.lang.Long getCRC(java.lang.String input)
      Get the CRC32 value for a string.
      static boolean isAsciiEncoded(java.lang.String str)
      Returns true if string can be ASCII encoded.
      static boolean isEmpty(java.lang.String str)
      Determine if the string has any characters.
      static java.lang.String removePercentSigns(java.lang.String inStr)
      This method removes percent signs from a string and was adapted from psdi.webclient.system.controller.UploadFile for APAR IJ42049 so that email listener received message attachments are treated consistently with attachments via the UI.
      static java.lang.String replaceAll(java.lang.String template, java.lang.Object[] tokenValuePairs) 
      static java.lang.String replaceSQLStringToken(java.lang.String sql, java.lang.String[][] pairs)
      Replace tokens in a SQL string with properly quoted string constants.
      static java.lang.String singleToDoubleQuotes(java.lang.String in)
      Scan input string to see if it contains any single quotes, and replace any single quote with two single quotes.
      static java.lang.String[] splitCSV(java.lang.String line)
      Split a line from a CSV file.
      static boolean stringsEqual(java.lang.String str, java.lang.String rts)
      Compare two strings where one or both of the strings may be null.
      static java.lang.String toUpperCase(java.lang.String str)
      Uppercases a string if it is not null.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringUtility

        public StringUtility()
    • Method Detail

      • createCommaString

        public static java.lang.String createCommaString(java.util.Collection items)
        Returns elements of the list separated by commas.
        Parameters:
        items -
        Returns:
        The items, joined by commas. If the list is empty, this will return the empty string.
      • createListString

        public static java.lang.String createListString(java.lang.String separator,
                                                        java.lang.String[] items)
        Returns items as a string with the the given separator.
        Returns:
        The items in a string delimited by the separator, or the empty string if there are no items.
      • createCommaString

        public static java.lang.String createCommaString(java.lang.String[] items)
        Returns elements of the list separated by commas.
        Parameters:
        items -
        Returns:
        The items, joined by commas. If the list is empty, this will return the empty string.
      • isEmpty

        public static boolean isEmpty(java.lang.String str)
        Determine if the string has any characters. Whitespace is ignored.
        Parameters:
        str - The String to check
        Returns:
        True if the string is empty or if a null is passed.
      • blankQuotes

        public static java.lang.String blankQuotes(java.lang.String strWithQuotes)
        This method creates a copy of the string where the contents of quoted strings are replaced by X's, so searches can be done while ignoring what's quoted.
        Parameters:
        strWithQuotes -
        Returns:
      • stringsEqual

        public static boolean stringsEqual(java.lang.String str,
                                           java.lang.String rts)
        Compare two strings where one or both of the strings may be null.
        Parameters:
        str -
        rts -
        Returns:
        true if the strings match, or if both parameters are null.
      • createCommaStringQuoted

        public static java.lang.String createCommaStringQuoted(java.lang.String[] items)
        Returns elements of the array contained by single quotes and separated by commas.
        Parameters:
        items -
        Returns:
        The items, quoted and joined by commas. If the array is empty, this will return the empty string.
      • createCommaStringQuoted

        public static java.lang.String createCommaStringQuoted(java.util.Collection items)
        Returns elements of the list contained by single quotes and separated by commas.
        Parameters:
        items -
        Returns:
        The items, quoted and joined by commas. If the list is empty, this will return the empty string.
      • isAsciiEncoded

        public static boolean isAsciiEncoded(java.lang.String str)
        Returns true if string can be ASCII encoded.
        Parameters:
        string -
        Returns:
        true if ASCII encoded
      • toUpperCase

        public static java.lang.String toUpperCase(java.lang.String str)
        Uppercases a string if it is not null.
      • delimit

        public static java.lang.String delimit(java.lang.String[] keys,
                                               java.lang.String delimiter)
        Combine the elements of the array with the delimiter given.
        Parameters:
        keys -
        delimiter - put between the keys.
        Returns:
        The delimited string. If keys is empty then the empty string is returned.
      • delimit

        public static java.lang.String delimit(java.util.List clauses,
                                               java.lang.String delimiter)
        Combine the elements of the array with the delimiter given.
        Parameters:
        keys -
        delimiter - put between the keys.
        Returns:
        The delimited string. If keys is empty then the empty string is returned.
      • singleToDoubleQuotes

        public static java.lang.String singleToDoubleQuotes(java.lang.String in)
        Scan input string to see if it contains any single quotes, and replace any single quote with two single quotes. This is used when creating a SQL statement with a value that contains single quotes.
        Parameters:
        in - The value to be analyzed.
        Returns:
        The input value with any single quotes replaced by two single quotes.
      • blankBetweenParenthesis

        public static java.lang.String blankBetweenParenthesis(java.lang.String statement)
      • replaceSQLStringToken

        public static java.lang.String replaceSQLStringToken(java.lang.String sql,
                                                             java.lang.String[][] pairs)
        Replace tokens in a SQL string with properly quoted string constants. If the replace string constant has internal single quotes, they will be doubled.
        Parameters:
        sql - The SQL string to modify
        pairs - Size 2 String arrays with token name and replacement value.
        Returns:
        The modified SQL.
      • getCRC

        public static java.lang.Long getCRC(java.lang.String input)
        Get the CRC32 value for a string.
        Parameters:
        input -
        Returns:
      • splitCSV

        public static java.lang.String[] splitCSV(java.lang.String line)
        Split a line from a CSV file.
        Parameters:
        line -
        Returns:
        The columns of data. An empty array will be return if the line is blank or there are no values.
      • replaceAll

        public static java.lang.String replaceAll(java.lang.String template,
                                                  java.lang.Object[] tokenValuePairs)
      • generateNextName

        public static java.lang.String generateNextName(java.lang.String modifyablePreifx,
                                                        java.lang.String suffix,
                                                        int maxLength)
      • removePercentSigns

        public static java.lang.String removePercentSigns(java.lang.String inStr)
        This method removes percent signs from a string and was adapted from psdi.webclient.system.controller.UploadFile for APAR IJ42049 so that email listener received message attachments are treated consistently with attachments via the UI.
        Parameters:
        inStr -
        Returns:
        Remove percent signs from a string Method