Package com._1c.g5.v8.dt.common
Class StringUtils
- java.lang.Object
-
- com._1c.g5.v8.dt.common.StringUtils
-
public class StringUtils extends Object
Utils are responsible for basic operations with strings
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStringUtils.RewriterAmatcher-based string rewriter.
-
Constructor Summary
Constructors Constructor Description StringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringcapitalize(String source)Sets the first character to the Upper casestatic booleanequals(String str1, String str2)static booleanequalsTrimValues(String str1, String str2)Equals method for trimmed sringsstatic FuzzyPattern.MatchfuzzyMatch(String pattern, String sample)Performs fuzzy match given the pattern and sample.static FuzzyPattern.MatchfuzzyMatch(String pattern, String sample, boolean useMutation)Performs fuzzy match given the pattern and sample.static booleanisBlank(CharSequence cs)Checks whether the input string null, empty or contains only white space characters.static booleanisEmpty(String str)Is empty stringstatic booleanisNotBlank(CharSequence cs)Checks whether string is not blank.static booleanisNotEmpty(String str)Is not empty stringstatic booleanisValidName(String name)Правильное имя свойства или метода контекста представляет собой строку ненулевой длины.static intlowerCaseHashCode(String str)Gets hashCode for lower case string.static StringnameToText(String nameInput)Converts passed name input string into text string using next rules: A set of underline symbols ('_') changes to one empty symbol (space, ' ') If this symbol is first or last, it will be omitted Three and more upper case letters are not modified.static Pair<String,Integer>processAmpersands(String string)Parses string with ampersands (if any) and returns modified string and position of first char that needs to be underlined.static StringremoveExtension(String s)static StringstringAsRegEx(String pattern)Escaped characters in string to use in regExstatic StringtrimDigitSuffix(String original)Gets the copy oforiginalstring with trailing digit removed.static Stringuncapitalize(String source)
-
-
-
Field Detail
-
EMPTY
public static final String EMPTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
isEmpty
public static boolean isEmpty(String str)
Is empty string- Parameters:
str-- Returns:
- true if null or empty
-
isNotEmpty
public static boolean isNotEmpty(String str)
Is not empty string- Parameters:
str-- Returns:
- true if string not null and not empty
-
isBlank
public static boolean isBlank(CharSequence cs)
Checks whether the input string null, empty or contains only white space characters.- Parameters:
cs- the inputCharSequence, can benull- Returns:
trueif the input stringnullor empty or contains only white space characters,falseotherwise.
-
isNotBlank
public static boolean isNotBlank(CharSequence cs)
Checks whether string is not blank.- Parameters:
cs- the inputCharSequence, can benull- Returns:
trueif the string is not blank,falseotherwise.- See Also:
isBlank(CharSequence)
-
equalsTrimValues
public static boolean equalsTrimValues(String str1, String str2)
Equals method for trimmed srings- Parameters:
str1-str2-- Returns:
- true if strings are equal
-
capitalize
public static String capitalize(String source)
Sets the first character to the Upper case- Parameters:
source- - the source string- Returns:
- the capitalized string
-
nameToText
public static String nameToText(String nameInput)
Converts passed name input string into text string using next rules:- A set of underline symbols ('_') changes to one empty symbol (space, ' ') If this symbol is first or last, it will be omitted
- Three and more upper case letters are not modified. Less than three upper case letters are placed in upper case if they are the last one in the string
- Before first upper case symbol, a space symbol is placed (only if there is no space before it)
- If there is a lower case or number symbol after one or two upper case symbols then upper case symbols are changed to lower case and there will be added a space symbol before them
- First character of a name is always in upper case
- Parameters:
nameInput- - name of the element- Returns:
- - text converted from name
-
fuzzyMatch
public static FuzzyPattern.Match fuzzyMatch(String pattern, String sample, boolean useMutation)
Performs fuzzy match given the pattern and sample.- Parameters:
pattern- pattern to match against, notnull.sample- sample to match, notnull.useMutation- use mutation (splitting) of pattern- Returns:
FuzzyPattern.Match.NONEif no match found, match describing the matched ranges otherwise, notnull.- See Also:
FuzzyPattern
-
fuzzyMatch
public static FuzzyPattern.Match fuzzyMatch(String pattern, String sample)
Performs fuzzy match given the pattern and sample.- Parameters:
pattern- pattern to match against, notnull.sample- sample to match, notnull.- Returns:
FuzzyPattern.Match.NONEif no match found, match describing the matched ranges otherwise, notnull- See Also:
FuzzyPattern
-
trimDigitSuffix
public static String trimDigitSuffix(String original)
Gets the copy oforiginalstring with trailing digit removed.- Parameters:
original- - a prototype- Returns:
- A copy of
originalstring with trailing digit removed, ororiginalstring if it has no trailing digit.
-
isValidName
public static boolean isValidName(String name)
Правильное имя свойства или метода контекста представляет собой строку ненулевой длины. Первый символ этой строки - буква или символ '_'. Все последующие символы должны быть буквами, десятичными цифрами или символами '_'- Parameters:
name- имя- Returns:
-
lowerCaseHashCode
public static int lowerCaseHashCode(String str)
Gets hashCode for lower case string.- Parameters:
str- the string.- Returns:
- a hashCode of lower case string.
-
stringAsRegEx
public static String stringAsRegEx(String pattern)
Escaped characters in string to use in regEx- Parameters:
pattern- - the input string (notnull)- Returns:
- an escaped string
-
processAmpersands
public static Pair<String,Integer> processAmpersands(String string)
Parses string with ampersands (if any) and returns modified string and position of first char that needs to be underlined.- Parameters:
string- original string, can benullor empty- Returns:
- pair of result string and position of character that needs to be underlined in the result string,
never
null
-
-