Search in sources :

Example 21 with MissingResourceException

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;
}
Also used : Locale(java.util.Locale) ListResourceBundle(java.util.ListResourceBundle) MissingResourceException(java.util.MissingResourceException) ResourceBundle(java.util.ResourceBundle) ListResourceBundle(java.util.ListResourceBundle)

Example 22 with MissingResourceException

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, "");
        }
    }
}
Also used : Locale(java.util.Locale) MissingResourceException(java.util.MissingResourceException)

Example 23 with MissingResourceException

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, "");
        }
    }
}
Also used : Locale(java.util.Locale) MissingResourceException(java.util.MissingResourceException)

Example 24 with MissingResourceException

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;
    }
}
Also used : Locale(java.util.Locale) MissingResourceException(java.util.MissingResourceException)

Example 25 with MissingResourceException

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;
    }
}
Also used : Locale(java.util.Locale) MissingResourceException(java.util.MissingResourceException)

Aggregations

MissingResourceException (java.util.MissingResourceException)151 ResourceBundle (java.util.ResourceBundle)77 Locale (java.util.Locale)66 ArrayList (java.util.ArrayList)10 IOException (java.io.IOException)8 MessageFormat (java.text.MessageFormat)8 File (java.io.File)7 HashMap (java.util.HashMap)7 Map (java.util.Map)7 SMSException (com.sun.identity.sm.SMSException)6 PropertyResourceBundle (java.util.PropertyResourceBundle)6 Secure.getString (android.provider.Settings.Secure.getString)5 SSOException (com.iplanet.sso.SSOException)5 InputStream (java.io.InputStream)4 ISResourceBundle (com.sun.identity.common.ISResourceBundle)3 Enumeration (java.util.Enumeration)3 Iterator (java.util.Iterator)3 List (java.util.List)3 Set (java.util.Set)3 AttributeSchema (com.sun.identity.sm.AttributeSchema)2