Package org.apache.uima.pear.util

# Class StringUtil

java.lang.Object
org.apache.uima.pear.util.StringUtil

public class StringUtil extends Object
The `StringUtil` class provides utility methods for working with strings.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StringUtil()`

- ## Method Summary

  Modifier and Type
  Method
  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.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### StringUtil

    public StringUtil()

- ## Method Details

  - ### 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 is `true`, 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 is `true`, 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 given `Throwable` object.
    Parameters:
      `error` - The given `Throwable` object.
    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 Java `Class`.
    Parameters:
      `aClass` - The given Java `Class`.
    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, `false` otherwise.

  - ### isUpperCase

    public static boolean isUpperCase(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(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, `-1` is 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 at `fromIndex` or beyond, `-1` is 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 the `String::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.