summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/java/util/ResourceBundle.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/util/ResourceBundle.java')
-rw-r--r--libjava/classpath/java/util/ResourceBundle.java164
1 files changed, 82 insertions, 82 deletions
diff --git a/libjava/classpath/java/util/ResourceBundle.java b/libjava/classpath/java/util/ResourceBundle.java
index 21243403c5f..966eb026c7e 100644
--- a/libjava/classpath/java/util/ResourceBundle.java
+++ b/libjava/classpath/java/util/ResourceBundle.java
@@ -95,7 +95,7 @@ public abstract class ResourceBundle
/**
* Maximum size of our cache of <code>ResourceBundle</code>s keyed by
* {@link BundleKey} instances.
- *
+ *
* @see BundleKey
*/
private static final int CACHE_SIZE = 100;
@@ -120,7 +120,7 @@ public abstract class ResourceBundle
* {@link #CACHE_SIZE} accessed <code>ResourceBundle</code>s keyed by the
* tuple: default locale, resource-bundle name, resource-bundle locale, and
* classloader.
- *
+ *
* @see BundleKey
*/
private static Map<BundleKey,Object> bundleCache =
@@ -188,8 +188,8 @@ public abstract class ResourceBundle
String className = getClass().getName();
throw new MissingResourceException("Key '" + key
- + "'not found in Bundle: "
- + className, className, key);
+ + "'not found in Bundle: "
+ + className, className, key);
}
/**
@@ -270,7 +270,7 @@ public abstract class ResourceBundle
{
set(dl, s, l, cl);
}
-
+
void set(Locale dl, String s, Locale l, ClassLoader cl)
{
defaultLocale = dl;
@@ -280,12 +280,12 @@ public abstract class ResourceBundle
hashcode = defaultLocale.hashCode() ^ baseName.hashCode()
^ locale.hashCode() ^ classLoader.hashCode();
}
-
+
public int hashCode()
{
return hashcode;
}
-
+
public boolean equals(Object o)
{
if (! (o instanceof BundleKey))
@@ -296,7 +296,7 @@ public abstract class ResourceBundle
&& baseName.equals(key.baseName)
&& locale.equals(key.locale)
&& classLoader.equals(key.classLoader);
- }
+ }
public String toString()
{
@@ -313,11 +313,11 @@ public abstract class ResourceBundle
return builder.toString();
}
}
-
+
/** A cache lookup key. This avoids having to a new one for every
* getBundle() call. */
private static final BundleKey lookupKey = new BundleKey();
-
+
/** Singleton cache entry to represent previous failed lookups. */
private static final Object nullEntry = new Object();
@@ -383,7 +383,7 @@ public abstract class ResourceBundle
* <li>Locale("es", "ES"): result MyResources_es_ES.class, parent
* MyResources.class</li>
* </ul>
- *
+ *
* <p>The file MyResources_fr_CH.properties is never used because it is hidden
* by MyResources_fr_CH.class.</p>
*
@@ -475,38 +475,38 @@ public abstract class ResourceBundle
rbClass = Class.forName(localizedName);
else
rbClass = classloader.loadClass(localizedName);
- // Note that we do the check up front instead of catching
- // ClassCastException. The reason for this is that some crazy
- // programs (Eclipse) have classes that do not extend
- // ResourceBundle but that have the same name as a property
- // bundle; in fact Eclipse relies on ResourceBundle not
- // instantiating these classes.
- if (ResourceBundle.class.isAssignableFrom(rbClass))
- bundle = (ResourceBundle) rbClass.newInstance();
+ // Note that we do the check up front instead of catching
+ // ClassCastException. The reason for this is that some crazy
+ // programs (Eclipse) have classes that do not extend
+ // ResourceBundle but that have the same name as a property
+ // bundle; in fact Eclipse relies on ResourceBundle not
+ // instantiating these classes.
+ if (ResourceBundle.class.isAssignableFrom(rbClass))
+ bundle = (ResourceBundle) rbClass.newInstance();
}
catch (Exception ex) {}
if (bundle == null)
{
- try
- {
- InputStream is;
- String resourceName
- = localizedName.replace('.', '/') + ".properties";
- if (classloader == null)
- is = ClassLoader.getSystemResourceAsStream(resourceName);
- else
- is = classloader.getResourceAsStream(resourceName);
- if (is != null)
- bundle = new PropertyResourceBundle(is);
- }
- catch (IOException ex)
- {
- MissingResourceException mre = new MissingResourceException
- ("Failed to load bundle: " + localizedName, localizedName, "");
- mre.initCause(ex);
- throw mre;
- }
+ try
+ {
+ InputStream is;
+ String resourceName
+ = localizedName.replace('.', '/') + ".properties";
+ if (classloader == null)
+ is = ClassLoader.getSystemResourceAsStream(resourceName);
+ else
+ is = classloader.getResourceAsStream(resourceName);
+ if (is != null)
+ bundle = new PropertyResourceBundle(is);
+ }
+ catch (IOException ex)
+ {
+ MissingResourceException mre = new MissingResourceException
+ ("Failed to load bundle: " + localizedName, localizedName, "");
+ mre.initCause(ex);
+ throw mre;
+ }
}
return bundle;
@@ -524,13 +524,13 @@ public abstract class ResourceBundle
* @return the resource bundle if it was loaded, otherwise the backup
*/
private static ResourceBundle tryBundle(String baseName, Locale locale,
- ClassLoader classLoader,
- boolean wantBase)
+ ClassLoader classLoader,
+ boolean wantBase)
{
String language = locale.getLanguage();
String country = locale.getCountry();
String variant = locale.getVariant();
-
+
int baseLen = baseName.length();
// Build up a CPStringBuilder containing the complete bundle name, fully
@@ -538,23 +538,23 @@ public abstract class ResourceBundle
CPStringBuilder sb = new CPStringBuilder(baseLen + variant.length() + 7);
sb.append(baseName);
-
+
if (language.length() > 0)
{
- sb.append('_');
- sb.append(language);
-
- if (country.length() > 0)
- {
- sb.append('_');
- sb.append(country);
-
- if (variant.length() > 0)
- {
- sb.append('_');
- sb.append(variant);
- }
- }
+ sb.append('_');
+ sb.append(language);
+
+ if (country.length() > 0)
+ {
+ sb.append('_');
+ sb.append(country);
+
+ if (variant.length() > 0)
+ {
+ sb.append('_');
+ sb.append(variant);
+ }
+ }
}
// Now try to load bundles, starting with the most specialized name.
@@ -562,28 +562,28 @@ public abstract class ResourceBundle
String bundleName = sb.toString();
ResourceBundle first = null; // The most specialized bundle.
ResourceBundle last = null; // The least specialized bundle.
-
+
while (true)
{
ResourceBundle foundBundle = tryBundle(bundleName, classLoader);
- if (foundBundle != null)
- {
- if (first == null)
- first = foundBundle;
- if (last != null)
- last.parent = foundBundle;
- foundBundle.locale = locale;
- last = foundBundle;
- }
- int idx = bundleName.lastIndexOf('_');
- // Try the non-localized base name only if we already have a
- // localized child bundle, or wantBase is true.
- if (idx > baseLen || (idx == baseLen && (first != null || wantBase)))
- bundleName = bundleName.substring(0, idx);
- else
- break;
+ if (foundBundle != null)
+ {
+ if (first == null)
+ first = foundBundle;
+ if (last != null)
+ last.parent = foundBundle;
+ foundBundle.locale = locale;
+ last = foundBundle;
+ }
+ int idx = bundleName.lastIndexOf('_');
+ // Try the non-localized base name only if we already have a
+ // localized child bundle, or wantBase is true.
+ if (idx > baseLen || (idx == baseLen && (first != null || wantBase)))
+ bundleName = bundleName.substring(0, idx);
+ else
+ break;
}
-
+
return first;
}
@@ -611,14 +611,14 @@ public abstract class ResourceBundle
if (loader == null)
throw new NullPointerException("The loader can not be null.");
synchronized (ResourceBundle.class)
- {
- Iterator<BundleKey> iter = bundleCache.keySet().iterator();
- while (iter.hasNext())
- {
- BundleKey key = iter.next();
- if (key.classLoader == loader)
- iter.remove();
- }
+ {
+ Iterator<BundleKey> iter = bundleCache.keySet().iterator();
+ while (iter.hasNext())
+ {
+ BundleKey key = iter.next();
+ if (key.classLoader == loader)
+ iter.remove();
+ }
}
}
OpenPOWER on IntegriCloud