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 boolean
Checks whether the givenString
represents a valid boolean value.static boolean
Checks whether the givenString
represents a valid real value (as defined inDouble
).static boolean
Checks whether the givenString
represents a valid integer value in the range Integer.MIN_VALUE..Integer.MAX_VALUE.static boolean
Checks whether the givenString
represents a valid integer value in the range Long.MIN_VALUE..Long.MAX_VALUE.
-
Method Details
-
canParseInt
Checks whether the givenString
represents a valid integer value in the range Integer.MIN_VALUE..Integer.MAX_VALUE.- Parameters:
s
- theString
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
Checks whether the givenString
represents a valid integer value in the range Long.MIN_VALUE..Long.MAX_VALUE.- Parameters:
s
- theString
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
Checks whether the givenString
represents a valid real value (as defined inDouble
).- Parameters:
s
- theString
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
Checks whether the givenString
represents a valid boolean value.- Parameters:
s
- theString
to be checked- Returns:
- true if the given
String
represents a valid boolean, false otherwise - Ensures:
canParseBoolean = (s = "true") or (s = "false")
-