32
33 /**
34 * Access to the localizable resources used by a doclet.
35 * The resources are split across two resource bundles:
36 * one that contains format-neutral strings common to
37 * all supported formats, and one that contains strings
38 * specific to the selected doclet, such as the standard
39 * HTML doclet.
40 */
41 public class Resources {
42 public final String annotationTypeSummary;
43 public final String classSummary;
44 private final BaseConfiguration configuration;
45 private final String commonBundleName;
46 private final String docletBundleName;
47 public final String enumSummary;
48 public final String errorSummary;
49 public final String exceptionSummary;
50 public final String interfaceSummary;
51 public final String packageSummary;
52
53 protected ResourceBundle commonBundle;
54 protected ResourceBundle docletBundle;
55
56 /**
57 * Creates a {@code Resources} to provide access the resource
58 * bundles used by a doclet.
59 *
60 * @param configuration the configuration for the doclet,
61 * to provide access the locale to be used when accessing the
62 * names resource bundles.
63 * @param commonBundleName the name of the bundle containing the strings
64 * common to all output formats
65 * @param docletBundleName the name of the bundle containing the strings
66 * specific to a particular format
67 */
68 public Resources(BaseConfiguration configuration, String commonBundleName, String docletBundleName) {
69 this.configuration = configuration;
70 this.commonBundleName = commonBundleName;
71 this.docletBundleName = docletBundleName;
72 this.annotationTypeSummary = getText("doclet.Annotation_Types_Summary");
73 this.classSummary = getText("doclet.Class_Summary");
74 this.enumSummary = getText("doclet.Enum_Summary");
75 this.errorSummary = getText("doclet.Error_Summary");
76 this.exceptionSummary = getText("doclet.Exception_Summary");
77 this.interfaceSummary = getText("doclet.Interface_Summary");
78 this.packageSummary = getText("doclet.Package_Summary");
79 }
80
81 /**
82 * Gets the string for the given key from one of the doclet's
83 * resource bundles.
84 *
85 * The more specific bundle is checked first;
86 * if it is not there, the common bundle is then checked.
87 *
88 * @param key the key for the desired string
89 * @return the string for the given key
90 * @throws MissingResourceException if the key is not found in either
91 * bundle.
92 */
93 public String getText(String key) throws MissingResourceException {
94 initBundles();
95
96 if (docletBundle.containsKey(key))
97 return docletBundle.getString(key);
98
|
32
33 /**
34 * Access to the localizable resources used by a doclet.
35 * The resources are split across two resource bundles:
36 * one that contains format-neutral strings common to
37 * all supported formats, and one that contains strings
38 * specific to the selected doclet, such as the standard
39 * HTML doclet.
40 */
41 public class Resources {
42 public final String annotationTypeSummary;
43 public final String classSummary;
44 private final BaseConfiguration configuration;
45 private final String commonBundleName;
46 private final String docletBundleName;
47 public final String enumSummary;
48 public final String errorSummary;
49 public final String exceptionSummary;
50 public final String interfaceSummary;
51 public final String packageSummary;
52 public final String recordSummary;
53
54 protected ResourceBundle commonBundle;
55 protected ResourceBundle docletBundle;
56
57 /**
58 * Creates a {@code Resources} to provide access the resource
59 * bundles used by a doclet.
60 *
61 * @param configuration the configuration for the doclet,
62 * to provide access the locale to be used when accessing the
63 * names resource bundles.
64 * @param commonBundleName the name of the bundle containing the strings
65 * common to all output formats
66 * @param docletBundleName the name of the bundle containing the strings
67 * specific to a particular format
68 */
69 public Resources(BaseConfiguration configuration, String commonBundleName, String docletBundleName) {
70 this.configuration = configuration;
71 this.commonBundleName = commonBundleName;
72 this.docletBundleName = docletBundleName;
73 this.annotationTypeSummary = getText("doclet.Annotation_Types_Summary");
74 this.classSummary = getText("doclet.Class_Summary");
75 this.enumSummary = getText("doclet.Enum_Summary");
76 this.errorSummary = getText("doclet.Error_Summary");
77 this.exceptionSummary = getText("doclet.Exception_Summary");
78 this.interfaceSummary = getText("doclet.Interface_Summary");
79 this.packageSummary = getText("doclet.Package_Summary");
80 this.recordSummary = getText("doclet.Record_Summary");
81 }
82
83 /**
84 * Gets the string for the given key from one of the doclet's
85 * resource bundles.
86 *
87 * The more specific bundle is checked first;
88 * if it is not there, the common bundle is then checked.
89 *
90 * @param key the key for the desired string
91 * @return the string for the given key
92 * @throws MissingResourceException if the key is not found in either
93 * bundle.
94 */
95 public String getText(String key) throws MissingResourceException {
96 initBundles();
97
98 if (docletBundle.containsKey(key))
99 return docletBundle.getString(key);
100
|