equal
deleted
inserted
replaced
42 * This code and its internal interfaces are subject to change or |
42 * This code and its internal interfaces are subject to change or |
43 * deletion without notice.</b> |
43 * deletion without notice.</b> |
44 */ |
44 */ |
45 public class JavacMessages implements Messages { |
45 public class JavacMessages implements Messages { |
46 /** The context key for the JavacMessages object. */ |
46 /** The context key for the JavacMessages object. */ |
47 public static final Context.Key<JavacMessages> messagesKey = |
47 public static final Context.Key<JavacMessages> messagesKey = new Context.Key<>(); |
48 new Context.Key<JavacMessages>(); |
|
49 |
48 |
50 /** Get the JavacMessages instance for this context. */ |
49 /** Get the JavacMessages instance for this context. */ |
51 public static JavacMessages instance(Context context) { |
50 public static JavacMessages instance(Context context) { |
52 JavacMessages instance = context.get(messagesKey); |
51 JavacMessages instance = context.get(messagesKey); |
53 if (instance == null) |
52 if (instance == null) |
91 /** Creates a JavacMessages object. |
90 /** Creates a JavacMessages object. |
92 * @param bundleName the name to identify the resource bundle of localized messages. |
91 * @param bundleName the name to identify the resource bundle of localized messages. |
93 */ |
92 */ |
94 public JavacMessages(String bundleName, Locale locale) throws MissingResourceException { |
93 public JavacMessages(String bundleName, Locale locale) throws MissingResourceException { |
95 bundleNames = List.nil(); |
94 bundleNames = List.nil(); |
96 bundleCache = new HashMap<Locale, SoftReference<List<ResourceBundle>>>(); |
95 bundleCache = new HashMap<>(); |
97 add(bundleName); |
96 add(bundleName); |
98 setCurrentLocale(locale); |
97 setCurrentLocale(locale); |
99 } |
98 } |
100 |
99 |
101 public JavacMessages() throws MissingResourceException { |
100 public JavacMessages() throws MissingResourceException { |
122 bundleList = bundleList.prepend(rb); |
121 bundleList = bundleList.prepend(rb); |
123 } catch (MissingResourceException e) { |
122 } catch (MissingResourceException e) { |
124 throw new InternalError("Cannot find javac resource bundle for locale " + locale); |
123 throw new InternalError("Cannot find javac resource bundle for locale " + locale); |
125 } |
124 } |
126 } |
125 } |
127 bundleCache.put(locale, new SoftReference<List<ResourceBundle>>(bundleList)); |
126 bundleCache.put(locale, new SoftReference<>(bundleList)); |
128 } |
127 } |
129 return bundleList; |
128 return bundleList; |
130 } |
129 } |
131 |
130 |
132 /** Gets the localized string corresponding to a key, formatted with a set of args. |
131 /** Gets the localized string corresponding to a key, formatted with a set of args. |