Class FormatChecker

java.lang.Object
components.utilities.FormatChecker

public final class FormatChecker extends Object
FormatChecker utility class with methods to check whether a String can be parsed as one of the primitive types (int, long, double, or boolean).
  • Method Details

    • canParseInt

      public static boolean canParseInt(String s)
      Checks whether the given String represents a valid integer value in the range Integer.MIN_VALUE..Integer.MAX_VALUE.
      Parameters:
      s - the String to be checked
      Returns:
      true if the given String represents a valid integer, false otherwise
      Ensures:
      canParseInt = [the given String represents a valid integer]
    • canParseLong

      public static boolean canParseLong(String s)
      Checks whether the given String represents a valid integer value in the range Long.MIN_VALUE..Long.MAX_VALUE.
      Parameters:
      s - the String to be checked
      Returns:
      true if the given String represents a valid integer, false otherwise
      Ensures:
      canParseLong = [the given String represents a valid integer]
    • canParseDouble

      public static boolean canParseDouble(String s)
      Checks whether the given String represents a valid real value (as defined in Double).
      Parameters:
      s - the String to be checked
      Returns:
      true if the given String represents a valid real, false otherwise
      Ensures:
      canParseDouble = [the given String represents a valid real]
    • canParseBoolean

      public static boolean canParseBoolean(String s)
      Checks whether the given String represents a valid boolean value.
      Parameters:
      s - the String to be checked
      Returns:
      true if the given String represents a valid boolean, false otherwise
      Ensures:
      canParseBoolean = (s = "true") or (s = "false")