public class SortedBundle extends Object
ResourceBundle (on which it is based), but it creates
SortedMap's. The order of the entries of the Map can be influenced in tree ways. You can
associate the keys with JAVA constants (and their natural ordering can be used), you can wrap the
keys in a 'wrapper' (which can be of any type, the sole restriction being that there is a
constructor with String argument or of the type of the assiocated JAVA constant if that happened
too, and the natural order of the wrapper can be used (a wrapper of some Number type would be
logical). Finally you can also explicitely specify a Comparator if no natural
order is good.| Modifier and Type | Class and Description |
|---|---|
static class |
SortedBundle.ValueWrapper
You can specify ValueWrapper.class as a value for the wrapper argument.
|
| Modifier and Type | Field and Description |
|---|---|
static Comparator<? super Object> |
NO_COMPARATOR
|
static HashMap<String,Object> |
NO_CONSTANTSPROVIDER
|
static Class<?> |
NO_WRAPPER
|
| Modifier and Type | Method and Description |
|---|---|
static Object |
castKey(String bundleKey,
Object value,
Map<String,Object> constantsProvider,
Class<?> wrapper) |
protected static Object |
castKey(String bundleKey,
Object value,
Map<String,Object> constantsProvider,
Class<?> wrapper,
Locale locale)
Casts a key of the bundle to the specified key-type.
|
static HashMap<String,Object> |
getConstantsProvider(Class<?> clazz)
Returns a (serializable) Map representing all accessible static public members of given class (so, all constants).
|
static <C> SortedMap<C,String> |
getResource(String baseName,
Locale locale,
ClassLoader loader,
Map<String,Object> constantsProvider,
Class<?> wrapper,
Comparator<? super Object> comparator) |
public static final Class<?> NO_WRAPPER
public static final Comparator<? super Object> NO_COMPARATOR
public static <C> SortedMap<C,String> getResource(String baseName, Locale locale, ClassLoader loader, Map<String,Object> constantsProvider, Class<?> wrapper, Comparator<? super Object> comparator)
baseName - A string identifying the resource. See ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader) for an explanation of this string.locale - the locale for which a resource bundle is desiredloader - the class loader from which to load the resource bundleconstantsProvider - A map representing constants for the value. Can be based on a class using getConstantsProvider(Class), then the class's constants ar used to associate with the elements of this resource.wrapper - the keys will be wrapped in objects of this type (which must have a
constructor with the right type (String, or otherwise the type of the variable given by the constantsProvider), and must be Comparable.
You could specify e.g. Integer.class if the keys of the
map are meant to be integers. This can be null, in which case the keys will remain unwrapped (and therefore String).comparator - the elements will be sorted (by key) using this comparator or by natural key order if this is null.NullPointerException - if baseName or locale is null (not if loader is null)MissingResourceException - if no resource bundle for the specified base name can be foundIllegalArgumentExcpetion - if wrapper is not Comparable.public static Object castKey(String bundleKey, Object value, Map<String,Object> constantsProvider, Class<?> wrapper)
protected static Object castKey(String bundleKey, Object value, Map<String,Object> constantsProvider, Class<?> wrapper, Locale locale)
getResource(java.lang.String, java.util.Locale, java.lang.ClassLoader, java.util.Map<java.lang.String, java.lang.Object>, java.lang.Class<?>, java.util.Comparator<? super java.lang.Object>).MMBase 1.9-SNAPSHOT - ${javadoctimestamp}