public static int toUpperCaseOfCodeForLocale( final int code, final boolean needsToUpperCase, final Locale locale) { if (!KeyboardConstants.isLetterCode(code) || !needsToUpperCase) return code; final String text = new String(new int[] {code}, 0, 1); final String casedText = KeySpecParser.toUpperCaseOfStringForLocale(text, needsToUpperCase, locale); return StringUtils.codePointCount(casedText) == 1 ? casedText.codePointAt(0) : CODE_UNSPECIFIED; }
static String getOutputText(final String moreKeySpec) { if (hasCode(moreKeySpec)) { return null; } final String outputText = getOutputTextInternal(moreKeySpec); if (outputText != null) { if (StringUtils.codePointCount(outputText) == 1) { // If output text is one code point, it should be treated as a code. // See {@link #getCode(Resources, String)}. return null; } if (!TextUtils.isEmpty(outputText)) { return outputText; } throw new KeySpecParserError("Empty outputText: " + moreKeySpec); } final String label = getLabel(moreKeySpec); if (label == null) { throw new KeySpecParserError("Empty label: " + moreKeySpec); } // Code is automatically generated for one letter label. See {@link getCode()}. return (StringUtils.codePointCount(label) == 1) ? null : label; }
static int getCode(final String moreKeySpec, final KeyboardCodesSet codesSet) { if (hasCode(moreKeySpec)) { final int end = indexOfLabelEnd(moreKeySpec, 0); if (indexOfLabelEnd(moreKeySpec, end + 1) >= 0) { throw new KeySpecParserError("Multiple " + VERTICAL_BAR + ": " + moreKeySpec); } return parseCode(moreKeySpec.substring(end + 1), codesSet, CODE_UNSPECIFIED); } final String outputText = getOutputTextInternal(moreKeySpec); if (outputText != null) { // If output text is one code point, it should be treated as a code. // See {@link #getOutputText(String)}. if (StringUtils.codePointCount(outputText) == 1) { return outputText.codePointAt(0); } return CODE_OUTPUT_TEXT; } final String label = getLabel(moreKeySpec); // Code is automatically generated for one letter label. if (StringUtils.codePointCount(label) == 1) { return label.codePointAt(0); } return CODE_OUTPUT_TEXT; }