Package org.eclipse.net4j.util

# Class StringUtil

java.lang.Object
org.eclipse.net4j.util.StringUtil

public final class StringUtil extends Object
Various static helper methods for dealing with strings.

Author:
  Eike Stepper

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`EMPTY`
`static final String`
`FALSE`
`static final String`
`NL`
`static final String`
`TRUE`

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`appendSeparator(StringBuilder builder, char c)`
`static boolean`
`appendSeparator(StringBuilder builder, String str)`
`static String`
`cap(String str)`
`static String`
`capAll(String str)`
`static int`
`compare(String s1, String s2)`
`static int`
`compareIgnoreCase(String s1, String s2)`
`static String`
`convert(String str, IManagedContainer container)`
`static String`
`convert(String str, IManagedContainer container, Pattern pattern)`
`static String`
`create(char c, int length)`
`static boolean`
`equalsIgnoreCase(String s1, String s2)`
`static boolean`
`equalsUpperOrLowerCase(String s, String upperOrLowerCase)`
Deprecated.
As of 3.23 use `equalsIgnoreCase(String, String)`.
`static String`
`escape(String str)`
`static String`
`escape(String str, char separator)`
`static String`
`formatException(Throwable t)`
`static boolean`
`glob(String pattern, String string)`
Matches a string against a pattern.
`static boolean`
`glob(String pattern, String string, String[] subStrings)`
Matches a string against a pattern and fills an array with the sub-matches.
`static boolean`
`isEmpty(String str)`
`static boolean`
`isFalse(String s)`
`static boolean`
`isTrue(String s)`
`static int`
`occurrences(String str, char c)`
`static int`
`occurrences(String str, String c)`
`static <T> T`
`parse(String str, IManagedContainer container, Class<T> type)`
`static <T> T`
`parse(String str, IManagedContainer container, Class<T> type, boolean enumCaseSensitive)`
`static <E extends Enum<E>>
E`
`parseEnum(Class<E> enumType, String name, boolean caseSensitive)`
`static String`
`replace(String text, String[] find, String[] replace)`
`static String`
`replace(String text, String find, String replace)`
`static String`
`replace(String str, Map<String,String> replacements)`
`static String`
`safe(Object object)`
`static String`
`safe(Object object, String def)`
`static String`
`safe(String str)`
`static String`
`safe(String str, String def)`
`static List<String>`
`split(String text, String separators, String brackets)`
`static String`
`stripHTML(String html)`
`static void`
`tokenize(String text, String separators, Consumer<String> tokenConsumer)`
`static String`
`translate(String str, String from, String to)`
`static String`
`uncap(String str)`
`static String`
`uncapAll(String str)`
`static String`
`unescape(String str)`
`static String`
`unescape(String str, char separator)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### EMPTY

public static final String EMPTY

See Also:
  - Constant Field Values

### NL

public static final String NL

### TRUE

public static final String TRUE

Since:
  3.22

### FALSE

public static final String FALSE

Since:
  3.22

## Method Details

### create

public static String create(char c, int length)

Since:
  3.4

### formatException

public static String formatException(Throwable t)

Since:
  2.0

### replace

public static String replace(String text, String find, String replace)

Since:
  3.16

### replace

public static String replace(String text, String[] find, String[] replace)

### replace

public static String replace(String str, Map<String,String> replacements)

Since:
  3.23

### tokenize

public static void tokenize(String text, String separators, Consumer<String> tokenConsumer)

Since:
  3.22

### split

public static List<String> split(String text, String separators, String brackets)

Since:
  3.4

### safe

public static String safe(String str)

### safe

public static String safe(String str, String def)

Since:
  3.4

### safe

public static String safe(Object object)

Since:
  3.13

### safe

public static String safe(Object object, String def)

Since:
  3.13

### escape

public static String escape(String str)

Since:
  3.22

### escape

public static String escape(String str, char separator)

Since:
  3.22

### unescape

public static String unescape(String str)

Since:
  3.22

### unescape

public static String unescape(String str, char separator)

Since:
  3.22

### stripHTML

public static String stripHTML(String html)

Since:
  3.26

### compare

public static int compare(String s1, String s2)

### compareIgnoreCase

public static int compareIgnoreCase(String s1, String s2)

Since:
  3.23

### equalsIgnoreCase

public static boolean equalsIgnoreCase(String s1, String s2)

Since:
  3.23

### isTrue

public static boolean isTrue(String s)

Since:
  3.22

### isFalse

public static boolean isFalse(String s)

Since:
  3.22

### capAll

public static String capAll(String str)

Since:
  2.0

### cap

public static String cap(String str)

### uncapAll

public static String uncapAll(String str)

Since:
  2.0

### uncap

public static String uncap(String str)

### occurrences

public static int occurrences(String str, char c)

### occurrences

public static int occurrences(String str, String c)

### translate

public static String translate(String str, String from, String to)

Since:
  3.8

### convert

public static String convert(String str, IManagedContainer container)

Since:
  3.23

### convert

public static String convert(String str, IManagedContainer container, Pattern pattern)

Since:
  3.23

### parse

public static <T> T parse(String str, IManagedContainer container, Class<T> type)

Since:
  3.23

### parse

public static <T> T parse(String str, IManagedContainer container, Class<T> type, boolean enumCaseSensitive)

Since:
  3.23

### parseEnum

public static <E extends Enum<E>> E parseEnum(Class<E> enumType, String name, boolean caseSensitive)

Since:
  3.29

### isEmpty

public static boolean isEmpty(String str)

### appendSeparator

public static boolean appendSeparator(StringBuilder builder, String str)

Since:
  3.16

### appendSeparator

public static boolean appendSeparator(StringBuilder builder, char c)

Since:
  3.16

### glob

public static boolean glob(String pattern, String string)
Matches a string against a pattern.

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

### glob

public static boolean glob(String pattern, String string, String[] subStrings)
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 public static boolean equalsUpperOrLowerCase(String s, String upperOrLowerCase)
Deprecated.
As of 3.23 use `equalsIgnoreCase(String, String)`.

Since:
  3.1