Class StringUtil
java.lang.Object
org.uitnet.testing.smartfwk.ui.core.utils.StringUtil
public class StringUtil extends Object
- Author:
- Madhav Krishna
-
Method Summary
Modifier and Type Method Description static booleancontainsText(String str, String text)Checks whether the text exist in string or not.static booleancontainsWord(String str, String word)Checks whether a word present in a string.static booleanendsWithText(String str, String text)Checks if string ends with a text.static intindexOfExpectedValue(String text, String expectedValue, TextMatchMechanism textMatchMechanism)static booleanisEmptyAfterTrim(String str)static booleanisEmptyNoTrim(String str)static booleanisTextMatchedWithExpectedValue(String text, String expectedValue, TextMatchMechanism textMatchMechanism)Checks whether the text matches with expected value based on text match mechanism.static voidmain(String[] args)static StringremoveItemsFromText(String text, String itemSeparator, String... itemsToRemove)static booleanstartsWithText(String str, String text)Checks if the string starts with text.static Stringsubstring(String str, int startIndex, int maxCharsToExtract)Used to return substring starting from startIndex until max characters are extracted.static Stringsubstring(String str, String startToken, String endToken)Extract the text from the startToken and endToken.static Stringtrim(String str)Trims the leading and trailing spacesstatic StringtrimNullAsEmpty(String str)static StringtrimNullObjAsEmptyStr(Object obj)static voidvalidateAtLeastNKeywordPresent(String text, int atLeastN, boolean inOrder, String... keyWords)
-
Method Details
-
trim
Trims the leading and trailing spaces- Parameters:
str-- Returns:
-
trimNullAsEmpty
-
isEmptyAfterTrim
-
isEmptyNoTrim
-
trimNullObjAsEmptyStr
-
containsText
Checks whether the text exist in string or not.- Parameters:
str-text-- Returns:
-
startsWithText
Checks if the string starts with text.- Parameters:
str-text-- Returns:
-
endsWithText
Checks if string ends with a text.- Parameters:
str-text-- Returns:
-
containsWord
Checks whether a word present in a string.- Parameters:
str-word-- Returns:
-
isTextMatchedWithExpectedValue
public static boolean isTextMatchedWithExpectedValue(String text, String expectedValue, TextMatchMechanism textMatchMechanism)Checks whether the text matches with expected value based on text match mechanism.- Parameters:
actualValue-expectedValue-textMatchMechanism-- Returns:
- if matches then returns true else returns false.
-
indexOfExpectedValue
public static int indexOfExpectedValue(String text, String expectedValue, TextMatchMechanism textMatchMechanism)- Parameters:
text-expectedValue-textMatchMechanism-- Returns:
- the index of expected value in text. -1 is returned when value is not matched.
-
removeItemsFromText
-
validateAtLeastNKeywordPresent
-
substring
Used to return substring starting from startIndex until max characters are extracted. If max chars are not available then it will just return the available characters startIndex onwards.- Parameters:
str-startIndex-maxCharsToExtract-- Returns:
-
substring
Extract the text from the startToken and endToken.- Parameters:
str- - string from where the text to be extracted.startToken- - startTokenendToken- - endToken.- Returns:
-
main
-