public final class StringHelper extends Object
Modifier and Type | Method and Description |
---|---|
static int |
countChar(String s,
char ch)
Counts the number of times the given char is in the string
|
static boolean |
hasStartToken(String expression,
String language)
Does the expression have the language start token?
|
static boolean |
hasUpperCase(String text)
Determines if the string has at least one letter in upper case
|
static boolean |
isQuoted(String s) |
static String |
removeLeadingAndEndingQuotes(String s) |
static String |
removeQuotes(String s) |
static String |
replaceAll(String input,
String from,
String to)
Replaces all the from tokens in the given input string.
|
static String |
sanitize(String s)
Ensures that
s is friendly for a URL or file system. |
static String |
toJson(String name,
String value,
boolean isMap)
Creates a json tuple with the given name/value pair.
|
static String |
xmlEncode(String text)
Encodes the text into safe XML by replacing < > and & with XML tokens
|
public static String sanitize(String s)
s
is friendly for a URL or file system.s
- String to be sanitized.s
.NullPointerException
- if s
is null
.public static int countChar(String s, char ch)
s
- the stringch
- the charpublic static String removeQuotes(String s)
public static String removeLeadingAndEndingQuotes(String s)
public static String xmlEncode(String text)
text
- the textpublic static boolean hasUpperCase(String text)
text
- the textpublic static boolean hasStartToken(String expression, String language)
expression
- the expressionlanguage
- the name of the language, such as simplepublic static String replaceAll(String input, String from, String to)
input
- the input stringfrom
- the from string, must not be null or emptyto
- the replacement string, must not be emptyIllegalArgumentException
- if the input arguments is invalidApache Camel