Package com._1c.g5.v8.dt.common
Class StringUtils
java.lang.Object
com._1c.g5.v8.dt.common.StringUtils
Utils are responsible for basic operations with strings
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringcapitalize(String source) Sets the first character to the Upper casestatic StringdefaultIfBlank(String str, String defaultStr) Returns either the passedstrin String, or if thestris blank, empty ornull, the value ofdefaultStr.static booleanstatic 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 booleanIs empty stringstatic booleanChecks 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.processAmpersands(String string) Parses string with ampersands (if any) and returns modified string and position of first char that needs to be underlined.static Stringstatic <T extends CharSequence>
TrequireNonBlank(T cs) Checks that the specified char sequence is notblank.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 Details
-
EMPTY
- See Also:
-
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
isEmpty
Is empty string- Parameters:
str-- Returns:
- true if null or empty
-
isNotEmpty
Is not empty string- Parameters:
str-- Returns:
- true if string not null and not empty
-
isBlank
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
Checks whether string is not blank.- Parameters:
cs- the inputCharSequence, can benull- Returns:
trueif the string is not blank,falseotherwise.- See Also:
-
defaultIfBlank
Returns either the passedstrin String, or if thestris blank, empty ornull, the value ofdefaultStr.- Parameters:
str- the String to check, can benulldefaultStr- the default String to return if the input is blank, empty ornull, can benull- Returns:
- the passed
strin String, or the default, can benull
-
requireNonBlank
Checks that the specified char sequence is notblank. This method is designed primarily for doing parameter validation in methods and constructors, as demonstrated below:public Foo(String string) { this.string = StringUtils.requireNonBlank(string); }- Type Parameters:
T- the type of the char sequence.- Parameters:
cs- the char sequence to check- Returns:
csif notblank, nevernull.- Throws:
NullPointerException- ifcsisnull.IllegalArgumentException- ifcsis notnull, but isblank.
-
equalsTrimValues
Equals method for trimmed srings- Parameters:
str1-str2-- Returns:
- true if strings are equal
-
equals
-
uncapitalize
-
capitalize
Sets the first character to the Upper case- Parameters:
source- - the source string- Returns:
- the capitalized string
-
nameToText
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
-
removeExtension
-
fuzzyMatch
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:
-
fuzzyMatch
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:
-
trimDigitSuffix
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
Правильное имя свойства или метода контекста представляет собой строку ненулевой длины. Первый символ этой строки - буква или символ '_'. Все последующие символы должны быть буквами, десятичными цифрами или символами '_'- Parameters:
name- имя- Returns:
-
lowerCaseHashCode
Gets hashCode for lower case string.- Parameters:
str- the string.- Returns:
- a hashCode of lower case string.
-
stringAsRegEx
Escaped characters in string to use in regEx- Parameters:
pattern- - the input string (notnull)- Returns:
- an escaped string
-
processAmpersands
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
-