MCPcopy Create free account
hub / github.com/banq/jdonframework / isInteger

Method isInteger

src/main/java/com/jdon/util/UtilValidate.java:305–320  ·  view source on GitHub ↗

Returns true if all characters in string s are numbers. Accepts non-signed integers only. Does not accept floating point, exponential notation, etc.

(String s)

Source from the content-addressed store, hash-verified

303 * point, exponential notation, etc.
304 */
305 public static boolean isInteger(String s) {
306 if (isEmpty(s)) return defaultEmptyOK;
307
308 // Search through string's characters one by one
309 // until we find a non-numeric character.
310 // When we do, return false; if we don't, return true.
311 for (int i = 0; i < s.length(); i++) {
312 // Check that current character is number.
313 char c = s.charAt(i);
314
315 if (!isDigit(c)) return false;
316 }
317
318 // All characters are numbers.
319 return true;
320 }
321
322 /** Returns true if all characters are numbers;
323 * first character is allowed to be + or - as well.

Callers 5

isSSNMethod · 0.95
isUSPhoneNumberMethod · 0.95
isUSPhoneAreaCodeMethod · 0.95
isUSPhoneMainNumberMethod · 0.95
isZipCodeMethod · 0.95

Calls 2

isEmptyMethod · 0.95
isDigitMethod · 0.95

Tested by

no test coverage detected