/** * Change to sentence case - that is first character in caps, the rest in lower. * * @param word The word to be manipulated * @return The altered word */ public static String toSentenceCase(String word) { assert word != null; if (word.length() == 0) { return ""; } return Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase(LocaleProviderManager.getLocale()); }
/** * What case is the specified word?. A blank word is LOWER, a word with a single upper case letter * is SENTENCE and not UPPER - Simply because this is more likely, however TO BE SURE I WOULD NEED * TO THE CONTEXT. I could not tell otherwise. * * <p>The issue here is that getCase("FreD") is undefined. Telling if this is SENTENCE * (Tubal-Cain) or MIXED (really the case) is complex and would slow things down for a case that I * don't believe happens with Bible text. * * @param word The word to be tested * @return LOWER, SENTENCE, UPPER or MIXED * @exception IllegalArgumentException is the word is null */ public static CaseType getCase(String word) { assert word != null; // Blank word if (word.length() == 0) { return LOWER; } // Lower case? if (word.equals(word.toLowerCase(LocaleProviderManager.getLocale()))) { return LOWER; } // Upper case? // A string length of 1 is no good ('I' or 'A' is sentence case) if (word.equals(word.toUpperCase(LocaleProviderManager.getLocale())) && word.length() != 1) { return UPPER; } // So ... return SENTENCE; }
/** * Gets the localized bible names, based on the {@link LocaleProviderManager} * * @return the localized bible names */ private NameList getLocalizedBibleNames() { // Get the current Locale return getBibleNamesForLocale(LocaleProviderManager.getLocale()); }
/** * Gets the localised countries. * * @return the localised countries */ private static ResourceBundle getLocalisedCountries() { return ResourceBundle.getBundle( "iso3166", LocaleProviderManager.getLocale(), CWClassLoader.instance()); }
@Override public String setCase(String word) { return word.toUpperCase(LocaleProviderManager.getLocale()); }