Class PrepareString

java.lang.Object
com.ubs.backend.util.PrepareString

public class PrepareString extends Object
A utility class to prepare Strings
Since:
19.07.2021
Author:
Marc Andri Fuchs, Tim Irmler
  • Constructor Details

    • PrepareString

      public PrepareString()
  • Method Details

    • prepareString

      public static String prepareString(String string, int maxStringLength, boolean removeAllSpecialChars, boolean toLowerCase, boolean removeQuestionMark)
      method to prepare and clean a string
      Parameters:
      string - the string that will be prepared
      maxStringLength - defines the maximum length of the string, if the string is longer than the max, the method will only return as many characters as described by maxStringLength
      removeAllSpecialChars - should special characters be removed?
      toLowerCase - should the string be to lower case?
      removeQuestionMark - should question mark be removed from the string?
      Returns:
      the prepared string
      Since:
      19.08.2021
    • prepareString

      public static String prepareString(String string, int maxStringLength, boolean removeAllSpecialChars, boolean toLowerCase)
      Method to replace all unwanted characters in a String.
      Parameters:
      string - the target String
      maxStringLength - the maximum length of the string
      removeAllSpecialChars - is the string something a normal user (in the chatbot for example) has sent? if so we might want to handle it special and escape more/different stuff
      toLowerCase - should the string be lower case?
      Returns:
      the prepared String
      Since:
      17.07.2021
    • shortenString

      public static String shortenString(String s, int maxStringLength)
      Shortens a String to a defined max length
      Parameters:
      s - the String which should be shortened
      maxStringLength - the max length for the String
      Returns:
      the shortened String
    • stringTooLong

      public static boolean stringTooLong(String s, int maxStringLength)
      checks if a String is too long
      Parameters:
      s - the String which will be checked
      maxStringLength - the max length for the String
      Returns:
      true if too long, false if smaller or equal.