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 String
capitalize
(String source) Sets the first character to the Upper casestatic String
defaultIfBlank
(String str, String defaultStr) Returns either the passedstr
in String, or if thestr
is blank, empty ornull
, the value ofdefaultStr
.static boolean
static boolean
equalsTrimValues
(String str1, String str2) Equals method for trimmed sringsstatic FuzzyPattern.Match
fuzzyMatch
(String pattern, String sample) Performs fuzzy match given the pattern and sample.static FuzzyPattern.Match
fuzzyMatch
(String pattern, String sample, boolean useMutation) Performs fuzzy match given the pattern and sample.static boolean
isBlank
(CharSequence cs) Checks whether the input string null, empty or contains only white space characters.static boolean
Is empty stringstatic boolean
Checks whether string is not blank.static boolean
isNotEmpty
(String str) Is not empty stringstatic boolean
isValidName
(String name) Правильное имя свойства или метода контекста представляет собой строку ненулевой длины.static int
lowerCaseHashCode
(String str) Gets hashCode for lower case string.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.processAmpersands
(String string) Parses string with ampersands (if any) and returns modified string and position of first char that needs to be underlined.static String
static <T extends CharSequence>
TrequireNonBlank
(T cs) Checks that the specified char sequence is notblank
.static String
stringAsRegEx
(String pattern) Escaped characters in string to use in regExstatic String
trimDigitSuffix
(String original) Gets the copy oforiginal
string with trailing digit removed.static String
uncapitalize
(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:
true
if the input stringnull
or empty or contains only white space characters,false
otherwise.
-
isNotBlank
Checks whether string is not blank.- Parameters:
cs
- the inputCharSequence
, can benull
- Returns:
true
if the string is not blank,false
otherwise.- See Also:
-
defaultIfBlank
Returns either the passedstr
in String, or if thestr
is blank, empty ornull
, the value ofdefaultStr
.- Parameters:
str
- the String to check, can benull
defaultStr
- the default String to return if the input is blank, empty ornull
, can benull
- Returns:
- the passed
str
in 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:
cs
if notblank
, nevernull
.- Throws:
NullPointerException
- ifcs
isnull
.IllegalArgumentException
- ifcs
is 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.NONE
if 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.NONE
if no match found, match describing the matched ranges otherwise, notnull
- See Also:
-
trimDigitSuffix
Gets the copy oforiginal
string with trailing digit removed.- Parameters:
original
- - a prototype- Returns:
- A copy of
original
string with trailing digit removed, ororiginal
string 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 benull
or empty- Returns:
- pair of result string and position of character that needs to be underlined in the result string,
never
null
-