static ExpectedKeyOutput newInstance(final String outputText) {
   // If the <code>outputText</code> is one code point string, use {@link CodePoint} object.
   if (StringUtils.codePointCount(outputText) == 1) {
     return new Code(outputText.codePointAt(0));
   }
   return new Text(outputText);
 }
 @Override
 ExpectedKeyOutput toUpperCase(final Locale locale) {
   if (Constants.isLetterCode(mCode)) {
     final String codeString = StringUtils.newSingleCodePointString(mCode);
     // A letter may have an upper case counterpart that consists of multiple code
     // points, for instance the upper case of "ß" is "SS".
     return newInstance(codeString.toUpperCase(locale));
   }
   // A special negative value has no upper case.
   return this;
 }
  private boolean checkDistracterUsingGetSuggestions(final String testedWord) {
    if (mKeyboard == null) {
      return false;
    }
    final SettingsValuesForSuggestion settingsValuesForSuggestion =
        new SettingsValuesForSuggestion(
            false /* blockPotentiallyOffensive */,
            false /* spaceAwareGestureEnabled */,
            null /* additionalFeaturesSettingValues */);
    final int trailingSingleQuotesCount = StringUtils.getTrailingSingleQuotesCount(testedWord);
    final String consideredWord =
        trailingSingleQuotesCount > 0
            ? testedWord.substring(0, testedWord.length() - trailingSingleQuotesCount)
            : testedWord;
    final WordComposer composer = new WordComposer();
    final int[] codePoints = StringUtils.toCodePointArray(testedWord);

    synchronized (mLock) {
      final int[] coordinates = mKeyboard.getCoordinates(codePoints);
      composer.setComposingWord(codePoints, coordinates);
      final SuggestionResults suggestionResults =
          mDictionaryFacilitator.getSuggestionResults(
              composer,
              PrevWordsInfo.EMPTY_PREV_WORDS_INFO,
              mKeyboard.getProximityInfo(),
              settingsValuesForSuggestion,
              0 /* sessionId */);
      if (suggestionResults.isEmpty()) {
        return false;
      }
      final SuggestedWordInfo firstSuggestion = suggestionResults.first();
      final boolean isDistractor =
          suggestionExceedsDistracterThreshold(
              firstSuggestion, consideredWord, DISTRACTER_WORD_SCORE_THRESHOLD);
      if (DEBUG) {
        Log.d(TAG, "isDistracter: " + isDistractor);
      }
      return isDistractor;
    }
  }
 /**
  * Returns a localized character sequence describing what will happen when the specified key is
  * pressed based on its key code point.
  *
  * @param context The package's context.
  * @param codePoint The code point from which to obtain a description.
  * @return a character sequence describing the code point.
  */
 public String getDescriptionForCodePoint(final Context context, final int codePoint) {
   // If the key description should be obscured, now is the time to do it.
   final int index = mKeyCodeMap.indexOfKey(codePoint);
   if (index >= 0) {
     return context.getString(mKeyCodeMap.valueAt(index));
   }
   final String accentedLetter = getSpokenAccentedLetterDescription(context, codePoint);
   if (accentedLetter != null) {
     return accentedLetter;
   }
   // Here, <code>code</code> may be a base (non-accented) letter.
   final String unsupportedSymbol = getSpokenSymbolDescription(context, codePoint);
   if (unsupportedSymbol != null) {
     return unsupportedSymbol;
   }
   final String emojiDescription = getSpokenEmojiDescription(context, codePoint);
   if (emojiDescription != null) {
     return emojiDescription;
   }
   if (Character.isDefined(codePoint) && !Character.isISOControl(codePoint)) {
     return StringUtils.newSingleCodePointString(codePoint);
   }
   return null;
 }
 @Override
 boolean equalsTo(final String text) {
   return StringUtils.codePointCount(text) == 1 && text.codePointAt(0) == mCode;
 }
 @Override
 public String toString() {
   return Constants.isLetterCode(mCode)
       ? StringUtils.newSingleCodePointString(mCode)
       : Constants.printableCode(mCode);
 }