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

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

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

Ascii.toLowerCase介绍

[英]If the argument is an #isUpperCase(char) returns the lowercase equivalent. Otherwise returns the argument.
[中]如果参数为#isUpperCase(char),则返回小写等效值。否则返回参数。

代码示例

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

@Override
String normalizeWord(String word) {
 return Ascii.toLowerCase(word);
}

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

@Override
String normalizeWord(String word) {
 return Ascii.toLowerCase(word);
}

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

private static String normalizeParameterValue(String attribute, String value) {
 return CHARSET_ATTRIBUTE.equals(attribute) ? Ascii.toLowerCase(value) : value;
}

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

@Override
 String convert(CaseFormat format, String s) {
  if (format == LOWER_HYPHEN) {
   return Ascii.toLowerCase(s.replace('_', '-'));
  }
  if (format == LOWER_UNDERSCORE) {
   return Ascii.toLowerCase(s);
  }
  return super.convert(format, s);
 }
};

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

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

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

private static String firstCharOnlyToUpper(String word) {
  return word.isEmpty()
    ? word
    : Ascii.toUpperCase(word.charAt(0)) + Ascii.toLowerCase(word.substring(1));
 }
}

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

@Override
 public String apply(String value) {
  return Ascii.toLowerCase(value);
 }
};

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

@Override
 public String transformEntry(String key, String value) {
  return Ascii.toLowerCase(value);
 }
};

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

private static String normalizeToken(String token) {
 checkArgument(TOKEN_MATCHER.matchesAllOf(token));
 return Ascii.toLowerCase(token);
}

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

private String normalizeFirstWord(String word) {
 return (this == LOWER_CAMEL) ? Ascii.toLowerCase(word) : normalizeWord(word);
}

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

Alphabet lowerCase() {
 if (!hasUpperCase()) {
  return this;
 } else {
  checkState(!hasLowerCase(), "Cannot call lowerCase() on a mixed-case alphabet");
  char[] lowerCased = new char[chars.length];
  for (int i = 0; i < chars.length; i++) {
   lowerCased[i] = Ascii.toLowerCase(chars[i]);
  }
  return new Alphabet(name + ".lowerCase()", lowerCased);
 }
}

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

public void testToLowerCase() {
 assertEquals(LOWER, Ascii.toLowerCase(UPPER));
 assertSame(LOWER, Ascii.toLowerCase(LOWER));
 assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
 assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
}

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

private static String upperToHttpHeaderName(
   String constantName,
   ImmutableBiMap<String, String> specialCases,
   ImmutableSet<String> uppercaseAcronyms) {
  if (specialCases.containsKey(constantName)) {
   return specialCases.get(constantName);
  }
  List<String> parts = Lists.newArrayList();
  for (String part : SPLITTER.split(constantName)) {
   if (!uppercaseAcronyms.contains(part)) {
    part = part.charAt(0) + Ascii.toLowerCase(part.substring(1));
   }
   parts.add(part);
  }
  return JOINER.join(parts);
 }
}

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

public void testToString() {
 for (String inputName : SOMEWHERE_UNDER_PS) {
  InternetDomainName domain = InternetDomainName.from(inputName);
  /*
   * We would ordinarily use constants for the expected results, but
   * doing it by derivation allows us to reuse the test case definitions
   * used in other tests.
   */
  String expectedName = Ascii.toLowerCase(inputName);
  expectedName = expectedName.replaceAll("[\u3002\uFF0E\uFF61]", ".");
  if (expectedName.endsWith(".")) {
   expectedName = expectedName.substring(0, expectedName.length() - 1);
  }
  assertEquals(expectedName, domain.toString());
 }
}

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

public void testGetKeyMatchesString() {
 for (StandardSystemProperty property : StandardSystemProperty.values()) {
  String fieldName = property.name();
  String expected = Ascii.toLowerCase(fieldName).replaceAll("_", ".");
  assertEquals(expected, property.key());
 }
}

代码示例来源: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));
 }
}

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

private static void testEncodingWithCasing(
  BaseEncoding encoding, String decoded, String encoded) {
 testEncodingWithSeparators(encoding, decoded, encoded);
 testEncodingWithSeparators(encoding.upperCase(), decoded, Ascii.toUpperCase(encoded));
 testEncodingWithSeparators(encoding.lowerCase(), decoded, Ascii.toLowerCase(encoded));
}

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

@GwtIncompatible // Reader/Writer
private static void testStreamingEncodingWithCasing(
  BaseEncoding encoding, String decoded, String encoded) throws IOException {
 testStreamingEncodingWithSeparators(encoding, decoded, encoded);
 testStreamingEncodingWithSeparators(encoding.upperCase(), decoded, Ascii.toUpperCase(encoded));
 testStreamingEncodingWithSeparators(encoding.lowerCase(), decoded, Ascii.toLowerCase(encoded));
}

相关文章