Java Code Examples for org.apache.commons.lang3.CharUtils#isAsciiAlphanumeric()

The following examples show how to use org.apache.commons.lang3.CharUtils#isAsciiAlphanumeric() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApiNameGenerator.java    From api-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Replaces all non alphanumeric characters in input string with {@link
 * ApiNameGenerator#API_NAME_FILLER_CHAR}
 */
private static String replaceNonAlphanumericChars(String input, boolean allowDots) {
  StringBuilder alphaNumeric = new StringBuilder();
  for (char hostnameChar : input.toCharArray()) {
    if (CharUtils.isAsciiAlphanumeric(hostnameChar) || (allowDots && hostnameChar == SEPARATOR)) {
      alphaNumeric.append(hostnameChar);
    } else {
      alphaNumeric.append(API_NAME_FILLER_CHAR);
    }
  }
  return alphaNumeric.toString();
}
 
Example 2
Source File: RandomStringUtilsTest.java    From OpenEstate-IO with Apache License 2.0 5 votes vote down vote up
private static boolean isAsciiAlphanumeric(String value) {
    for (char c : value.toCharArray()) {
        if (!CharUtils.isAsciiAlphanumeric(c))
            return false;
    }
    return true;
}
 
Example 3
Source File: SensitiveFilter.java    From MyCommunity with Apache License 2.0 4 votes vote down vote up
private boolean isSymbol(Character c) {
    // 0x2E80~0x9FFF 是东亚文字范围
    return !CharUtils.isAsciiAlphanumeric(c) && (c < 0x2E80 || c > 0x9FFF);
}
 
Example 4
Source File: TextQuery.java    From onedev with MIT License 4 votes vote down vote up
private boolean isWordChar(char ch) {
	return CharUtils.isAsciiAlphanumeric(ch) || ch == '_';
}