150 |
* second hash map is the localized name, the value is a soft |
* second hash map is the localized name, the value is a soft |
151 |
* references to the resource bundle. |
* references to the resource bundle. |
152 |
*/ |
*/ |
153 |
private static final Map resourceBundleCache = new HashMap(); |
private static Map resourceBundleCache; |
154 |
|
|
155 |
|
/** |
156 |
|
* The last default Locale we saw. If this ever changes then we have to |
157 |
|
* reset our caches. |
158 |
|
*/ |
159 |
|
private static Locale lastDefaultLocale; |
160 |
|
|
161 |
/** |
/** |
162 |
* The `empty' locale is created once in order to optimize |
* The `empty' locale is created once in order to optimize |
357 |
{ |
{ |
358 |
// This implementation searches the bundle in the reverse direction |
// This implementation searches the bundle in the reverse direction |
359 |
// and builds the parent chain on the fly. |
// and builds the parent chain on the fly. |
360 |
|
Locale defaultLocale = Locale.getDefault(); |
361 |
|
if (defaultLocale != lastDefaultLocale) |
362 |
|
{ |
363 |
|
resourceBundleCache = new HashMap(); |
364 |
|
lastDefaultLocale = defaultLocale; |
365 |
|
} |
366 |
HashMap cache = (HashMap) resourceBundleCache.get(classLoader); |
HashMap cache = (HashMap) resourceBundleCache.get(classLoader); |
367 |
StringBuffer sb = new StringBuffer(60); |
StringBuffer sb = new StringBuffer(60); |
368 |
sb.append(baseName).append('_').append(locale); |
sb.append(baseName).append('_').append(locale); |
410 |
// bundle. |
// bundle. |
411 |
ResourceBundle bundle = tryLocalBundle(baseName, locale, |
ResourceBundle bundle = tryLocalBundle(baseName, locale, |
412 |
classLoader, baseBundle, cache); |
classLoader, baseBundle, cache); |
413 |
if (bundle == baseBundle && !locale.equals(Locale.getDefault())) |
if (bundle == baseBundle && !locale.equals(defaultLocale)) |
414 |
{ |
{ |
415 |
bundle = tryLocalBundle(baseName, Locale.getDefault(), |
bundle = tryLocalBundle(baseName, defaultLocale, |
416 |
classLoader, baseBundle, cache); |
classLoader, baseBundle, cache); |
417 |
// We need to record that the argument locale maps to the |
// We need to record that the argument locale maps to the |
418 |
// bundle we just found. If we didn't find a bundle, record |
// bundle we just found. If we didn't find a bundle, record |