author | bpatel |
Thu, 17 May 2018 12:59:53 -0700 | |
changeset 50167 | cc705c956798 |
parent 47216 | 71c04702a3d5 |
child 53562 | 0d9dee001667 |
permissions | -rw-r--r-- |
40303 | 1 |
/* |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
40303 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.javadoc.internal.doclets.toolkit; |
|
27 |
||
28 |
import java.text.MessageFormat; |
|
29 |
import java.util.Locale; |
|
30 |
import java.util.MissingResourceException; |
|
31 |
import java.util.ResourceBundle; |
|
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 { |
|
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
42 |
public final String annotationTypeSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
43 |
public final String annotationTypeTableSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
44 |
public final String classSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
45 |
public final String classTableSummary; |
45417 | 46 |
private final BaseConfiguration configuration; |
40303 | 47 |
private final String commonBundleName; |
48 |
private final String docletBundleName; |
|
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
49 |
public final String enumSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
50 |
public final String enumTableSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
51 |
public final String errorSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
52 |
public final String errorTableSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
53 |
public final String exceptionSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
54 |
public final String exceptionTableSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
55 |
public final String interfaceSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
56 |
public final String interfaceTableSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
57 |
public final String packageSummary; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
58 |
public final String packageTableSummary; |
40303 | 59 |
|
60 |
protected ResourceBundle commonBundle; |
|
61 |
protected ResourceBundle docletBundle; |
|
62 |
||
63 |
/** |
|
64 |
* Creates a {@code Resources} to provide access the resource |
|
65 |
* bundles used by a doclet. |
|
66 |
* |
|
67 |
* @param configuration the configuration for the doclet, |
|
68 |
* to provide access the locale to be used when accessing the |
|
69 |
* names resource bundles. |
|
70 |
* @param commonBundleName the name of the bundle containing the strings |
|
71 |
* common to all output formats |
|
72 |
* @param docletBundleName the name of the bundle containing the strings |
|
73 |
* specific to a particular format |
|
74 |
*/ |
|
45417 | 75 |
public Resources(BaseConfiguration configuration, String commonBundleName, String docletBundleName) { |
40303 | 76 |
this.configuration = configuration; |
77 |
this.commonBundleName = commonBundleName; |
|
78 |
this.docletBundleName = docletBundleName; |
|
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
79 |
this.annotationTypeSummary = getText("doclet.Annotation_Types_Summary"); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
80 |
this.annotationTypeTableSummary = getText("doclet.Member_Table_Summary", |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
81 |
this.annotationTypeSummary, getText("doclet.annotationtypes")); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
82 |
this.classSummary = getText("doclet.Class_Summary"); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
83 |
this.classTableSummary = getText("doclet.Member_Table_Summary", |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
84 |
this.classSummary, getText("doclet.classes")); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
85 |
this.enumSummary = getText("doclet.Enum_Summary"); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
86 |
this.enumTableSummary = getText("doclet.Member_Table_Summary", |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
87 |
this.enumSummary, getText("doclet.enums")); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
88 |
this.errorSummary = getText("doclet.Error_Summary"); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
89 |
this.errorTableSummary = getText("doclet.Member_Table_Summary", |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
90 |
this.errorSummary, getText("doclet.errors")); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
91 |
this.exceptionSummary = getText("doclet.Exception_Summary"); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
92 |
this.exceptionTableSummary = getText("doclet.Member_Table_Summary", |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
93 |
this.exceptionSummary, getText("doclet.exceptions")); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
94 |
this.interfaceSummary = getText("doclet.Interface_Summary"); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
95 |
this.interfaceTableSummary = getText("doclet.Member_Table_Summary", |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
96 |
this.interfaceSummary, getText("doclet.interfaces")); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
97 |
this.packageSummary = getText("doclet.Package_Summary"); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
98 |
this.packageTableSummary = getText("doclet.Member_Table_Summary", |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
99 |
this.packageSummary, getText("doclet.packages")); |
40303 | 100 |
} |
101 |
||
102 |
/** |
|
103 |
* Gets the string for the given key from one of the doclet's |
|
104 |
* resource bundles. |
|
105 |
* |
|
106 |
* The more specific bundle is checked first; |
|
107 |
* if it is not there, the common bundle is then checked. |
|
108 |
* |
|
109 |
* @param key the key for the desired string |
|
110 |
* @return the string for the given key |
|
111 |
* @throws MissingResourceException if the key is not found in either |
|
112 |
* bundle. |
|
113 |
*/ |
|
114 |
public String getText(String key) throws MissingResourceException { |
|
115 |
initBundles(); |
|
116 |
||
117 |
if (docletBundle.containsKey(key)) |
|
118 |
return docletBundle.getString(key); |
|
119 |
||
120 |
return commonBundle.getString(key); |
|
121 |
} |
|
122 |
/** |
|
123 |
* Gets the string for the given key from one of the doclet's |
|
124 |
* resource bundles, substituting additional arguments into |
|
125 |
* into the resulting string with {@link MessageFormat#format}. |
|
126 |
* |
|
127 |
* The more specific bundle is checked first; |
|
128 |
* if it is not there, the common bundle is then checked. |
|
129 |
* |
|
130 |
* @param key the key for the desired string |
|
131 |
* @param args values to be substituted into the resulting string |
|
132 |
* @return the string for the given key |
|
133 |
* @throws MissingResourceException if the key is not found in either |
|
134 |
* bundle. |
|
135 |
*/ |
|
136 |
public String getText(String key, Object... args) throws MissingResourceException { |
|
137 |
return MessageFormat.format(getText(key), args); |
|
138 |
} |
|
139 |
||
140 |
/** |
|
141 |
* Lazily initializes the bundles. This is (currently) necessary because |
|
142 |
* this object may be created before the locale to be used is known. |
|
143 |
*/ |
|
144 |
protected void initBundles() { |
|
145 |
if (commonBundle == null) { |
|
146 |
Locale locale = configuration.getLocale(); |
|
147 |
this.commonBundle = ResourceBundle.getBundle(commonBundleName, locale); |
|
148 |
this.docletBundle = ResourceBundle.getBundle(docletBundleName, locale); |
|
149 |
} |
|
150 |
} |
|
151 |
} |