Class StringTool

java.lang.Object
ch.nolix.base.commontype.stringtool.StringTool

public final class StringTool extends Object
The StringTool provides methods to handle Strings. Of the StringTool an instance cannot be created.
Author:
Silvan Wyss
  • Method Details

    • createTabs

      public static String createTabs(int tabCount)
      Parameters:
      tabCount -
      Returns:
      a new String consisting of as many tabulators as the given tabCount says
      Throws:
      RuntimeException - if the given tabCount is negative
    • getInBraces

      public static String getInBraces(Object object)
      Parameters:
      object -
      Returns:
      the String representation of the given object in braces
      Throws:
      RuntimeException - if the given object is null
    • getIndexOfNextVisibleCharacterOrMinusOne

      public static int getIndexOfNextVisibleCharacterOrMinusOne(String string, int startIndex)
      Parameters:
      string -
      startIndex -
      Returns:
      the index of the next visible character of the given string from the given startIndex if exists, -1 otherwise
    • getInParentheses

      public static String getInParentheses(Object... objects)
      Parameters:
      objects -
      Returns:
      the String representation of the given objects in parentheses
      Throws:
      RuntimeException - if the given objects is null
      RuntimeException - if one of the given objects is null
    • getInSingleQuotes

      public static String getInSingleQuotes(Object object)
      Parameters:
      object -
      Returns:
      the String representation of the given object in single quotes
      Throws:
      RuntimeException - if the given object is null
    • getWithoutLastCharacters

      public static String getWithoutLastCharacters(String string, int n)
      Parameters:
      string -
      n -
      Returns:
      a new String that is like the given string without the last n characters.
    • isPascalCase

      public static boolean isPascalCase(String string)
      Parameters:
      string -
      Returns:
      true if the given string is in pascal case, false otherwise
    • toBoolean

      public static boolean toBoolean(String string)
      Parameters:
      string -
      Returns:
      the boolean the given string represents
      Throws:
      RuntimeException - if the given string does not represent a boolean
    • toCapitalSnakeCase

      public static String toCapitalSnakeCase(String string)
      Parameters:
      string -
      Returns:
      a new String in capital snake case for the given string.
    • toDouble

      public static double toDouble(String string)
      Parameters:
      string -
      Returns:
      the double the given string represents
      Throws:
      RuntimeException - if the given string does not represent a double
    • toPascalCase

      public static String toPascalCase(String string)
      Parameters:
      string -
      Returns:
      a new String in pascal case for the given string.
    • toProportion

      public static double toProportion(String string)
      Parameters:
      string -
      Returns:
      a proportion in [0, 1] from the given string
      Throws:
      RuntimeException - if the given string does not represent a proportion