Package de.aristaflow.adept2.util.i18n
Class ResourceBundleProvider<T>
- java.lang.Object
- 
- de.aristaflow.adept2.util.i18n.ResourceBundleProvider<T>
 
- 
- Type Parameters:
- T- The localising object based on a- ResourceBundle.
 - Direct Known Subclasses:
- MessagesProvider,- ResBundleSubclassProvider
 
 public abstract class ResourceBundleProvider<T> extends Object implements Function<Locale,T> This class provides resource bundles for various locales and caches them (or the corresponding related objects). This is coupled to a loading class providing the base name and the classloader (and usually also the key constants).This class generalises from the concrete localising object. It loads the appropriate resource bundle, wraps it with the localising object and caches it. The default function uses no locale fallback for the resource bundle. 
- 
- 
Field SummaryFields Modifier and Type Field Description protected StringbaseNameThe base name of the resource bundle.protected ConcurrentMap<Locale,T>cacheA cache for retrieved bundles or alike.protected ClassLoaderclassLoaderThe class loader used to retrieve the resource bundles.protected ResourceBundle.ControlcontrolThe control with which to load the resource bundle.
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedResourceBundleProvider(Class<?> loadingClass, List<String> bundleFormat)Constructs a new resource bundle provider for loading resource bundles for a specific locale for the designated class.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Tapply(Locale l)protected abstract Tconvert(Locale reqLocale, ResourceBundle bundle)Converts the designated resource bundle to the corresponding localising object.TforLocale(Locale locale)Returns the resource bundle or the related object for the specified locale.
 
- 
- 
- 
Field Detail- 
cacheprotected final ConcurrentMap<Locale,T> cache A cache for retrieved bundles or alike.
 - 
baseNameprotected final String baseName The base name of the resource bundle.
 - 
classLoaderprotected final ClassLoader classLoader The class loader used to retrieve the resource bundles.
 - 
controlprotected final ResourceBundle.Control control The control with which to load the resource bundle.
 
- 
 - 
Constructor Detail- 
ResourceBundleProviderprotected ResourceBundleProvider(Class<?> loadingClass, List<String> bundleFormat) Constructs a new resource bundle provider for loading resource bundles for a specific locale for the designated class.- Parameters:
- loadingClass- The class with which to load the resource bundle.
- bundleFormat- A list of bundle formats which to load, usually class and/or properties.
- See Also:
- ResourceBundle.Control.getFormats(String)
 
 
- 
 - 
Method Detail- 
forLocalepublic T forLocale(Locale locale) Returns the resource bundle or the related object for the specified locale.This method is thread-safe. - Parameters:
- locale- The desired locale. If this is- null, the default locale of the JVM will be used.
- Returns:
- The best-matching resource bundle or the related object for the specified locale.
 
 - 
convertprotected abstract T convert(Locale reqLocale, ResourceBundle bundle) Converts the designated resource bundle to the corresponding localising object.- Parameters:
- reqLocale- The requested locale. This may differ from the locale of the resource bundle.
- bundle- The resource bundle for which to get the corresponding localising object.
- Returns:
- The localising object for the designated resource bundle.
 
 
- 
 
-