|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.artima.place.attribute.ResourceBundleLoader
A class that takes care of loading resources from a codebase
that is selected based on best-fit locale. The best-fit locale
is selected using an algorithm similar to that used by
ResourceBundle.getBundle().
This class is not cloneable because it is immutable.
| Constructor Summary | |
ResourceBundleLoader(java.lang.String baseName,
java.util.Map localesMap)
Constructs a ResourceBundleLoader with passed base name
and locales map. |
|
| Method Summary | |
boolean |
equals(java.lang.Object o)
Compares passed ResourceBundleLoader to this
ResourceBundleLoader for equality. |
java.lang.String |
getBaseName()
Returns the base name of the ResourceBundles that
can be loaded by this ResourceBundleLoader. |
java.util.Locale |
getBestFitLocale()
Returns the actual locale for which this ResourceBundleLoader can return a resource bundle that
best fits the default locale. |
java.util.Locale |
getBestFitLocale(java.util.Locale desiredLocale)
Returns the actual locale for which this ResourceBundleLoader can return a resource bundle that
best fits the passed locale. |
java.util.Locale |
getBestFitLocaleIncluding(java.util.Locale includeLocale)
Returns the best fit locale for the default locale, given all the locales supported by this ResourceBundleLoader and also including
the passed includeLocale. |
java.util.Locale |
getBestFitLocaleIncluding(java.util.Locale includeLocale,
java.util.Locale desiredLocale)
Returns the best fit locale for the passed desired locale, given all the locales supported by this ResourceBundleLoader and also including
the passed includeLocale. |
java.util.Locale |
getBestFitLocaleIncluding(java.util.Set includeLocales)
Returns the best fit locale for the default locale, given all the locales supported by this ResourceBundleLoader and also including
the Locale contained in the passed includeLocales set. |
java.util.Locale |
getBestFitLocaleIncluding(java.util.Set includeLocales,
java.util.Locale desiredLocale)
Returns the best fit locale for the passed desired locale, given all the locales supported by this ResourceBundleLoader and also including
the Locale contained in the passed includeLocales set. |
java.lang.ClassLoader |
getCodebaseClassLoader()
Returns a ClassLoader for the codebase that best fits the
default Locale. |
java.lang.ClassLoader |
getCodebaseClassLoader(java.util.Locale locale)
Returns a ClassLoader for the codebase that best fits the
passed Locale. |
java.util.Map |
getLocalesMap()
Returns the locales map of this ResourceBundleLoader,
a mapping of Locales to codebase URL Strings. |
java.util.ResourceBundle |
getResourceBundle()
Returns a best-fit ResourceBundle for the default
Locale. |
java.util.ResourceBundle |
getResourceBundle(java.util.Locale locale)
Returns a best-fit ResourceBundle for the passed
desired Locale. |
java.util.Set |
getSupportedLocales()
Returns an unmodifiable set of locales which are directly supported by this ResourceBundleLoader. |
int |
hashCode()
Computes the hash code for this ResourceBundleLoader. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ResourceBundleLoader(java.lang.String baseName,
java.util.Map localesMap)
ResourceBundleLoader with passed base name
and locales map. The locales map contains Locale keys
mapped to codebase URLStrings. The Locale
keys represent locales for which ResourceBundles exist at
the corresponding codebase URL. The set of locales in this map are a
cache of the information embedded in the class names (or property file
names) of the resources. For example, if class files
MyResources_de_CH.class,
MyResources_de.class, and
MyResources.class are sitting in a JAR file at
http://www.artima.com/myderes.jar, then
Locale keys for ("de", "CH"), ("de", ""), and ("", "")
would exist in this map all of whose coresponding
URLString values would be
"http://www.artima.com/myderes.jar".
The passed map is not used as part of the state of this object. The locales map may also contain as values arrays of URLString, so long as the length of the array is not zero and no elements of the array is null.
baseName - the base name of the ResourceBundles that
can be loaded by this ResourceBundleLoaderlocalesMap - a mapping of Locales to codebase URL
StringsNullPointerException - if either of passed baseName
or localesMap is null, or if any value
contained in the localesMap is nulljava.lang.IllegalArgumentException - if any keys contained in passed
localesMap are not Locales, if any
values are not either URLStrings or
URLString[]s, if the length of any
URLString[] array is zero, or if any
URLString[] array contains null
elements, if the localesMap does not contain the
empty Locale, or if the basename
contains any white space.| Method Detail |
public java.lang.String getBaseName()
ResourceBundles that
can be loaded by this ResourceBundleLoader.ResourceBundles that
can be loaded by this ResourceBundleLoaderpublic java.util.Map getLocalesMap()
ResourceBundleLoader,
a mapping of Locales to codebase URL Strings.Map this ResourceBundleLoader's locales map, a mapping of Locales to codebase URL
Stringspublic java.util.Locale getBestFitLocale(java.util.Locale desiredLocale)
ResourceBundleLoader can return a resource bundle that
best fits the passed locale.desiredLocale - the locale for which to get a best-fit supported
locale.NullPointerException - if the desiredLocale
parameter is nullpublic java.util.Locale getBestFitLocale()
ResourceBundleLoader can return a resource bundle that
best fits the default locale.public java.util.Locale getBestFitLocaleIncluding(java.util.Locale includeLocale)
ResourceBundleLoader and also including
the passed includeLocale.public java.util.Locale getBestFitLocaleIncluding(java.util.Set includeLocales)
ResourceBundleLoader and also including
the Locale contained in the passed includeLocales set.
public java.util.Locale getBestFitLocaleIncluding(java.util.Locale includeLocale,
java.util.Locale desiredLocale)
ResourceBundleLoader and also including
the passed includeLocale.
public java.util.Locale getBestFitLocaleIncluding(java.util.Set includeLocales,
java.util.Locale desiredLocale)
ResourceBundleLoader and also including
the Locale contained in the passed includeLocales set.public java.util.Set getSupportedLocales()
ResourceBundleLoader. Need to define whether or not this
means also listing the dudes that don't have all, such as the root,
or _en if also have _en_US. Probably want to send back all.ResourceBundleLoader.
public java.util.ResourceBundle getResourceBundle()
throws java.util.MissingResourceException
ResourceBundle for the default
Locale.ResourceBundle for the default
Locale.java.util.MissingResourceException - if a codebase URL is found to be
unusable. (Because URLString enforces well-formedness
of all URLs used by this method, this exception probably indicates
the protocol was unknown.), or if a ResourceBundle is
not found at the expected codebase
public java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
throws java.util.MissingResourceException
ResourceBundle for the passed
desired Locale.locale - the desired localeResourceBundle for the passed
desired Locale.java.util.MissingResourceException - if a codebase URL is found to be
unusable (Because URLString enforces well-formedness
of all URLs used by this method, this exception probably indicates
the protocol was unknown.), or if a ResourceBundle is
not found at the expected codebaseNullPointerException - if the passed locale
parameter is null
public java.lang.ClassLoader getCodebaseClassLoader()
throws java.net.MalformedURLException
ClassLoader for the codebase that best fits the
default Locale. The returned ClassLoader
represents the codebase from which the ResourceBundle
returned by getResourceBundle() is loaded. If a resource
loaded from a ResourceBundle indicates the name of a
file loadable from its codebase, that file can be loaded via the
getResource, getResourceAsStream, or
getResources methods of the returned
ClassLoader.ClassLoader for the codebase that best fits the
default Locale.java.net.MalformedURLException - if a codebase URL is found to be
unusable. (Because URLString enforces well-formedness
of all URLs used by this method, this exception probably indicates
the protocol was unknown.), or if a ResourceBundle is
not found at the expected codebase
public java.lang.ClassLoader getCodebaseClassLoader(java.util.Locale locale)
throws java.net.MalformedURLException
ClassLoader for the codebase that best fits the
passed Locale. The returned ClassLoader
represents the codebase from which the ResourceBundle
returned by getResourceBundle(Locale) is loaded. If a
resource loaded from a ResourceBundle indicates the name
of a file loadable from its codebase, that file can be loaded via the
getResource, getResourceAsStream, or
getResources methods of the returned
ClassLoader.locale - the desired localeClassLoader for the codebase that best fits the
passed desired Locale.java.net.MalformedURLException - if a codebase URL is found to be
unusable (Because URLString enforces well-formedness
of all URLs used by this method, this exception probably indicates
the protocol was unknown.), or if a ResourceBundle is
not found at the expected codebaseNullPointerException - if the passed locale
parameter is nullpublic boolean equals(java.lang.Object o)
ResourceBundleLoader to this
ResourceBundleLoader for equality. Two
ResourceBundleLoader objects are semantically equal if
they have the equivalent base names and locales maps.equals in class java.lang.ObjectAn - object to compare to this ResourceBundleLoadertrue if this ResourceBundleLoader is
semantically equal to the passed ResourceBundleLoaderpublic int hashCode()
ResourceBundleLoader.hashCode in class java.lang.ObjectResourceBundleLoader
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||