Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/classes/sun/rmi/rmic/newrmic/Resources.java
+++ new/src/share/classes/sun/rmi/rmic/newrmic/Resources.java
1 1 /*
2 2 * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation. Oracle designates this
8 8 * particular file as subject to the "Classpath" exception as provided
9 9 * by Oracle in the LICENSE file that accompanied this code.
10 10 *
11 11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 14 * version 2 for more details (a copy is included in the LICENSE file that
15 15 * accompanied this code).
16 16 *
17 17 * You should have received a copy of the GNU General Public License version
18 18 * 2 along with this work; if not, write to the Free Software Foundation,
19 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 20 *
21 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 22 * or visit www.oracle.com if you need additional information or have any
23 23 * questions.
24 24 */
25 25
26 26 package sun.rmi.rmic.newrmic;
27 27
28 28 import java.text.MessageFormat;
29 29 import java.util.MissingResourceException;
30 30 import java.util.ResourceBundle;
31 31
32 32 /**
33 33 * Provides resource support for rmic.
34 34 *
35 35 * WARNING: The contents of this source file are not part of any
36 36 * supported API. Code that depends on them does so at its own risk:
37 37 * they are subject to change or removal without notice.
38 38 *
39 39 * @author Peter Jones
40 40 **/
41 41 public final class Resources {
42 42
43 43 private static ResourceBundle resources = null;
44 44 private static ResourceBundle resourcesExt = null;
45 45 static {
46 46 try {
47 47 resources =
48 48 ResourceBundle.getBundle("sun.rmi.rmic.resources.rmic");
49 49 } catch (MissingResourceException e) {
50 50 // gracefully handle this later
51 51 }
52 52 try {
53 53 resourcesExt =
54 54 ResourceBundle.getBundle("sun.rmi.rmic.resources.rmicext");
55 55 } catch (MissingResourceException e) {
56 56 // OK if this isn't found
57 57 }
58 58 }
59 59
60 60 private Resources() { throw new AssertionError(); }
61 61
↓ open down ↓ |
61 lines elided |
↑ open up ↑ |
62 62 /**
63 63 * Returns the text of the rmic resource for the specified key
64 64 * formatted with the specified arguments.
65 65 **/
66 66 public static String getText(String key, String... args) {
67 67 String format = getString(key);
68 68 if (format == null) {
69 69 format = "missing resource key: key = \"" + key + "\", " +
70 70 "arguments = \"{0}\", \"{1}\", \"{2}\"";
71 71 }
72 - return MessageFormat.format(format, (Object[]) args);
72 + return MessageFormat.format(format, args);
73 73 }
74 74
75 75 /**
76 76 * Returns the rmic resource string for the specified key.
77 77 **/
78 78 private static String getString(String key) {
79 79 if (resourcesExt != null) {
80 80 try {
81 81 return resourcesExt.getString(key);
82 82 } catch (MissingResourceException e) {
83 83 }
84 84 }
85 85 if (resources != null) {
86 86 try {
87 87 return resources.getString(key);
88 88 } catch (MissingResourceException e) {
89 89 return null;
90 90 }
91 91 }
92 92 return "missing resource bundle: key = \"" + key + "\", " +
93 93 "arguments = \"{0}\", \"{1}\", \"{2}\"";
94 94 }
95 95 }
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX