Class StringUtils

java.lang.Object
games.stendhal.server.util.StringUtils

public class StringUtils extends Object
little methods to work with strings.
Author:
hendrik
  • Constructor Details

    • StringUtils

      public StringUtils()
  • Method Details

    • countUpperCase

      public static int countUpperCase(String text)
      Counts the number of upper case characters.
      Parameters:
      text - text to count
      Returns:
      number of upper case characters
    • countLowerCase

      public static int countLowerCase(String text)
      Counts the number of lower case characters.
      Parameters:
      text - text to count
      Returns:
      number of lower case characters
    • generateStringOfCharacters

      public static String generateStringOfCharacters(int count)
      creates a random string which only consists of letters
      Parameters:
      count - length of the string
      Returns:
      generated string
    • substitute

      public static String substitute(String string, Object... params)
      Replaces [variables] in a string
      Parameters:
      string - with [variables]
      params - name1, value1, name2, value2, name3, value3
      Returns:
      string with substituted parameters
    • substitute

      public static String substitute(String string, Map<String,​?> params)
      Replaces [variables] in a string
      Parameters:
      string - with [variables]
      params - replacement parameters
      Returns:
      string with substituted parameters
    • titleize

      public static String titleize(String st)
      Converts a string to title case. Example: "hello world" is converted to "Hello World"
      Parameters:
      st - String to be formatted.
      Returns:
      Title case formatted string.
    • trimTo

      public static String trimTo(String string, int size)
      trims a string to the specified size. It will not throw an error, if the string is already short enough.
      Parameters:
      string - string to trim down
      size - size
      Returns:
      trimmed string