This is the mail archive of the
java-patches@sources.redhat.com
mailing list for the Java project.
Patch: ResourceBundle method
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: Patch: ResourceBundle method
- From: Tom Tromey <tromey at redhat dot com>
- Date: 15 Dec 2000 00:04:43 -0700
- Reply-To: tromey at redhat dot com
I've implemented the missing 1.2 method from ResourceBundle.
I'm checking this in.
2000-12-14 Tom Tromey <tromey@redhat.com>
* java/util/ResourceBundle.java
(getBundle(String,Locale,ClassLoader)): New method.
(trySomeGetBundle): Added `loader' argument.
(partialGetBundle): Likewise.
Tom
Index: java/util/ResourceBundle.java
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/util/ResourceBundle.java,v
retrieving revision 1.9
diff -u -r1.9 ResourceBundle.java
--- ResourceBundle.java 2000/08/21 21:25:55 1.9
+++ ResourceBundle.java 2000/12/15 06:42:24
@@ -73,7 +73,8 @@
// stripping off the '_' delimited tails until the search name is
// the same as stopHere.
private static final ResourceBundle trySomeGetBundle (String bundleName,
- String stopHere)
+ String stopHere,
+ ClassLoader loader)
{
Class rbc;
ResourceBundle needs_parent = null, r, result = null;
@@ -115,9 +116,9 @@
}
// Look for a properties file.
- InputStream i =
- ClassLoader.getSystemResourceAsStream (bundleName.replace ('.', '/')
- + ".properties");
+ InputStream i = loader.getResourceAsStream (bundleName.replace ('.',
+ '/')
+ + ".properties");
if (i != null)
{
try
@@ -151,7 +152,8 @@
// Search for bundles, but stop at baseName_language (if required).
// This is synchronized so that the cache works correctly.
private static final synchronized ResourceBundle
- partialGetBundle (String baseName, Locale locale, boolean langStop)
+ partialGetBundle (String baseName, Locale locale, boolean langStop,
+ ClassLoader loader)
{
ResourceBundle rb;
@@ -168,7 +170,7 @@
+ (langStop ? ("_" + locale.getLanguage()) : ""));
- rb = trySomeGetBundle(bundleName, stopHere);
+ rb = trySomeGetBundle(bundleName, stopHere, loader);
if (rb != null)
resource_cache.put(bundleName, rb);
@@ -177,6 +179,13 @@
public static final ResourceBundle getBundle (String baseName,
Locale locale)
+ {
+ return getBundle (baseName, locale, ClassLoader.getSystemClassLoader ());
+ }
+
+ public static final ResourceBundle getBundle (String baseName,
+ Locale locale,
+ ClassLoader loader)
throws MissingResourceException
{
ResourceBundle rb;
@@ -185,14 +194,14 @@
if (baseName == null)
throw new NullPointerException ();
- rb = partialGetBundle(baseName, locale, false);
+ rb = partialGetBundle(baseName, locale, false, loader);
if (rb != null)
return rb;
// Finally, try the default locale.
if (! locale.equals(Locale.getDefault()))
{
- rb = partialGetBundle(baseName, Locale.getDefault(), true);
+ rb = partialGetBundle(baseName, Locale.getDefault(), true, loader);
if (rb != null)
return rb;
}