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

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

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

Character.isUpperCase介绍

[英]Indicates whether the specified character is an upper case letter.
[中]指示指定的字符是否为大写字母。

代码示例

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

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

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

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

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

/**
 * Check if a string begins with an uppercase.
 *
 * @param s a string
 * @return true if the string is capitalized
 *         false otherwise
 */
public static boolean isCapitalized(String s) {
 return (Character.isUpperCase(s.charAt(0)));
}

代码示例来源:origin: greenrobot/greenDAO

public static String dbName(String javaName) {
  StringBuilder builder = new StringBuilder(javaName);
  for (int i = 1; i < builder.length(); i++) {
    boolean lastWasUpper = Character.isUpperCase(builder.charAt(i - 1));
    boolean isUpper = Character.isUpperCase(builder.charAt(i));
    if (isUpper && !lastWasUpper) {
      builder.insert(i, '_');
      i++;
    }
  }
  return builder.toString().toUpperCase();
}

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

/**
 * Return the method suffix for a given property name. The default implementation
 * uses JavaBean conventions.
 */
protected String getPropertyMethodSuffix(String propertyName) {
  if (propertyName.length() > 1 && Character.isUpperCase(propertyName.charAt(1))) {
    return propertyName;
  }
  return StringUtils.capitalize(propertyName);
}

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

protected static boolean allUpperCase(String s) {
 if (s == null) {
  return false;
 }
 for (int i = 0, len = s.length(); i < len; i++) {
  if (!Character.isUpperCase(s.charAt(i))) {
   return false;
  }
 }
 return true;
}

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

protected static boolean containsUpperCase(String s) {
 if (s == null) {
  return false;
 }
 for (int i = 0, len = s.length(); i < len; i++) {
  if (Character.isUpperCase(s.charAt(i))) {
   return true;
  }
 }
 return false;
}

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

public static String isCapitalized(String s) {
  if(s.length() > 0) {
   Character ch = s.charAt(0);
   return Character.isUpperCase(ch) ? "-upper" : "";
  }
  return "";
 }
}

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

private static boolean noUpperCase(String str) {
 if (str.length() < 1) {
  return false;
 }
 for (int i = 0; i < str.length(); i++) {
  if (Character.isUpperCase(str.charAt(i))) {
   return false;
  }
 }
 return true;
}

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

private static List<String> getMainTokenStrs(String[] tokens) {
 List<String> mainTokenStrs = new ArrayList<>(tokens.length);
 for (String text:tokens) {
  if ( !text.isEmpty() && ( text.length() >= 4 || Character.isUpperCase(text.charAt(0)) ) ) {
   mainTokenStrs.add(text);
  }
 }
 return mainTokenStrs;
}

代码示例来源:origin: shuzheng/zheng

/**
 * 首字母转大写
 * @param s
 * @return
 */
public static String toUpperCaseFirstOne(String s) {
  if (StringUtils.isBlank(s)) {
    return s;
  }
  if (Character.isUpperCase(s.charAt(0))) {
    return s;
  } else {
    return (new StringBuffer()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
  }
}

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

public static List<String> getMainStrs(List<String> tokens) {
 List<String> mainTokenStrs = new ArrayList<>(tokens.size());
 mainTokenStrs.addAll(tokens.stream().filter(text -> !text.isEmpty() && (text.length() >= 4 || Character.isUpperCase(text.charAt(0)))).collect(Collectors.toList()));
 return mainTokenStrs;
}

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

private static String getWordShape(String string) {
 if (string.toUpperCase().equals(string) && string.toLowerCase().equals(string)) return "no-case";
 if (string.toUpperCase().equals(string)) return "upper-case";
 if (string.toLowerCase().equals(string)) return "lower-case";
 if (string.length() > 1 && Character.isUpperCase(string.charAt(0)) && string.substring(1).toLowerCase().equals(string.substring(1)))
  return "capitalized";
 return "mixed-case";
}

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

private static String getWordShape(String string) {
 if (string.toUpperCase().equals(string) && string.toLowerCase().equals(string)) return "no-case";
 if (string.toUpperCase().equals(string)) return "upper-case";
 if (string.toLowerCase().equals(string)) return "lower-case";
 if (string.length() > 1 && Character.isUpperCase(string.charAt(0)) && string.substring(1).toLowerCase().equals(string.substring(1)))
  return "capitalized";
 return "mixed-case";
}

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

/**
 * Return the method suffixes for a given property name. The default implementation
 * uses JavaBean conventions with additional support for properties of the form 'xY'
 * where the method 'getXY()' is used in preference to the JavaBean convention of
 * 'getxY()'.
 */
protected String[] getPropertyMethodSuffixes(String propertyName) {
  String suffix = getPropertyMethodSuffix(propertyName);
  if (suffix.length() > 0 && Character.isUpperCase(suffix.charAt(0))) {
    return new String[] {suffix};
  }
  return new String[] {suffix, StringUtils.capitalize(suffix)};
}

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

public static String toPoolName(Class<?> poolType) {
  if (poolType == null) {
    throw new NullPointerException("poolType");
  }
  String poolName = StringUtil.simpleClassName(poolType);
  switch (poolName.length()) {
    case 0:
      return "unknown";
    case 1:
      return poolName.toLowerCase(Locale.US);
    default:
      if (Character.isUpperCase(poolName.charAt(0)) && Character.isLowerCase(poolName.charAt(1))) {
        return Character.toLowerCase(poolName.charAt(0)) + poolName.substring(1);
      } else {
        return poolName;
      }
  }
}

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

private static List<String> getMainTokenStrs(List<CoreLabel> tokens) {
 List<String> mainTokenStrs = new ArrayList<>(tokens.size());
 for (CoreLabel token:tokens) {
  String text = token.get(CoreAnnotations.TextAnnotation.class);
  if (!text.isEmpty() && ( text.length() >= 4 || Character.isUpperCase(text.charAt(0))) ) {
   mainTokenStrs.add(text);
  }
 }
 return mainTokenStrs;
}

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

@Override
public String getName(HandlerMethod handlerMethod, RequestMappingInfo mapping) {
  if (mapping.getName() != null) {
    return mapping.getName();
  }
  StringBuilder sb = new StringBuilder();
  String simpleTypeName = handlerMethod.getBeanType().getSimpleName();
  for (int i = 0 ; i < simpleTypeName.length(); i++) {
    if (Character.isUpperCase(simpleTypeName.charAt(i))) {
      sb.append(simpleTypeName.charAt(i));
    }
  }
  sb.append(SEPARATOR).append(handlerMethod.getMethod().getName());
  return sb.toString();
}

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

public static Set<String> readAnimacyList(String filename) {
 Set<String> animacyList = Generics.newHashSet();
 List<String> lines = IOUtils.linesFromFile(filename);
 for (String line : lines) {
  if (!Character.isUpperCase(line.charAt(0))) //ignore names
   animacyList.add(line);
 }
 return animacyList;
}

代码示例来源:origin: bumptech/glide

private String getClassNameString() {
 StringBuilder result = new StringBuilder();
 for (char c : testClass.getSimpleName().toCharArray()) {
  if (Character.isUpperCase(c)) {
   result.append(Character.toLowerCase(c));
  }
 }
 return result.toString();
}

相关文章

Character类方法