Package com.ubs.backend.util
Class PrepareString
java.lang.Object
com.ubs.backend.util.PrepareString
A utility class to prepare Strings
- Since:
- 19.07.2021
- Author:
- Marc Andri Fuchs, Tim Irmler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringprepareString(String string, int maxStringLength, boolean removeAllSpecialChars, boolean toLowerCase)Method to replace all unwanted characters in a String.static StringprepareString(String string, int maxStringLength, boolean removeAllSpecialChars, boolean toLowerCase, boolean removeQuestionMark)method to prepare and clean a stringstatic StringshortenString(String s, int maxStringLength)Shortens a String to a defined max lengthstatic booleanstringTooLong(String s, int maxStringLength)checks if a String is too long
-
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 preparedmaxStringLength- 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 maxStringLengthremoveAllSpecialChars- 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 StringmaxStringLength- the maximum length of the stringremoveAllSpecialChars- 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 stufftoLowerCase- should the string be lower case?- Returns:
- the prepared String
- Since:
- 17.07.2021
-
shortenString
Shortens a String to a defined max length- Parameters:
s- the String which should be shortenedmaxStringLength- the max length for the String- Returns:
- the shortened String
-
stringTooLong
checks if a String is too long- Parameters:
s- the String which will be checkedmaxStringLength- the max length for the String- Returns:
- true if too long, false if smaller or equal.
-