List of usage examples for java.lang Character isLetterOrDigit
public static boolean isLetterOrDigit(int codePoint)
From source file:com.clark.func.Functions.java
/** * <p>//from w w w.ja v a 2s . c o m * Checks if the CharSequence contains only unicode letters or digits. * </p> * * <p> * <code>null</code> will return <code>false</code>. An empty CharSequence * (length()=0) will return <code>true</code>. * </p> * * <pre> * isAlphanumeric(null) = false * isAlphanumeric("") = true * isAlphanumeric(" ") = false * isAlphanumeric("abc") = true * isAlphanumeric("ab c") = false * isAlphanumeric("ab2c") = true * isAlphanumeric("ab-c") = false * </pre> * * @param cs * the CharSequence to check, may be null * @return <code>true</code> if only contains letters or digits, and is * non-null * @since 3.0 Changed signature from isAlphanumeric(String) to * isAlphanumeric(CharSequence) */ public static boolean isAlphanumeric(CharSequence cs) { if (cs == null) { return false; } int sz = cs.length(); for (int i = 0; i < sz; i++) { if (Character.isLetterOrDigit(cs.charAt(i)) == false) { return false; } } return true; }
From source file:bfile.util.StringUtils.java
/** * <p>Checks if the CharSequence contains only Unicode letters or digits.</p> * * <p>{@code null} will return {@code false}. * An empty CharSequence (length()=0) will return {@code false}.</p> * * <pre>/*www. ja v a2 s . c om*/ * StringUtils.isAlphanumeric(null) = false * StringUtils.isAlphanumeric("") = false * StringUtils.isAlphanumeric(" ") = false * StringUtils.isAlphanumeric("abc") = true * StringUtils.isAlphanumeric("ab c") = false * StringUtils.isAlphanumeric("ab2c") = true * StringUtils.isAlphanumeric("ab-c") = false * </pre> * * @param cs the CharSequence to check, may be null * @return {@code true} if only contains letters or digits, * and is non-null * @since 3.0 Changed signature from isAlphanumeric(String) to isAlphanumeric(CharSequence) * @since 3.0 Changed "" to return false and not true */ public static boolean isAlphanumeric(final CharSequence cs) { if (isEmpty(cs)) { return false; } final int sz = cs.length(); for (int i = 0; i < sz; i++) { if (Character.isLetterOrDigit(cs.charAt(i)) == false) { return false; } } return true; }
From source file:bfile.util.StringUtils.java
/** * <p>Checks if the CharSequence contains only Unicode letters, digits * or space ({@code ' '}).</p>/*from ww w .j a v a2s.com*/ * * <p>{@code null} will return {@code false}. * An empty CharSequence (length()=0) will return {@code true}.</p> * * <pre> * StringUtils.isAlphanumericSpace(null) = false * StringUtils.isAlphanumericSpace("") = true * StringUtils.isAlphanumericSpace(" ") = true * StringUtils.isAlphanumericSpace("abc") = true * StringUtils.isAlphanumericSpace("ab c") = true * StringUtils.isAlphanumericSpace("ab2c") = true * StringUtils.isAlphanumericSpace("ab-c") = false * </pre> * * @param cs the CharSequence to check, may be null * @return {@code true} if only contains letters, digits or space, * and is non-null * @since 3.0 Changed signature from isAlphanumericSpace(String) to isAlphanumericSpace(CharSequence) */ public static boolean isAlphanumericSpace(final CharSequence cs) { if (cs == null) { return false; } final int sz = cs.length(); for (int i = 0; i < sz; i++) { if (Character.isLetterOrDigit(cs.charAt(i)) == false && cs.charAt(i) != ' ') { return false; } } return true; }