Package components.utilities
Class FormatChecker
java.lang.Object
components.utilities.FormatChecker
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 Summary
Modifier and TypeMethodDescriptionstatic booleanChecks whether the givenStringrepresents a valid boolean value.static booleanChecks whether the givenStringrepresents a valid real value (as defined inDouble).static booleanChecks whether the givenStringrepresents a valid integer value in the range Integer.MIN_VALUE..Integer.MAX_VALUE.static booleanChecks whether the givenStringrepresents a valid integer value in the range Long.MIN_VALUE..Long.MAX_VALUE.
-
Method Details
-
canParseInt
Checks whether the givenStringrepresents a valid integer value in the range Integer.MIN_VALUE..Integer.MAX_VALUE.- Parameters:
s- theStringto be checked- Returns:
- true if the given
Stringrepresents a valid integer, false otherwise - Ensures:
canParseInt = [the given String represents a valid integer]
-
canParseLong
Checks whether the givenStringrepresents a valid integer value in the range Long.MIN_VALUE..Long.MAX_VALUE.- Parameters:
s- theStringto be checked- Returns:
- true if the given
Stringrepresents a valid integer, false otherwise - Ensures:
canParseLong = [the given String represents a valid integer]
-
canParseDouble
Checks whether the givenStringrepresents a valid real value (as defined inDouble).- Parameters:
s- theStringto be checked- Returns:
- true if the given
Stringrepresents a valid real, false otherwise - Ensures:
canParseDouble = [the given String represents a valid real]
-
canParseBoolean
Checks whether the givenStringrepresents a valid boolean value.- Parameters:
s- theStringto be checked- Returns:
- true if the given
Stringrepresents a valid boolean, false otherwise - Ensures:
canParseBoolean = (s = "true") or (s = "false")
-