use of java.util.MissingResourceException in project j2objc by google.
the class Messages method loadResourceBundle.
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements ListResourceBundle,
* without language suffix.
* @return the ResourceBundle
* @throws MissingResourceException
* @xsl.usage internal
*/
private ListResourceBundle loadResourceBundle(String resourceBundle) throws MissingResourceException {
m_resourceBundleName = resourceBundle;
Locale locale = getLocale();
ListResourceBundle lrb;
try {
ResourceBundle rb = ResourceBundle.getBundle(m_resourceBundleName, locale);
lrb = (ListResourceBundle) rb;
} catch (MissingResourceException e) {
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
lrb = (ListResourceBundle) ResourceBundle.getBundle(m_resourceBundleName, new Locale("en", "US"));
} catch (MissingResourceException e2) {
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException("Could not load any resource bundles." + m_resourceBundleName, m_resourceBundleName, "");
}
}
m_resourceBundle = lrb;
return lrb;
}
use of java.util.MissingResourceException in project j2objc by google.
the class XSLTErrorResources method loadResourceBundle.
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className the name of the class that implements the resource bundle.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XSLTErrorResources loadResourceBundle(String className) throws MissingResourceException {
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try {
// first try with the given locale
return (XSLTErrorResources) ResourceBundle.getBundle(className + suffix, locale);
} catch (MissingResourceException e) {
try // try to fall back to en_US if we can't load
{
// fall back to en_US.
return (XSLTErrorResources) ResourceBundle.getBundle(className, new Locale("en", "US"));
} catch (MissingResourceException e2) {
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException("Could not load any resource bundles.", className, "");
}
}
}
use of java.util.MissingResourceException in project j2objc by google.
the class XPATHErrorResources method loadResourceBundle.
/**
* Return a named ResourceBundle for a particular locale. This method mimics the behavior
* of ResourceBundle.getBundle().
*
* @param className Name of local-specific subclass.
* @return the ResourceBundle
* @throws MissingResourceException
*/
public static final XPATHErrorResources loadResourceBundle(String className) throws MissingResourceException {
Locale locale = Locale.getDefault();
String suffix = getResourceSuffix(locale);
try {
// first try with the given locale
return (XPATHErrorResources) ResourceBundle.getBundle(className + suffix, locale);
} catch (MissingResourceException e) {
try // try to fall back to en_US if we can't load
{
// fall back to en_US.
return (XPATHErrorResources) ResourceBundle.getBundle(className, new Locale("en", "US"));
} catch (MissingResourceException e2) {
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException("Could not load any resource bundles.", className, "");
}
}
}
use of java.util.MissingResourceException in project android_frameworks_base by DirtyUnicorns.
the class TextToSpeechService method onLoadVoice.
/**
* Notifies the engine that it should load a speech synthesis voice. There is no guarantee
* that this method is always called before the voice is used for synthesis. It is merely
* a hint to the engine that it will probably get some synthesis requests for this voice
* at some point in the future.
*
* Will be called only on synthesis thread.
*
* The default implementation creates a Locale from the voice name (by interpreting the name as
* a BCP-47 tag for the locale), and passes it to
* {@link #onLoadLanguage(String, String, String)}.
*
* @param voiceName Name of the voice.
* @return {@link TextToSpeech#ERROR} or {@link TextToSpeech#SUCCESS}.
*/
public int onLoadVoice(String voiceName) {
Locale locale = Locale.forLanguageTag(voiceName);
if (locale == null) {
return TextToSpeech.ERROR;
}
int expectedStatus = getExpectedLanguageAvailableStatus(locale);
try {
int localeStatus = onIsLanguageAvailable(locale.getISO3Language(), locale.getISO3Country(), locale.getVariant());
if (localeStatus != expectedStatus) {
return TextToSpeech.ERROR;
}
onLoadLanguage(locale.getISO3Language(), locale.getISO3Country(), locale.getVariant());
return TextToSpeech.SUCCESS;
} catch (MissingResourceException e) {
return TextToSpeech.ERROR;
}
}
use of java.util.MissingResourceException in project android_frameworks_base by DirtyUnicorns.
the class TextToSpeechService method onIsValidVoiceName.
/**
* Checks whether the engine supports a voice with a given name.
*
* Can be called on multiple threads.
*
* The default implementation treats the voice name as a language tag, creating a Locale from
* the voice name, and passes it to {@link #onIsLanguageAvailable(String, String, String)}.
*
* @param voiceName Name of the voice.
* @return {@link TextToSpeech#ERROR} or {@link TextToSpeech#SUCCESS}.
*/
public int onIsValidVoiceName(String voiceName) {
Locale locale = Locale.forLanguageTag(voiceName);
if (locale == null) {
return TextToSpeech.ERROR;
}
int expectedStatus = getExpectedLanguageAvailableStatus(locale);
try {
int localeStatus = onIsLanguageAvailable(locale.getISO3Language(), locale.getISO3Country(), locale.getVariant());
if (localeStatus != expectedStatus) {
return TextToSpeech.ERROR;
}
return TextToSpeech.SUCCESS;
} catch (MissingResourceException e) {
return TextToSpeech.ERROR;
}
}
Aggregations