src/share/classes/com/sun/tools/javac/util/JavacMessages.java

changeset 944
83260b3305ac
parent 581
f2fdd52e4e87
child 1135
36553cb94345
equal deleted inserted replaced
943:72bdd232e0ea 944:83260b3305ac
1 /* 1 /*
2 * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
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 protected static final Context.Key<JavacMessages> messagesKey = 47 public static final Context.Key<JavacMessages> messagesKey =
48 new Context.Key<JavacMessages>(); 48 new Context.Key<JavacMessages>();
49 49
50 /** Get the JavacMessages instance for this context. */ 50 /** Get the JavacMessages instance for this context. */
51 public static JavacMessages instance(Context context) { 51 public static JavacMessages instance(Context context) {
52 JavacMessages instance = context.get(messagesKey); 52 JavacMessages instance = context.get(messagesKey);
75 } 75 }
76 76
77 /** Creates a JavacMessages object. 77 /** Creates a JavacMessages object.
78 */ 78 */
79 public JavacMessages(Context context) { 79 public JavacMessages(Context context) {
80 this(defaultBundleName); 80 this(defaultBundleName, context.get(Locale.class));
81 context.put(messagesKey, this); 81 context.put(messagesKey, this);
82 } 82 }
83 83
84 /** Creates a JavacMessages object. 84 /** Creates a JavacMessages object.
85 * @param bundleName the name to identify the resource buundle of localized messages. 85 * @param bundleName the name to identify the resource buundle of localized messages.
86 */ 86 */
87 public JavacMessages(String bundleName) throws MissingResourceException { 87 public JavacMessages(String bundleName) throws MissingResourceException {
88 this(bundleName, null);
89 }
90
91 /** Creates a JavacMessages object.
92 * @param bundleName the name to identify the resource buundle of localized messages.
93 */
94 public JavacMessages(String bundleName, Locale locale) throws MissingResourceException {
88 bundleNames = List.nil(); 95 bundleNames = List.nil();
89 bundleCache = new HashMap<Locale, SoftReference<List<ResourceBundle>>>(); 96 bundleCache = new HashMap<Locale, SoftReference<List<ResourceBundle>>>();
90 add(bundleName); 97 add(bundleName);
91 setCurrentLocale(Locale.getDefault()); 98 setCurrentLocale(locale);
92 } 99 }
93 100
94 public JavacMessages() throws MissingResourceException { 101 public JavacMessages() throws MissingResourceException {
95 this(defaultBundleName); 102 this(defaultBundleName);
96 } 103 }

mercurial