1 package jp.sourceforge.stigmata.utils;
7 import java.util.HashMap;
8 import java.util.Locale;
10 import java.util.MissingResourceException;
11 import java.util.ResourceBundle;
14 * @author Haruaki TAMADA
16 public class LocalizedDescriptionManager{
17 public static enum ServiceCategory{
18 comparator, extractor, birthmark, formatter, filter,
20 private Map<Locale, ResourceBundle> resources = new HashMap<Locale, ResourceBundle>();
23 * only one instance of singleton pattern.
25 private static LocalizedDescriptionManager manager = new LocalizedDescriptionManager();
27 private LocalizedDescriptionManager(){
30 public String getDisplayType(Locale locale, String type){
31 return getDisplayType(locale, type, ServiceCategory.birthmark);
34 public String getDisplayType(Locale locale, String type, ServiceCategory category){
36 return getBundle(locale).getString(category.name() + "." + type + ".display.type");
37 } catch(MissingResourceException e){
42 public String getDescription(Locale locale, String birthmarkType){
43 return getDescription(locale, birthmarkType, ServiceCategory.birthmark);
46 public String getDescription(Locale locale, String type, ServiceCategory category){
48 return getBundle(locale).getString(category.name() + "." + type + ".description");
49 } catch(MissingResourceException e){
54 private ResourceBundle getBundle(Locale locale){
55 ResourceBundle bundle = resources.get(locale);
57 bundle = ResourceBundle.getBundle("resources.description", locale);
58 resources.put(locale, bundle);
63 public static LocalizedDescriptionManager getInstance(){