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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PropertiesappendProperties(Properties source, Properties plus, boolean override) Appends properties specified in a given 'plus' object to a given 'source' object.static intcountWords(String text) static StringerrorStackTraceContent(Throwable error) Return the content of the stack trace for a givenThrowableobject.static StringextractTextFromMarkup(String mString) static StringgetPlainClassName(Class<?> aClass) Returns a plain name (without package name) of a given JavaClass.static intindexOfIgnoreCase(String mainStr, String argStr) static intindexOfIgnoreCase(String mainStr, String argStr, int fromIndex) static booleanisLowerCase(String string) static booleanisUpperCase(String string) static StringtoRegExpReplacement(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 StringtoRegExpString(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 givenThrowableobject.- Parameters:
error- The givenThrowableobject.- 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,falseotherwise.
-
isUpperCase
- Parameters:
string- The given string.- Returns:
true, if all characters in a given string are uppercase letters,falseotherwise.
-
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,
-1is 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 atfromIndexor beyond,-1is 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.
-