com.google.common.base.Ascii.isUpperCase()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(112)

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

Ascii.isUpperCase介绍

[英]Indicates whether c is one of the twenty-six uppercase ASCII alphabetic characters between 'A' and 'Z' inclusive. All others (including non-ASCII characters) return false.
[中]指示c是否是介于“A”和“Z”之间的二十六个大写ASCII字母字符之一(含)。所有其他字符(包括非ASCII字符)返回false。

代码示例

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

private boolean hasUpperCase() {
 for (char c : chars) {
  if (Ascii.isUpperCase(c)) {
   return true;
  }
 }
 return false;
}

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

/**
 * If the argument is an {@linkplain #isUpperCase(char) uppercase ASCII character} returns the
 * lowercase equivalent. Otherwise returns the argument.
 */
public static char toLowerCase(char c) {
 return isUpperCase(c) ? (char) (c ^ CASE_MASK) : c;
}

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

private boolean hasUpperCase() {
 for (char c : chars) {
  if (Ascii.isUpperCase(c)) {
   return true;
  }
 }
 return false;
}

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

/**
 * If the argument is an {@linkplain #isUpperCase(char) uppercase ASCII character} returns the
 * lowercase equivalent. Otherwise returns the argument.
 */
public static char toLowerCase(char c) {
 return isUpperCase(c) ? (char) (c ^ CASE_MASK) : c;
}

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

private boolean hasUpperCase() {
 for (char c : chars) {
  if (Ascii.isUpperCase(c)) {
   return true;
  }
 }
 return false;
}

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

/**
 * If the argument is an {@linkplain #isUpperCase(char) uppercase ASCII character} returns the
 * lowercase equivalent. Otherwise returns the argument.
 */
public static char toLowerCase(char c) {
 return isUpperCase(c) ? (char) (c ^ CASE_MASK) : c;
}

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

/**
 * Returns a copy of the input string in which all {@linkplain #isUpperCase(char) uppercase ASCII
 * characters} have been converted to lowercase. All other characters are copied without
 * modification.
 */
public static String toLowerCase(String string) {
 int length = string.length();
 for (int i = 0; i < length; i++) {
  if (isUpperCase(string.charAt(i))) {
   char[] chars = string.toCharArray();
   for (; i < length; i++) {
    char c = chars[i];
    if (isUpperCase(c)) {
     chars[i] = (char) (c ^ CASE_MASK);
    }
   }
   return String.valueOf(chars);
  }
 }
 return string;
}

代码示例来源:origin: google/error-prone

@VisibleForTesting
static String fromSecondLevel(String qualifiedTemplateClass) {
 List<String> path = Splitter.on('.').splitToList(qualifiedTemplateClass);
 for (int topLevel = 0; topLevel < path.size() - 1; topLevel++) {
  if (Ascii.isUpperCase(path.get(topLevel).charAt(0))) {
   return Joiner.on('_').join(path.subList(topLevel + 1, path.size()));
  }
 }
 return Iterables.getLast(path);
}

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

/**
 * Returns a copy of the input string in which all {@linkplain #isUpperCase(char) uppercase ASCII
 * characters} have been converted to lowercase. All other characters are copied without
 * modification.
 */
public static String toLowerCase(String string) {
 int length = string.length();
 for (int i = 0; i < length; i++) {
  if (isUpperCase(string.charAt(i))) {
   char[] chars = string.toCharArray();
   for (; i < length; i++) {
    char c = chars[i];
    if (isUpperCase(c)) {
     chars[i] = (char) (c ^ CASE_MASK);
    }
   }
   return String.valueOf(chars);
  }
 }
 return string;
}

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

/**
 * Returns a copy of the input string in which all {@linkplain #isUpperCase(char) uppercase ASCII
 * characters} have been converted to lowercase. All other characters are copied without
 * modification.
 */
public static String toLowerCase(String string) {
 int length = string.length();
 for (int i = 0; i < length; i++) {
  if (isUpperCase(string.charAt(i))) {
   char[] chars = string.toCharArray();
   for (; i < length; i++) {
    char c = chars[i];
    if (isUpperCase(c)) {
     chars[i] = (char) (c ^ CASE_MASK);
    }
   }
   return String.valueOf(chars);
  }
 }
 return string;
}

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

@Override
public String apply(String input) {
 unresolved = false;
 boolean assumedUnqualified = Ascii.isUpperCase(input.charAt(0));
 if (assumedUnqualified) {
  input = qualifyImportedIfPossible(input, false);
 }
 return input;
}

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

public String apply(String input) {
  if (!input.isEmpty()) {
   if (this == CAPITALIZED && !Ascii.isUpperCase(input.charAt(0))) {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, input);
   }
   if (this == LOWERIZED && !Ascii.isLowerCase(input.charAt(0))) {
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, input);
   }
  }
  return input;
 }
}

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

String resolveTopForAttribute(String input) {
 unresolved = false;
 boolean assumedUnqualified = Ascii.isUpperCase(input.charAt(0));
 if (assumedUnqualified) {
  input = qualifyImportedIfPossible(input, !unresolvedYetArguments.contains(input));
 }
 return input;
}

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

@Override
public String detect(String identifier) {
 if (identifier.length() <= lengthsOfPrefixAndSuffix) {
  return NOT_DETECTED;
 }
 boolean prefixMatches = prefix.isEmpty() ||
   (identifier.startsWith(prefix) && Ascii.isUpperCase(identifier.charAt(prefix.length())));
 boolean suffixMatches = suffix.isEmpty() || identifier.endsWith(suffix);
 if (prefixMatches && suffixMatches) {
  String detected = identifier.substring(prefix.length(), identifier.length() - suffix.length());
  return prefix.isEmpty()
    ? detected
    : CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, detected);
 }
 return NOT_DETECTED;
}

代码示例来源:origin: line/armeria

@VisibleForTesting
static String toHeaderName(String name) {
  requireNonNull(name, "name");
  checkArgument(!name.isEmpty(), "name is empty");
  final String upperCased = Ascii.toUpperCase(name);
  if (name.equals(upperCased)) {
    return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name);
  }
  final String lowerCased = Ascii.toLowerCase(name);
  if (name.equals(lowerCased)) {
    return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name);
  }
  // Ensure that the name does not contain '_'.
  // If it contains '_', we give up to make it lower hyphen case. Just converting it to lower case.
  if (name.indexOf('_') >= 0) {
    return lowerCased;
  }
  if (Ascii.isUpperCase(name.charAt(0))) {
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name);
  } else {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name);
  }
}

代码示例来源:origin: google/error-prone

&& Ascii.isUpperCase(identifier.charAt(1))
&& Ascii.isLowerCase(identifier.charAt(2))) {

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

private static boolean shouldDisableFor(Reporter reporter, Element element) {
  while (element != null) {
   if (element.getKind() == ElementKind.PACKAGE) {
    for (String segment : DOT_SPLITTER.split(((PackageElement) element).getQualifiedName())) {
     if (!segment.isEmpty() && Ascii.isUpperCase(segment.charAt(0))) {
      reporter.warning(About.INCOMPAT, WARNING_START + " uppercase package names");
      return true;
     }
    }
   }
   if (element.getKind().isClass() || element.getKind().isInterface()) {
    if (Ascii.isLowerCase(element.getSimpleName().charAt(0))) {
     reporter.warning(About.INCOMPAT, WARNING_START + " lowercase class names");
     return true;
    }
   }
   element = element.getEnclosingElement();
  }
  return false;
 }
}

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

public void testCharsLower() {
 for (char c : LOWER.toCharArray()) {
  String str = String.valueOf(c);
  assertTrue(str, c == Ascii.toLowerCase(c));
  assertFalse(str, c == Ascii.toUpperCase(c));
  assertTrue(str, Ascii.isLowerCase(c));
  assertFalse(str, Ascii.isUpperCase(c));
 }
}

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

public void testCharsUpper() {
 for (char c : UPPER.toCharArray()) {
  String str = String.valueOf(c);
  assertFalse(str, c == Ascii.toLowerCase(c));
  assertTrue(str, c == Ascii.toUpperCase(c));
  assertFalse(str, Ascii.isLowerCase(c));
  assertTrue(str, Ascii.isUpperCase(c));
 }
}

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

public void testCharsIgnored() {
 for (char c : IGNORED.toCharArray()) {
  String str = String.valueOf(c);
  assertTrue(str, c == Ascii.toLowerCase(c));
  assertTrue(str, c == Ascii.toUpperCase(c));
  assertFalse(str, Ascii.isLowerCase(c));
  assertFalse(str, Ascii.isUpperCase(c));
 }
}

相关文章