Class StringUtil
java.lang.Object
org.eclipse.net4j.util.StringUtil
Various static helper methods for dealing with strings.
- Author:
- Eike Stepper
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanappendSeparator(StringBuilder builder, char c) static booleanappendSeparator(StringBuilder builder, String str) static Stringstatic Stringstatic intstatic intcompareIgnoreCase(String s1, String s2) static Stringconvert(String str, IManagedContainer container) Converts expressions of the form$$$name(arguments)$$$using converters from the given container.static Stringconvert(String str, IManagedContainer container, Pattern pattern) Converts matches of the supplied pattern using the first two capture groups as the converter type and argument.static Stringcreate(char c, int length) static booleanequalsIgnoreCase(String s1, String s2) static booleanequalsUpperOrLowerCase(String s, String upperOrLowerCase) Deprecated.static Stringstatic Stringstatic Stringstatic booleanMatches a string against a pattern.static booleanMatches a string against a pattern and fills an array with the sub-matches.static booleanstatic booleanstatic booleanstatic intoccurrences(String str, char c) static intoccurrences(String str, String c) static <T> Tparse(String str, IManagedContainer container, Class<T> type) static <T> Tparse(String str, IManagedContainer container, Class<T> type, boolean enumCaseSensitive) static <E extends Enum<E>>
Estatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic voidstatic Stringstatic Stringstatic Stringstatic Stringstatic String
-
Field Details
-
EMPTY
- See Also:
-
NL
-
TRUE
- Since:
- 3.22
-
FALSE
- Since:
- 3.22
-
-
Method Details
-
create
- Since:
- 3.4
-
formatException
-
replace
-
replace
-
replace
-
tokenize
-
split
-
safe
-
safe
-
safe
-
safe
-
escape
-
escape
-
unescape
-
unescape
-
stripHTML
-
compare
-
compareIgnoreCase
-
equalsIgnoreCase
-
isTrue
- Since:
- 3.22
-
isFalse
- Since:
- 3.22
-
capAll
-
cap
-
uncapAll
-
uncap
-
occurrences
-
occurrences
-
translate
-
convert
Converts expressions of the form$$$name(arguments)$$$using converters from the given container. Nested expressions are evaluated from the inside out, and argument boundaries are identified before nested values are evaluated. Built-in multi-argument converters therefore retain their argument boundaries even when a nested converter returns a comma. Other converters continue to receive one comma-separatedStringargument. Inside arguments,$$$name(with a non-empty name that contains no$takes precedence as a nested expression opener. Every other$escapes the immediately following character, and an expression closes only when an unescaped)is immediately followed by$$$. Thus$,,$$,$(, and$)yield literal comma, dollar, and parentheses. Escapes are processed once, and only in expression arguments. For example,$$$equals_ignore_case($$$upper(ws)$$$,WS)$$$evaluates totrue. Multiple expressions are supported, and converter results are not parsed or escaped again. Unknown and malformed expressions are preserved while parsing resumes at subsequent expressions. Nested converters are all evaluated before their outer converter is invoked; booleanandandortherefore do not short-circuit. Anullcontainer leaves the string unchanged.- Parameters:
str- the string that may contain converter expressionscontainer- the container used to resolve converters- Returns:
- the string with recognized converter expressions evaluated
- Since:
- 3.23
-
convert
Converts matches of the supplied pattern using the first two capture groups as the converter type and argument. This overload retains the pattern-based, single-pass behavior; useconvert(String, IManagedContainer)for the standard nested$$$name(arguments)$$$syntax.- Parameters:
str- the string to convertcontainer- the container used to resolve converterspattern- the pattern whose first two capture groups contain the converter type and argument- Returns:
- the string with recognized matches converted
- Since:
- 3.23
-
parse
- Since:
- 3.23
-
parse
public static <T> T parse(String str, IManagedContainer container, Class<T> type, boolean enumCaseSensitive) - Since:
- 3.23
-
parseEnum
-
isEmpty
-
appendSeparator
- Since:
- 3.16
-
appendSeparator
- Since:
- 3.16
-
glob
-
glob
Matches a string against a pattern and fills an array with the sub-matches.Pattern description:
*matches 0 or more characters?matches a single character[...]matches a set and/or range of characters\escapes the following character
- Since:
- 2.0
-
equalsUpperOrLowerCase
Deprecated.As of 3.23 useequalsIgnoreCase(String, String).- Since:
- 3.1
-
equalsIgnoreCase(String, String).