本文整理了Java中com.google.common.base.Ascii.toUpperCase()
方法的一些代码示例,展示了Ascii.toUpperCase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ascii.toUpperCase()
方法的具体详情如下:
包路径:com.google.common.base.Ascii
类名称:Ascii
方法名:toUpperCase
[英]If the argument is a #isLowerCase(char) returns the uppercase equivalent. Otherwise returns the argument.
[中]如果参数为#isLowerCase(char),则返回等效的大写字母。否则返回参数。
代码示例来源:origin: google/guava
@Override
String normalizeWord(String word) {
return Ascii.toUpperCase(word);
}
代码示例来源:origin: google/j2objc
@Override
String normalizeWord(String word) {
return Ascii.toUpperCase(word);
}
代码示例来源:origin: google/guava
/**
* Returns a copy of the input character sequence in which all {@linkplain #isLowerCase(char)
* lowercase ASCII characters} have been converted to uppercase. All other characters are copied
* without modification.
*
* @since 14.0
*/
public static String toUpperCase(CharSequence chars) {
if (chars instanceof String) {
return toUpperCase((String) chars);
}
char[] newChars = new char[chars.length()];
for (int i = 0; i < newChars.length; i++) {
newChars[i] = toUpperCase(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
String convert(CaseFormat format, String s) {
if (format == LOWER_UNDERSCORE) {
return s.replace('-', '_');
}
if (format == UPPER_UNDERSCORE) {
return Ascii.toUpperCase(s.replace('-', '_'));
}
return super.convert(format, s);
}
},
代码示例来源:origin: google/guava
@Override
String convert(CaseFormat format, String s) {
if (format == LOWER_HYPHEN) {
return s.replace('_', '-');
}
if (format == UPPER_UNDERSCORE) {
return Ascii.toUpperCase(s);
}
return super.convert(format, s);
}
},
代码示例来源:origin: google/error-prone
@Override
public Target convert(String arg) {
return Target.valueOf(Ascii.toUpperCase(arg));
}
}
代码示例来源:origin: google/j2objc
private static String firstCharOnlyToUpper(String word) {
return (word.isEmpty())
? word
: Ascii.toUpperCase(word.charAt(0)) + Ascii.toLowerCase(word.substring(1));
}
}
代码示例来源:origin: google/j2objc
@Override
String convert(CaseFormat format, String s) {
if (format == LOWER_UNDERSCORE) {
return s.replace('-', '_');
}
if (format == UPPER_UNDERSCORE) {
return Ascii.toUpperCase(s.replace('-', '_'));
}
return super.convert(format, s);
}
},
代码示例来源:origin: google/j2objc
@Override
String convert(CaseFormat format, String s) {
if (format == LOWER_HYPHEN) {
return s.replace('_', '-');
}
if (format == UPPER_UNDERSCORE) {
return Ascii.toUpperCase(s);
}
return super.convert(format, s);
}
},
代码示例来源:origin: google/guava
Alphabet upperCase() {
if (!hasLowerCase()) {
return this;
} else {
checkState(!hasUpperCase(), "Cannot call upperCase() on a mixed-case alphabet");
char[] upperCased = new char[chars.length];
for (int i = 0; i < chars.length; i++) {
upperCased[i] = Ascii.toUpperCase(chars[i]);
}
return new Alphabet(name + ".upperCase()", upperCased);
}
}
代码示例来源:origin: google/guava
@Override
public M create(Object... elements) {
Multimap<String, String> multimap = ArrayListMultimap.create();
for (Object o : elements) {
@SuppressWarnings("unchecked")
Entry<String, String> entry = (Entry<String, String>) o;
multimap.put(entry.getKey(), Ascii.toUpperCase(entry.getValue()));
}
return transform(multimap);
}
代码示例来源:origin: google/guava
public void testToUpperCase() {
assertEquals(UPPER, Ascii.toUpperCase(LOWER));
assertSame(UPPER, Ascii.toUpperCase(UPPER));
assertEquals(IGNORED, Ascii.toUpperCase(IGNORED));
assertEquals("FOOBAR", Ascii.toUpperCase("FoOBAr"));
}
代码示例来源:origin: google/j2objc
Alphabet upperCase() {
if (!hasLowerCase()) {
return this;
} else {
checkState(!hasUpperCase(), "Cannot call upperCase() on a mixed-case alphabet");
char[] upperCased = new char[chars.length];
for (int i = 0; i < chars.length; i++) {
upperCased[i] = Ascii.toUpperCase(chars[i]);
}
return new Alphabet(name + ".upperCase()", upperCased);
}
}
代码示例来源:origin: google/error-prone
/** Returns true if the given symbol has static modifier and is all upper case. */
private static boolean isUpperCaseAndStatic(Symbol symbol) {
return symbol.isStatic()
&& symbol.name.contentEquals(Ascii.toUpperCase(symbol.name.toString()));
}
代码示例来源: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
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
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));
}
内容来源于网络,如有侵权,请联系作者删除!