public boolean isDigit(char c) { return Validator.isDigit(c); }
public boolean isDigit(java.lang.String s) { return Validator.isDigit(s); }
private boolean _isDigitOrLetter(char c) { if (Validator.isChar(c) || Validator.isDigit(c)) { return true; } return false; }
/** * Returns <code>true</code> if the string consists of only digits between 0 * and 9 (inclusive). * * @param s the string to check * @return <code>true</code> if the string consists of only digits between 0 * and 9 (inclusive); <code>false</code> otherwise */ public static boolean isDigit(String s) { if (isNull(s)) { return false; } for (char c : s.toCharArray()) { if (!isDigit(c)) { return false; } } return true; }
/** * Returns <code>true</code> if the string is a decimal integer number, * meaning it contains nothing but decimal digits. * * @param number the string to check * @return <code>true</code> if the string is a decimal integer number; * <code>false</code> otherwise */ public static boolean isNumber(String number) { if (isNull(number)) { return false; } for (char c : number.toCharArray()) { if (!isDigit(c)) { return false; } } return true; }
/** * Returns <code>true</code> if the string is an alphanumeric name, meaning * it contains nothing but English letters, numbers, and spaces. * * @param name the string to check * @return <code>true</code> if the string is an Alphanumeric name; * <code>false</code> otherwise */ public static boolean isAlphanumericName(String name) { if (isNull(name)) { return false; } String trimmedName = name.trim(); for (char c : trimmedName.toCharArray()) { if (!isChar(c) && !isDigit(c) && !Character.isWhitespace(c)) { return false; } } return true; }
/** * Returns <code>true</code> if the string is a valid password, meaning it * is at least four characters long and contains only letters and decimal * digits. * * @param password the string to check * @return <code>true</code> if the string is a valid password; * <code>false</code> otherwise */ public static boolean isPassword(String password) { if (isNull(password)) { return false; } if (password.length() < 4) { return false; } for (char c : password.toCharArray()) { if (!isChar(c) && !isDigit(c)) { return false; } } return true; }
/** * Returns <code>true</code> if the string is a valid host name. * * @param name the string to check * @return <code>true</code> if the string is a valid host name; * <code>false</code> otherwise */ public static boolean isHostName(String name) { if (isNull(name)) { return false; } char[] nameCharArray = name.toCharArray(); if ((nameCharArray[0] == CharPool.DASH) || (nameCharArray[0] == CharPool.PERIOD) || (nameCharArray[nameCharArray.length - 1] == CharPool.DASH)) { return false; } for (char c : nameCharArray) { if (!isChar(c) && !isDigit(c) && (c != CharPool.CLOSE_BRACKET) && (c != CharPool.COLON) && (c != CharPool.DASH) && (c != CharPool.OPEN_BRACKET) && (c != CharPool.PERIOD)) { return false; } } return true; }
/** * Returns a string consisting of all of the digits extracted from the * string. * * @param s the string from which to extract digits * @return a string consisting of all of the digits extracted from the * string */ public static String extractDigits(String s) { if (s == null) { return StringPool.BLANK; } StringBundler sb = new StringBundler(); char[] chars = s.toCharArray(); for (char c : chars) { if (Validator.isDigit(c)) { sb.append(c); } } return sb.toString(); }
/** * Returns the substring of all leading digits of string <code>s</code>, or * an empty string if it has no leading digits. * * @param s the string from which to extract the substring * @return the substring of all leading digits of string <code>s</code>, or * an empty string if it has no leading digits */ public static String extractLeadingDigits(String s) { if (s == null) { return StringPool.BLANK; } StringBundler sb = new StringBundler(); char[] chars = s.toCharArray(); for (char c : chars) { if (Validator.isDigit(c)) { sb.append(c); } else { return sb.toString(); } } return sb.toString(); }
if (!Validator.isChar(c) && !Validator.isDigit(c) && (c != CharPool.DASH) && (c != CharPool.PERIOD)) {
public boolean isDigit(char c) { return Validator.isDigit(c); }
public boolean isDigit(java.lang.String s) { return Validator.isDigit(s); }
public static String extractDigits(String s) { if (s == null) { return StringPool.BLANK; } StringBuilder sb = new StringBuilder(); char[] c = s.toCharArray(); for (int i = 0; i < c.length; i++) { if (Validator.isDigit(c[i])) { sb.append(c[i]); } } return sb.toString(); }
public static boolean isNumber(String number) { if (isNull(number)) { return false; } for (char c : number.toCharArray()) { if (!isDigit(c)) { return false; } } return true; }
/** * Returns true if s is a string of letters that are between 0 and 9. * * @param s a string * @return true if s is a string of letters that are between 0 and 9 */ public static boolean isDigit(String s) { if (isNull(s)) { return false; } for (char c : s.toCharArray()) { if (!isDigit(c)) { return false; } } return true; }
public static boolean isPassword(String password) { if (isNull(password)) { return false; } if (password.length() < 4) { return false; } for (char c : password.toCharArray()) { if (!isChar(c) && !isDigit(c)) { return false; } } return true; }
public static boolean isDomain(String domainName) { // See RFC-1034 (section 3), RFC-1123 (section 2.1), and RFC-952 // (section B. Lexical grammar) if (isNull(domainName)) { return false; } if (domainName.length() > 255) { return false; } String[] domainNameArray = StringUtil.split( domainName, StringPool.PERIOD); for (String domainNamePart : domainNameArray) { char[] domainNamePartCharArray = domainNamePart.toCharArray(); for (int i = 0; i < domainNamePartCharArray.length; i++) { char c = domainNamePartCharArray[i]; if ((i == 0) && (c == CharPool.DASH)) { return false; } else if ((i == (domainNamePartCharArray.length - 1)) && (c == CharPool.DASH)) { return false; } else if ((!isChar(c)) && (!isDigit(c)) && (c != CharPool.DASH)) { return false; } } } return true; }