Commit cd848423 by Tom Tromey Committed by Tom Tromey

* java/util/ResourceBundle.java

	(getBundle(String,Locale,ClassLoader)): New method.
	(trySomeGetBundle): Added `loader' argument.
	(partialGetBundle): Likewise.

From-SVN: r38275
parent 13b7bc8a
2000-12-14 Tom Tromey <tromey@redhat.com> 2000-12-14 Tom Tromey <tromey@redhat.com>
* java/util/ResourceBundle.java
(getBundle(String,Locale,ClassLoader)): New method.
(trySomeGetBundle): Added `loader' argument.
(partialGetBundle): Likewise.
* java/text/NumberFormat.java (groupingUsed, parseIntegerOnly, * java/text/NumberFormat.java (groupingUsed, parseIntegerOnly,
maximumFractionDigits, maximumIntegerDigits, maximumFractionDigits, maximumIntegerDigits,
minimumFractionDigits, minimumIntegerDigits): Now minimumFractionDigits, minimumIntegerDigits): Now
......
...@@ -73,7 +73,8 @@ public abstract class ResourceBundle ...@@ -73,7 +73,8 @@ public abstract class ResourceBundle
// stripping off the '_' delimited tails until the search name is // stripping off the '_' delimited tails until the search name is
// the same as stopHere. // the same as stopHere.
private static final ResourceBundle trySomeGetBundle (String bundleName, private static final ResourceBundle trySomeGetBundle (String bundleName,
String stopHere) String stopHere,
ClassLoader loader)
{ {
Class rbc; Class rbc;
ResourceBundle needs_parent = null, r, result = null; ResourceBundle needs_parent = null, r, result = null;
...@@ -115,9 +116,9 @@ public abstract class ResourceBundle ...@@ -115,9 +116,9 @@ public abstract class ResourceBundle
} }
// Look for a properties file. // Look for a properties file.
InputStream i = InputStream i = loader.getResourceAsStream (bundleName.replace ('.',
ClassLoader.getSystemResourceAsStream (bundleName.replace ('.', '/') '/')
+ ".properties"); + ".properties");
if (i != null) if (i != null)
{ {
try try
...@@ -151,7 +152,8 @@ public abstract class ResourceBundle ...@@ -151,7 +152,8 @@ public abstract class ResourceBundle
// Search for bundles, but stop at baseName_language (if required). // Search for bundles, but stop at baseName_language (if required).
// This is synchronized so that the cache works correctly. // This is synchronized so that the cache works correctly.
private static final synchronized ResourceBundle private static final synchronized ResourceBundle
partialGetBundle (String baseName, Locale locale, boolean langStop) partialGetBundle (String baseName, Locale locale, boolean langStop,
ClassLoader loader)
{ {
ResourceBundle rb; ResourceBundle rb;
...@@ -168,7 +170,7 @@ public abstract class ResourceBundle ...@@ -168,7 +170,7 @@ public abstract class ResourceBundle
+ (langStop ? ("_" + locale.getLanguage()) : "")); + (langStop ? ("_" + locale.getLanguage()) : ""));
rb = trySomeGetBundle(bundleName, stopHere); rb = trySomeGetBundle(bundleName, stopHere, loader);
if (rb != null) if (rb != null)
resource_cache.put(bundleName, rb); resource_cache.put(bundleName, rb);
...@@ -177,6 +179,13 @@ public abstract class ResourceBundle ...@@ -177,6 +179,13 @@ public abstract class ResourceBundle
public static final ResourceBundle getBundle (String baseName, public static final ResourceBundle getBundle (String baseName,
Locale locale) Locale locale)
{
return getBundle (baseName, locale, ClassLoader.getSystemClassLoader ());
}
public static final ResourceBundle getBundle (String baseName,
Locale locale,
ClassLoader loader)
throws MissingResourceException throws MissingResourceException
{ {
ResourceBundle rb; ResourceBundle rb;
...@@ -185,14 +194,14 @@ public abstract class ResourceBundle ...@@ -185,14 +194,14 @@ public abstract class ResourceBundle
if (baseName == null) if (baseName == null)
throw new NullPointerException (); throw new NullPointerException ();
rb = partialGetBundle(baseName, locale, false); rb = partialGetBundle(baseName, locale, false, loader);
if (rb != null) if (rb != null)
return rb; return rb;
// Finally, try the default locale. // Finally, try the default locale.
if (! locale.equals(Locale.getDefault())) if (! locale.equals(Locale.getDefault()))
{ {
rb = partialGetBundle(baseName, Locale.getDefault(), true); rb = partialGetBundle(baseName, Locale.getDefault(), true, loader);
if (rb != null) if (rb != null)
return rb; return rb;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment