Package org.apache.uima.pear.util
Class StringUtil
- java.lang.Object
-
- org.apache.uima.pear.util.StringUtil
-
public class StringUtil extends java.lang.Object
TheStringUtil
class 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 java.util.Properties
appendProperties(java.util.Properties source, java.util.Properties plus, boolean override)
Appends properties specified in a given 'plus' object to a given 'source' object.static int
countWords(java.lang.String text)
static java.lang.String
errorStackTraceContent(java.lang.Throwable error)
Return the content of the stack trace for a givenThrowable
object.static java.lang.String
extractTextFromMarkup(java.lang.String mString)
static java.lang.String
getPlainClassName(java.lang.Class<?> aClass)
Returns a plain name (without package name) of a given JavaClass
.static int
indexOfIgnoreCase(java.lang.String mainStr, java.lang.String argStr)
static int
indexOfIgnoreCase(java.lang.String mainStr, java.lang.String argStr, int fromIndex)
static boolean
isLowerCase(java.lang.String string)
static boolean
isUpperCase(java.lang.String string)
static java.lang.String
toRegExpReplacement(java.lang.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 java.lang.String
toRegExpString(java.lang.String string)
Converts a given input string to another string that can be used in all 'regular expression' methods.
-
-
-
Method Detail
-
appendProperties
public static java.util.Properties appendProperties(java.util.Properties source, java.util.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(java.lang.String text)
- Parameters:
text
- The given string.- Returns:
- The number of words in a given string.
-
errorStackTraceContent
public static java.lang.String errorStackTraceContent(java.lang.Throwable error)
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
public static java.lang.String extractTextFromMarkup(java.lang.String mString)
- Parameters:
mString
- The given markup string.- Returns:
- Text extracted from a given markup string.
-
getPlainClassName
public static java.lang.String getPlainClassName(java.lang.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(java.lang.String string)
- Parameters:
string
- The given string.- Returns:
true
, if all characters in a given string are lowercase letters,false
otherwise.
-
isUpperCase
public static boolean isUpperCase(java.lang.String string)
- Parameters:
string
- The given string.- Returns:
true
, if all characters in a given string are uppercase letters,false
otherwise.
-
indexOfIgnoreCase
public static int indexOfIgnoreCase(java.lang.String mainStr, java.lang.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,
-1
is returned.
-
indexOfIgnoreCase
public static int indexOfIgnoreCase(java.lang.String mainStr, java.lang.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 atfromIndex
or beyond,-1
is returned.
-
toRegExpReplacement
public static java.lang.String toRegExpReplacement(java.lang.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 java.lang.String toRegExpString(java.lang.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.
-
-