Package org.apache.uima.pear.util
Class StringUtil
- java.lang.Object
-
- org.apache.uima.pear.util.StringUtil
-
public class StringUtil extends Object
TheStringUtilclass provides utility methods for working with strings.
-
-
Constructor Summary
Constructors Constructor Description StringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.
-
-
-
Method Detail
-
appendProperties
public static Properties appendProperties(Properties source, Properties plus, boolean override)
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
public static int countWords(String text)
- Parameters:
text- The given string.- Returns:
- The number of words in a given string.
-
errorStackTraceContent
public static String errorStackTraceContent(Throwable error)
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
public static String extractTextFromMarkup(String mString)
- Parameters:
mString- The given markup string.- Returns:
- Text extracted from a given markup string.
-
getPlainClassName
public static String getPlainClassName(Class<?> aClass)
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
public static boolean isLowerCase(String string)
- Parameters:
string- The given string.- Returns:
true, if all characters in a given string are lowercase letters,falseotherwise.
-
isUpperCase
public static boolean isUpperCase(String string)
- Parameters:
string- The given string.- Returns:
true, if all characters in a given string are uppercase letters,falseotherwise.
-
indexOfIgnoreCase
public static int indexOfIgnoreCase(String mainStr, String argStr)
- 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
public static int indexOfIgnoreCase(String mainStr, String argStr, int fromIndex)
- 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
public 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.
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
public static String toRegExpString(String string)
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.
-
-