/** * If the argument is a {@linkplain #isLowerCase(char) lowercase ASCII character} returns the * uppercase equivalent. Otherwise returns the argument. */ public static char toUpperCase(char c) { return isLowerCase(c) ? (char) (c & 0x5f) : c; }
private boolean hasUpperCase() { for (char c : chars) { if (Ascii.isUpperCase(c)) { return true; } } return false; }
@Override String normalizeWord(String word) { return Ascii.toLowerCase(word); }
private static String firstCharOnlyToUpper(String word) { return (word.isEmpty()) ? word : Ascii.toUpperCase(word.charAt(0)) + Ascii.toLowerCase(word.substring(1)); } }
@Override String normalizeWord(String word) { return Ascii.toUpperCase(word); }
@Override public String toString() { return "CharSource.wrap(" + Ascii.truncate(seq, 30, "...") + ")"; } }
continue; int alphaIndex = getAlphaIndex(c1); if (alphaIndex < 26 && alphaIndex == getAlphaIndex(c2)) { continue;
/** * 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); }
@Override public String toString() { return "ByteSource.wrap(" + Ascii.truncate(BaseEncoding.base16().encode(bytes, offset, length), 30, "...") + ")"; } }
@Override String normalizeWord(String word) { return Ascii.toLowerCase(word); }
@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); } },
private boolean hasLowerCase() { for (char c : chars) { if (Ascii.isLowerCase(c)) { return true; } } return false; }
/** * 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 ^ 0x20) : c; }
private static String normalizeParameterValue(String attribute, String value) { return CHARSET_ATTRIBUTE.equals(attribute) ? Ascii.toLowerCase(value) : value; }
@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); } },
/** * Returns a copy of the input string in which all {@linkplain #isLowerCase(char) lowercase ASCII * characters} have been converted to uppercase. All other characters are copied without * modification. */ public static String toUpperCase(String string) { int length = string.length(); for (int i = 0; i < length; i++) { if (isLowerCase(string.charAt(i))) { char[] chars = string.toCharArray(); for (; i < length; i++) { char c = chars[i]; if (isLowerCase(c)) { chars[i] = (char) (c & 0x5f); } } return String.valueOf(chars); } } return string; }
/** * 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 ^ 0x20); } } return String.valueOf(chars); } } return string; }
@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); } };
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); } }
/** * 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); }