public class StringUtil extends Object
StringUtil
class provides utility methods for working with strings.Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static Properties |
appendProperties(Properties source,
Properties plus,
boolean override)
Appends properties specified in a given 'plus' object to a given 'source' object.
|
static int |
countWords(String text) |
static String |
errorStackTraceContent(Throwable error)
Return the content of the stack trace for a given
Throwable object. |
static String |
extractTextFromMarkup(String mString) |
static String |
getPlainClassName(Class<?> aClass)
Returns a plain name (without package name) of a given Java
Class . |
static int |
indexOfIgnoreCase(String mainStr,
String argStr) |
static int |
indexOfIgnoreCase(String mainStr,
String argStr,
int fromIndex) |
static boolean |
isLowerCase(String string) |
static boolean |
isUpperCase(String string) |
static String |
toRegExpReplacement(String string)
Converts a given input string to another string that can be used as a 'replacement' string in
the
String::replaceAll(String regex, String replacement) method. |
static String |
toRegExpString(String string)
Converts a given input string to another string that can be used in all 'regular expression'
methods.
|
public static Properties appendProperties(Properties source, Properties plus, boolean override)
true
, the 'plus' properties will override the 'source'
properties with the same name, otherwise the 'source' properties will stay.source
- The given 'source' properties object.plus
- The given 'plus' properties object.override
- If this flag is true
, the 'plus' properties will override the 'source'
properties with the same name, otherwise the 'source' properties will stay.public static int countWords(String text)
text
- The given string.public static String errorStackTraceContent(Throwable error)
Throwable
object.error
- The given Throwable
object.public static String extractTextFromMarkup(String mString)
mString
- The given markup string.public static String getPlainClassName(Class<?> aClass)
Class
.aClass
- The given Java Class
.Class
.public static boolean isLowerCase(String string)
string
- The given string.true
, if all characters in a given string are lowercase letters,
false
otherwise.public static boolean isUpperCase(String string)
string
- The given string.true
, if all characters in a given string are uppercase letters,
false
otherwise.public static int indexOfIgnoreCase(String mainStr, String argStr)
mainStr
- The given string object.argStr
- The given string argument.-1
is returned.public static int indexOfIgnoreCase(String mainStr, String argStr, int fromIndex)
mainStr
- The given string object.argStr
- The given string argument.fromIndex
- The index to start the search from.fromIndex
, then the
index of the first character of the first such substring is returned; if it does not
occur as a substring starting at fromIndex
or beyond, -1
is returned.public static String toRegExpReplacement(String string)
String::replaceAll(String regex, String replacement)
method. string
- The given input string.String::replaceAll(String regex, String replacement)
method.public static String toRegExpString(String string)
string
- The given input string.Copyright © 2006–2017 The Apache Software Foundation. All rights reserved.