Java String Find findResourceBundle(String aBundleName, Locale locale)

Here you can find the source of findResourceBundle(String aBundleName, Locale locale)

Description

Finds the given resorce bundle by it's name.

License

Open Source License

Parameter

Parameter Description
aBundleName the name of the bundle (usually it's FQN classname).
locale the locale.

Return

the bundle, null if not found.

Declaration

public static ResourceBundle findResourceBundle(String aBundleName, Locale locale) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    private static final Collection misses = new HashSet();
    /**//from   w ww . ja v  a2 s .co m
     * @GuardedBy #misses
     */
    private static ClassLoader delegatedClassLoader;

    /**
     * Finds the given resorce bundle by it's name.
     * <p/>
     * Will use <code>Thread.currentThread().getContextClassLoader()</code> as the classloader.
     * If {@link #delegatedClassLoader} is defined and the bundle cannot be found the current classloader it will delegate to that.
     * 
     * @param aBundleName  the name of the bundle (usually it's FQN classname).
     * @param locale       the locale.
     * @return  the bundle, <tt>null</tt> if not found.
     */
    public static ResourceBundle findResourceBundle(String aBundleName, Locale locale) {
        synchronized (misses) {
            try {
                if (!misses.contains(aBundleName)) {
                    return ResourceBundle.getBundle(aBundleName, locale,
                            Thread.currentThread().getContextClassLoader());
                }
            } catch (MissingResourceException ex) {

                if (delegatedClassLoader != null) {
                    try {
                        return ResourceBundle.getBundle(aBundleName, locale, delegatedClassLoader);
                    } catch (MissingResourceException e) {
                        misses.add(aBundleName);
                    }
                } else {
                    misses.add(aBundleName);
                }
            }
        }

        return null;
    }
}

Related

  1. findAllIndexes(String str, String searchStr)
  2. findAllOccurences(String str, String pattern)
  3. findAllOccurrences(String str, String substr)
  4. findAllSubsequences(String str)
  5. findParam(String src, char patternFrom, char patternTo)
  6. getAllOccurences(String str, char guess)
  7. getOccurenceIndices(String inSubject, String inOccurence)
  8. getSearchTermOccurrences(final String searchTerm, final String content)
  9. indexOfOccurance(String s1, String s2, Integer i)