java.lang.Character.isLetterOrDigit()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(316)

本文整理了Java中java.lang.Character.isLetterOrDigit()方法的一些代码示例,展示了Character.isLetterOrDigit()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Character.isLetterOrDigit()方法的具体详情如下:
包路径:java.lang.Character
类名称:Character
方法名:isLetterOrDigit

Character.isLetterOrDigit介绍

[英]Indicates whether the specified character is a letter or a digit.
[中]指示指定的字符是字母还是数字。

代码示例

代码示例来源:origin: google/guava

@Override
public boolean matches(char c) {
 return Character.isLetterOrDigit(c);
}

代码示例来源:origin: libgdx/libgdx

protected boolean isWordCharacter (char c) {
  return Character.isLetterOrDigit(c);
}

代码示例来源:origin: libgdx/libgdx

protected boolean isWordCharacter (char c) {
  return Character.isLetterOrDigit(c);
}

代码示例来源:origin: prestodb/presto

private static boolean isUnquotedSubscriptCharacter(char c)
{
  return c == '_' || isLetterOrDigit(c);
}

代码示例来源:origin: prestodb/presto

@Override
public boolean matches(char c) {
 return Character.isLetterOrDigit(c);
}

代码示例来源:origin: redisson/redisson

protected boolean isIdPart(int ch) {
  return Character.isLetterOrDigit(ch) || ch == '$' || ch == '#' || ch == '_' || ch == '.';
}

代码示例来源:origin: google/j2objc

@Override
public boolean matches(char c) {
 return Character.isLetterOrDigit(c);
}

代码示例来源:origin: AsyncHttpClient/async-http-client

private boolean isValidProtocolChar(char c) {
 return Character.isLetterOrDigit(c) && c != '.' && c != '+' && c != '-';
}

代码示例来源:origin: spring-projects/spring-framework

private static void validateLocalePart(String localePart) {
  for (int i = 0; i < localePart.length(); i++) {
    char ch = localePart.charAt(i);
    if (ch != ' ' && ch != '_' && ch != '-' && ch != '#' && !Character.isLetterOrDigit(ch)) {
      throw new IllegalArgumentException(
          "Locale part \"" + localePart + "\" contains invalid characters");
    }
  }
}

代码示例来源:origin: redisson/redisson

protected boolean shouldQuote(String string) {
  boolean ws = false;
  for (int ii = 0; ii < string.length(); ii++) {
    final char ch = string.charAt(ii);
    if (ii==0 && !Character.isLetter(ch) )
      return true;
    if (!Character.isLetterOrDigit(ch) && ch != '_' && ch != '-' && ch != '(' && ch != ')' && ch != '[' && ch != ']' && ch != '.') {
      ws = true;
      break;
    }
  }
  return ws;
}

代码示例来源:origin: stanfordnlp/CoreNLP

public static boolean langIndependentPuncCheck(String token) {
 boolean isNotWord = true;
 for (int offset = 0; offset < token.length(); ) {
   final int codepoint = token.codePointAt(offset);
   if (Character.isLetterOrDigit(codepoint)) {
    isNotWord = false;
   }
   offset += Character.charCount(codepoint);
 }
 return isNotWord;
}

代码示例来源:origin: jwtk/jjwt

private static void validateLocalePart(String localePart) {
  for (int i = 0; i < localePart.length(); i++) {
    char ch = localePart.charAt(i);
    if (ch != '_' && ch != ' ' && !Character.isLetterOrDigit(ch)) {
      throw new IllegalArgumentException(
        "Locale part \"" + localePart + "\" contains invalid characters");
    }
  }
}

代码示例来源:origin: org.springframework/spring-core

private static void validateLocalePart(String localePart) {
  for (int i = 0; i < localePart.length(); i++) {
    char ch = localePart.charAt(i);
    if (ch != ' ' && ch != '_' && ch != '-' && ch != '#' && !Character.isLetterOrDigit(ch)) {
      throw new IllegalArgumentException(
          "Locale part \"" + localePart + "\" contains invalid characters");
    }
  }
}

代码示例来源:origin: alibaba/easyexcel

private static void validateLocalePart(String localePart) {
  for (int i = 0; i < localePart.length(); i++) {
    char ch = localePart.charAt(i);
    if (ch != ' ' && ch != '_' && ch != '#' && !Character.isLetterOrDigit(ch)) {
      throw new IllegalArgumentException(
        "Locale part \"" + localePart + "\" contains invalid characters");
    }
  }
}

代码示例来源:origin: thinkaurelius/titan

public static List<String> tokenize(String str) {
  ArrayList<String> tokens = new ArrayList<String>();
  int previous = 0;
  for (int p = 0; p < str.length(); p++) {
    if (!Character.isLetterOrDigit(str.charAt(p))) {
      if (p > previous + MIN_TOKEN_LENGTH) tokens.add(str.substring(previous, p));
      previous = p + 1;
    }
  }
  if (previous + MIN_TOKEN_LENGTH < str.length()) tokens.add(str.substring(previous, str.length()));
  return tokens;
}

代码示例来源:origin: stackoverflow.com

InputFilter filter = new InputFilter() {
  public CharSequence filter(CharSequence source, int start, int end,
      Spanned dest, int dstart, int dend) {
    for (int i = start; i < end; i++) {
      if (!Character.isLetterOrDigit(source.charAt(i))) {
        return "";
      }
    }
    return null;
  }
};
edit.setFilters(new InputFilter[] { filter });

代码示例来源:origin: hibernate/hibernate-orm

private boolean isAliasDereferenced(String withClauseFragment, String alias) {
  // See if the with clause contains the join alias
  int index = withClauseFragment.indexOf( alias );
  int dotIndex = index + alias.length();
  if ( index != -1
      // Check that the join alias is not a suffix
      && ( index == 0 || !Character.isLetterOrDigit( withClauseFragment.charAt( index - 1 ) ) )
      // Check that the join alias gets de-referenced i.e. the next char is a dot
      && dotIndex < withClauseFragment.length() && withClauseFragment.charAt( dotIndex ) == '.' ) {
    return true;
  }
  return false;
}

代码示例来源:origin: apache/incubator-druid

private static String escape(final String s)
{
 final StringBuilder escaped = new StringBuilder();
 for (int i = 0; i < s.length(); i++) {
  final char c = s.charAt(i);
  if (Character.isLetterOrDigit(c) || Arrays.binarySearch(SAFE_CHARS, c) >= 0) {
   escaped.append(c);
  } else {
   escaped.append("\\u").append(BaseEncoding.base16().encode(Chars.toByteArray(c)));
  }
 }
 return escaped.toString();
}

代码示例来源:origin: com.h2database/h2

private String getFilePrefix(String dir) {
  StringBuilder buff = new StringBuilder(dir);
  buff.append('/');
  for (int i = 0; i < databaseName.length(); i++) {
    char ch = databaseName.charAt(i);
    if (Character.isLetterOrDigit(ch)) {
      buff.append(ch);
    } else {
      buff.append('_');
    }
  }
  return buff.toString();
}

代码示例来源:origin: alibaba/fastjson

public final void scanIdent() {
  np = bp - 1;
  hasSpecial = false;
  for (;;) {
    sp++;
    next();
    if (Character.isLetterOrDigit(ch)) {
      continue;
    }
    String ident = stringVal();
    if ("null".equalsIgnoreCase(ident)) {
      token = JSONToken.NULL;
    } else if ("new".equals(ident)) {
      token = JSONToken.NEW;
    } else if ("true".equals(ident)) {
      token = JSONToken.TRUE;
    } else if ("false".equals(ident)) {
      token = JSONToken.FALSE;
    } else if ("undefined".equals(ident)) {
      token = JSONToken.UNDEFINED;
    } else if ("Set".equals(ident)) {
      token = JSONToken.SET;
    } else if ("TreeSet".equals(ident)) {
      token = JSONToken.TREE_SET;
    } else {
      token = JSONToken.IDENTIFIER;
    }
    return;
  }
}

相关文章

Character类方法