org.mmbase.util
Class SortedBundle

java.lang.Object
  extended byorg.mmbase.util.SortedBundle

public class SortedBundle
extends java.lang.Object

A bit like 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 there 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.

Since:
MMBase-1.8
Author:
Michiel Meeuwissen
To Do:
THIS CLASS IS EXPERIMENTAL

Nested Class Summary
static class SortedBundle.ValueWrapper
          You can specify ValueWrapper.class as a value for the wrapper argument.
 
Field Summary
static java.util.Comparator NO_COMPARATOR
          Constant which can be used as an argument for getResource(java.lang.String, java.util.Locale, java.lang.ClassLoader, java.lang.Class, java.lang.Class, java.util.Comparator)
static java.lang.Class NO_CONSTANTSPROVIDER
          Constant which can be used as an argument for getResource(java.lang.String, java.util.Locale, java.lang.ClassLoader, java.lang.Class, java.lang.Class, java.util.Comparator)
static java.lang.Class NO_WRAPPER
          Constant which can be used as an argument for getResource(java.lang.String, java.util.Locale, java.lang.ClassLoader, java.lang.Class, java.lang.Class, java.util.Comparator)
 
Constructor Summary
SortedBundle()
           
 
Method Summary
static java.util.SortedMap getResource(java.lang.String baseName, java.util.Locale locale, java.lang.ClassLoader loader, java.lang.Class constantsProvider, java.lang.Class wrapper, java.util.Comparator comparator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_WRAPPER

public static final java.lang.Class NO_WRAPPER
Constant which can be used as an argument for getResource(java.lang.String, java.util.Locale, java.lang.ClassLoader, java.lang.Class, java.lang.Class, java.util.Comparator)


NO_COMPARATOR

public static final java.util.Comparator NO_COMPARATOR
Constant which can be used as an argument for getResource(java.lang.String, java.util.Locale, java.lang.ClassLoader, java.lang.Class, java.lang.Class, java.util.Comparator)


NO_CONSTANTSPROVIDER

public static final java.lang.Class NO_CONSTANTSPROVIDER
Constant which can be used as an argument for getResource(java.lang.String, java.util.Locale, java.lang.ClassLoader, java.lang.Class, java.lang.Class, java.util.Comparator)

Constructor Detail

SortedBundle

public SortedBundle()
Method Detail

getResource

public static java.util.SortedMap getResource(java.lang.String baseName,
                                              java.util.Locale locale,
                                              java.lang.ClassLoader loader,
                                              java.lang.Class constantsProvider,
                                              java.lang.Class wrapper,
                                              java.util.Comparator comparator)
Parameters:
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 desired
loader - - the class loader from which to load the resource bundle
constantsProvider - the class of which the constants must be used to be associated 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). 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
comparator - the elements will be sorted (by key) using this comparator or by natural key order if this is null.
Throws:
java.lang.NullPointerException - if baseName or locale is null (not if loader is null)
java.util.MissingResourceException - if no resource bundle for the specified base name can be found


MMBase build 1.7.1.20041002