Package org.apache.uima.pear.util
Class StringUtil
java.lang.Object
org.apache.uima.pear.util.StringUtil
The
StringUtil
class provides utility methods for working with strings.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 givenThrowable
object.static String
extractTextFromMarkup
(String mString) static String
getPlainClassName
(Class<?> aClass) Returns a plain name (without package name) of a given JavaClass
.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 theString::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.
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
appendProperties
Appends properties specified in a given 'plus' object to a given 'source' object. If the 'override' flag istrue
, the 'plus' properties will override the 'source' properties with the same name, otherwise the 'source' properties will stay.- Parameters:
source
- The given 'source' properties object.plus
- The given 'plus' properties object.override
- If this flag istrue
, the 'plus' properties will override the 'source' properties with the same name, otherwise the 'source' properties will stay.- Returns:
- The properties object, containing both the given 'source' properties and the given 'plus' properties.
-
countWords
- Parameters:
text
- The given string.- Returns:
- The number of words in a given string.
-
errorStackTraceContent
Return the content of the stack trace for a givenThrowable
object.- Parameters:
error
- The givenThrowable
object.- Returns:
- The content of the stack trace for the given error.
-
extractTextFromMarkup
- Parameters:
mString
- The given markup string.- Returns:
- Text extracted from a given markup string.
-
getPlainClassName
Returns a plain name (without package name) of a given JavaClass
.- Parameters:
aClass
- The given JavaClass
.- Returns:
- The plain name (without package name) of the given Java
Class
.
-
isLowerCase
- Parameters:
string
- The given string.- Returns:
true
, if all characters in a given string are lowercase letters,false
otherwise.
-
isUpperCase
- Parameters:
string
- The given string.- Returns:
true
, if all characters in a given string are uppercase letters,false
otherwise.
-
indexOfIgnoreCase
- Parameters:
mainStr
- The given string object.argStr
- The given string argument.- Returns:
- If the given string argument occurs as a substring, ignoring case, within the given
string object, then the index of the first character of the first such substring is
returned; if it does not occur as a substring,
-1
is returned.
-
indexOfIgnoreCase
- Parameters:
mainStr
- The given string object.argStr
- The given string argument.fromIndex
- The index to start the search from.- Returns:
- If the given string argument occurs as a substring, ignoring case, within the given
string object at a starting index no smaller than
fromIndex
, then the index of the first character of the first such substring is returned; if it does not occur as a substring starting atfromIndex
or beyond,-1
is returned.
-
toRegExpReplacement
Converts a given input string to another string that can be used as a 'replacement' string in theString::replaceAll(String regex, String replacement)
method.
Characters to be escaped are: "\ $".- Parameters:
string
- The given input string.- Returns:
- The string that can be used as a 'replacement' string in the
String::replaceAll(String regex, String replacement)
method.
-
toRegExpString
Converts a given input string to another string that can be used in all 'regular expression' methods.
Characters to be escaped are: "\ . $ ^ { [ ( | ) * + ?".- Parameters:
string
- The given input string.- Returns:
- The string that can be used in 'regular expression' methods.
-