author | bpatel |
Wed, 15 Mar 2017 16:12:20 -0700 | |
changeset 44297 | e03f5fb3714b |
parent 42816 | 3638773ff1b0 |
child 44564 | 4e1df2513486 |
permissions | -rw-r--r-- |
40303 | 1 |
/* |
44297
e03f5fb3714b
8175200: Long method signatures disturb Method Summary table
bpatel
parents:
42816
diff
changeset
|
2 |
* Copyright (c) 1998, 2017, 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.formats.html; |
|
27 |
||
28 |
import java.util.regex.Matcher; |
|
29 |
import java.util.regex.Pattern; |
|
30 |
||
31 |
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; |
|
32 |
import jdk.javadoc.internal.doclets.formats.html.markup.FixedStringContent; |
|
33 |
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; |
|
34 |
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; |
|
35 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
|
36 |
import jdk.javadoc.internal.doclets.toolkit.Resources; |
|
37 |
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; |
|
38 |
||
39 |
/** |
|
40 |
* Constants and factory methods for common fragments of content |
|
41 |
* used by HtmlDoclet. The string content of these fragments is |
|
42 |
* generally obtained from the {@link Resources resources} found |
|
43 |
* in the doclet's configuration. |
|
44 |
* |
|
45 |
* @implNote |
|
46 |
* Many constants are made available in this class, so that they are |
|
47 |
* only created once per doclet-instance, instead of once per generated page. |
|
48 |
*/ |
|
49 |
public class Contents { |
|
50 |
public static final Content SPACE = RawHtml.nbsp; |
|
44297
e03f5fb3714b
8175200: Long method signatures disturb Method Summary table
bpatel
parents:
42816
diff
changeset
|
51 |
public static final Content ZERO_WIDTH_SPACE = RawHtml.zws; |
40303 | 52 |
|
53 |
public final Content allClassesLabel; |
|
54 |
public final Content allImplementedInterfacesLabel; |
|
55 |
public final Content allModulesLabel; |
|
56 |
public final Content allPackagesLabel; |
|
57 |
public final Content allSuperinterfacesLabel; |
|
58 |
public final Content also; |
|
59 |
public final Content annotateTypeOptionalMemberSummaryLabel; |
|
60 |
public final Content annotateTypeRequiredMemberSummaryLabel; |
|
61 |
public final Content annotationType; |
|
62 |
public final Content annotationTypeDetailsLabel; |
|
63 |
public final Content annotationTypeMemberDetail; |
|
64 |
public final Content annotationTypes; |
|
65 |
public final Content classLabel; |
|
66 |
public final Content classes; |
|
67 |
public final Content constantsSummaryTitle; |
|
68 |
public final Content constructorDetailsLabel; |
|
69 |
public final Content constructorSummaryLabel; |
|
70 |
public final Content constructors; |
|
71 |
public final Content contentsHeading; |
|
72 |
public final Content defaultPackageLabel; |
|
73 |
public final Content default_; |
|
74 |
public final Content deprecatedAPI; |
|
75 |
public final Content deprecatedLabel; |
|
76 |
public final Content deprecatedPhrase; |
|
42816
3638773ff1b0
8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents:
40511
diff
changeset
|
77 |
public final Content deprecatedForRemovalPhrase; |
40303 | 78 |
public final Content descfrmClassLabel; |
79 |
public final Content descfrmInterfaceLabel; |
|
80 |
public final Content descriptionLabel; |
|
81 |
public final Content detailLabel; |
|
82 |
public final Content enclosingClassLabel; |
|
83 |
public final Content enclosingInterfaceLabel; |
|
84 |
public final Content enumConstantDetailLabel; |
|
85 |
public final Content enumConstantSummary; |
|
86 |
public final Content enum_; |
|
87 |
public final Content enums; |
|
88 |
public final Content errors; |
|
89 |
public final Content exceptions; |
|
90 |
public final Content fieldDetailsLabel; |
|
91 |
public final Content fieldSummaryLabel; |
|
92 |
public final Content fields; |
|
93 |
public final Content framesLabel; |
|
94 |
public final Content functionalInterface; |
|
95 |
public final Content functionalInterfaceMessage; |
|
96 |
public final Content helpLabel; |
|
97 |
public final Content hierarchyForAllPackages; |
|
98 |
public final Content implementation; |
|
99 |
public final Content implementingClassesLabel; |
|
100 |
public final Content inClass; |
|
101 |
public final Content inInterface; |
|
102 |
public final Content indexLabel; |
|
103 |
public final Content interfaces; |
|
104 |
public final Content interfacesItalic; |
|
105 |
public final Content methodDetailLabel; |
|
106 |
public final Content methodSummary; |
|
107 |
public final Content methods; |
|
108 |
public final Content moduleLabel; |
|
40511 | 109 |
public final Content module_; |
40303 | 110 |
public final Content moduleSubNavLabel; |
111 |
public final Content modulesLabel; |
|
112 |
public final Content navAnnotationTypeMember; |
|
113 |
public final Content navAnnotationTypeOptionalMember; |
|
114 |
public final Content navAnnotationTypeRequiredMember; |
|
115 |
public final Content navConstructor; |
|
116 |
public final Content navEnum; |
|
117 |
public final Content navField; |
|
118 |
public final Content navMethod; |
|
119 |
public final Content navModuleDescription; |
|
120 |
public final Content navModules; |
|
121 |
public final Content navNested; |
|
122 |
public final Content navPackages; |
|
123 |
public final Content navProperty; |
|
124 |
public final Content navServices; |
|
125 |
public final Content nestedClassSummary; |
|
126 |
public final Content nextClassLabel; |
|
127 |
public final Content nextLabel; |
|
128 |
public final Content nextLetter; |
|
129 |
public final Content nextModuleLabel; |
|
130 |
public final Content nextPackageLabel; |
|
131 |
public final Content noFramesLabel; |
|
132 |
public final Content noScriptMessage; |
|
133 |
public final Content overridesLabel; |
|
134 |
public final Content overviewLabel; |
|
135 |
public final Content packageHierarchies; |
|
136 |
public final Content packageLabel; |
|
137 |
public final Content package_; |
|
138 |
public final Content packagesLabel; |
|
139 |
public final Content prevClassLabel; |
|
140 |
public final Content prevLabel; |
|
141 |
public final Content prevLetter; |
|
142 |
public final Content prevModuleLabel; |
|
143 |
public final Content prevPackageLabel; |
|
144 |
public final Content properties; |
|
145 |
public final Content propertyDetailsLabel; |
|
146 |
public final Content propertySummary; |
|
147 |
public final Content seeLabel; |
|
148 |
public final Content serializedForm; |
|
149 |
public final Content specifiedByLabel; |
|
150 |
public final Content subclassesLabel; |
|
151 |
public final Content subinterfacesLabel; |
|
152 |
public final Content summaryLabel; |
|
153 |
public final Content treeLabel; |
|
154 |
public final Content useLabel; |
|
155 |
||
156 |
private final Resources resources; |
|
157 |
||
158 |
/** |
|
159 |
* Creates a {@code Contents} object. |
|
160 |
* |
|
161 |
* @param configuration the configuration in which to find the |
|
162 |
* resources used to look up resource keys, and other details. |
|
163 |
*/ |
|
164 |
Contents(ConfigurationImpl configuration) { |
|
165 |
this.resources = configuration.getResources(); |
|
166 |
||
167 |
allClassesLabel = getNonBreakContent("doclet.All_Classes"); |
|
168 |
allImplementedInterfacesLabel = getContent("doclet.All_Implemented_Interfaces"); |
|
169 |
allModulesLabel = getNonBreakContent("doclet.All_Modules"); |
|
170 |
allPackagesLabel = getNonBreakContent("doclet.All_Packages"); |
|
171 |
allSuperinterfacesLabel = getContent("doclet.All_Superinterfaces"); |
|
172 |
also = getContent("doclet.also"); |
|
173 |
annotateTypeOptionalMemberSummaryLabel = getContent("doclet.Annotation_Type_Optional_Member_Summary"); |
|
174 |
annotateTypeRequiredMemberSummaryLabel = getContent("doclet.Annotation_Type_Required_Member_Summary"); |
|
175 |
annotationType = getContent("doclet.AnnotationType"); |
|
176 |
annotationTypeDetailsLabel = getContent("doclet.Annotation_Type_Member_Detail"); |
|
177 |
annotationTypeMemberDetail = getContent("doclet.Annotation_Type_Member_Detail"); |
|
178 |
annotationTypes = getContent("doclet.AnnotationTypes"); |
|
179 |
classLabel = getContent("doclet.Class"); |
|
180 |
classes = getContent("doclet.Classes"); |
|
181 |
constantsSummaryTitle = getContent("doclet.Constants_Summary"); |
|
182 |
constructorDetailsLabel = getContent("doclet.Constructor_Detail"); |
|
183 |
constructorSummaryLabel = getContent("doclet.Constructor_Summary"); |
|
184 |
constructors = getContent("doclet.Constructors"); |
|
185 |
contentsHeading = getContent("doclet.Contents"); |
|
186 |
defaultPackageLabel = new StringContent(DocletConstants.DEFAULT_PACKAGE_NAME); |
|
187 |
default_ = getContent("doclet.Default"); |
|
188 |
deprecatedAPI = getContent("doclet.Deprecated_API"); |
|
189 |
deprecatedLabel = getContent("doclet.navDeprecated"); |
|
190 |
deprecatedPhrase = getContent("doclet.Deprecated"); |
|
42816
3638773ff1b0
8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents:
40511
diff
changeset
|
191 |
deprecatedForRemovalPhrase = getContent("doclet.DeprecatedForRemoval"); |
40303 | 192 |
descfrmClassLabel = getContent("doclet.Description_From_Class"); |
193 |
descfrmInterfaceLabel = getContent("doclet.Description_From_Interface"); |
|
194 |
descriptionLabel = getContent("doclet.Description"); |
|
195 |
detailLabel = getContent("doclet.Detail"); |
|
196 |
enclosingClassLabel = getContent("doclet.Enclosing_Class"); |
|
197 |
enclosingInterfaceLabel = getContent("doclet.Enclosing_Interface"); |
|
198 |
enumConstantDetailLabel = getContent("doclet.Enum_Constant_Detail"); |
|
199 |
enumConstantSummary = getContent("doclet.Enum_Constant_Summary"); |
|
200 |
enum_ = getContent("doclet.Enum"); |
|
201 |
enums = getContent("doclet.Enums"); |
|
202 |
errors = getContent("doclet.Errors"); |
|
203 |
exceptions = getContent("doclet.Exceptions"); |
|
204 |
fieldDetailsLabel = getContent("doclet.Field_Detail"); |
|
205 |
fieldSummaryLabel = getContent("doclet.Field_Summary"); |
|
206 |
fields = getContent("doclet.Fields"); |
|
207 |
framesLabel = getContent("doclet.Frames"); |
|
208 |
functionalInterface = getContent("doclet.Functional_Interface"); |
|
209 |
functionalInterfaceMessage = getContent("doclet.Functional_Interface_Message"); |
|
210 |
helpLabel = getContent("doclet.Help"); |
|
211 |
hierarchyForAllPackages = getContent("doclet.Hierarchy_For_All_Packages"); |
|
212 |
implementation = getContent("doclet.Implementation"); |
|
213 |
implementingClassesLabel = getContent("doclet.Implementing_Classes"); |
|
214 |
inClass = getContent("doclet.in_class"); |
|
215 |
inInterface = getContent("doclet.in_interface"); |
|
216 |
indexLabel = getContent("doclet.Index"); |
|
217 |
interfaces = getContent("doclet.Interfaces"); |
|
218 |
interfacesItalic = getContent("doclet.Interfaces_Italic"); |
|
219 |
methodDetailLabel = getContent("doclet.Method_Detail"); |
|
220 |
methodSummary = getContent("doclet.Method_Summary"); |
|
221 |
methods = getContent("doclet.Methods"); |
|
222 |
moduleLabel = getContent("doclet.Module"); |
|
40511 | 223 |
module_ = getContent("doclet.module"); |
40303 | 224 |
moduleSubNavLabel = getContent("doclet.Module_Sub_Nav"); |
225 |
modulesLabel = getContent("doclet.Modules"); |
|
226 |
navAnnotationTypeMember = getContent("doclet.navAnnotationTypeMember"); |
|
227 |
navAnnotationTypeOptionalMember = getContent("doclet.navAnnotationTypeOptionalMember"); |
|
228 |
navAnnotationTypeRequiredMember = getContent("doclet.navAnnotationTypeRequiredMember"); |
|
229 |
navConstructor = getContent("doclet.navConstructor"); |
|
230 |
navEnum = getContent("doclet.navEnum"); |
|
231 |
navField = getContent("doclet.navField"); |
|
232 |
navMethod = getContent("doclet.navMethod"); |
|
233 |
navModuleDescription = getContent("doclet.navModuleDescription"); |
|
234 |
navModules = getContent("doclet.navModules"); |
|
235 |
navNested = getContent("doclet.navNested"); |
|
236 |
navPackages = getContent("doclet.navPackages"); |
|
237 |
navProperty = getContent("doclet.navProperty"); |
|
238 |
navServices = getContent("doclet.navServices"); |
|
239 |
nestedClassSummary = getContent("doclet.Nested_Class_Summary"); |
|
240 |
nextClassLabel = getNonBreakContent("doclet.Next_Class"); |
|
241 |
nextLabel = getNonBreakContent("doclet.Next"); |
|
242 |
nextLetter = getContent("doclet.Next_Letter"); |
|
243 |
nextModuleLabel = getNonBreakContent("doclet.Next_Module"); |
|
244 |
nextPackageLabel = getNonBreakContent("doclet.Next_Package"); |
|
245 |
noFramesLabel = getNonBreakContent("doclet.No_Frames"); |
|
246 |
noScriptMessage = getContent("doclet.No_Script_Message"); |
|
247 |
overridesLabel = getContent("doclet.Overrides"); |
|
248 |
overviewLabel = getContent("doclet.Overview"); |
|
249 |
packageHierarchies = getContent("doclet.Package_Hierarchies"); |
|
250 |
packageLabel = getContent("doclet.Package"); |
|
251 |
package_ = getContent("doclet.package"); |
|
252 |
packagesLabel = getContent("doclet.Packages"); |
|
253 |
prevClassLabel = getNonBreakContent("doclet.Prev_Class"); |
|
254 |
prevLabel = getContent("doclet.Prev"); |
|
255 |
prevLetter = getContent("doclet.Prev_Letter"); |
|
256 |
prevModuleLabel = getNonBreakContent("doclet.Prev_Module"); |
|
257 |
prevPackageLabel = getNonBreakContent("doclet.Prev_Package"); |
|
258 |
properties = getContent("doclet.Properties"); |
|
259 |
propertyDetailsLabel = getContent("doclet.Property_Detail"); |
|
260 |
propertySummary = getContent("doclet.Property_Summary"); |
|
261 |
seeLabel = getContent("doclet.See"); |
|
262 |
serializedForm = getContent("doclet.Serialized_Form"); |
|
263 |
specifiedByLabel = getContent("doclet.Specified_By"); |
|
264 |
subclassesLabel = getContent("doclet.Subclasses"); |
|
265 |
subinterfacesLabel = getContent("doclet.Subinterfaces"); |
|
266 |
summaryLabel = getContent("doclet.Summary"); |
|
267 |
treeLabel = getContent("doclet.Tree"); |
|
268 |
useLabel = getContent("doclet.navClassUse"); |
|
269 |
} |
|
270 |
||
271 |
/** |
|
272 |
* Gets a {@code Content} object, containing the string for |
|
273 |
* a given key in the doclet's resources. |
|
274 |
* |
|
275 |
* @param key the key for the desired string |
|
276 |
* @return a content tree for the string |
|
277 |
*/ |
|
278 |
public Content getContent(String key) { |
|
279 |
return new FixedStringContent(resources.getText(key)); |
|
280 |
} |
|
281 |
||
282 |
/** |
|
283 |
* Gets a {@code Content} object, containing the string for |
|
284 |
* a given key in the doclet's resources, formatted with |
|
285 |
* given arguments. |
|
286 |
* |
|
287 |
* @param key the key to look for in the configuration fil |
|
288 |
* @param key the key for the desired string |
|
289 |
* @param o0 string or content argument to be formatted into the result |
|
290 |
* @return a content tree for the text |
|
291 |
*/ |
|
292 |
public Content getContent(String key, Object o0) { |
|
293 |
return getContent(key, o0, null, null); |
|
294 |
} |
|
295 |
||
296 |
/** |
|
297 |
* Gets a {@code Content} object, containing the string for |
|
298 |
* a given key in the doclet's resources, formatted with |
|
299 |
* given arguments. |
|
300 |
||
301 |
* @param key the key for the desired string |
|
302 |
* @param o0 string or content argument to be formatted into the result |
|
303 |
* @param o1 string or content argument to be formatted into the result |
|
304 |
* @return a content tree for the text |
|
305 |
*/ |
|
306 |
public Content getContent(String key, Object o0, Object o1) { |
|
307 |
return getContent(key, o0, o1, null); |
|
308 |
} |
|
309 |
||
310 |
/** |
|
311 |
* Gets a {@code Content} object, containing the string for |
|
312 |
* a given key in the doclet's resources, formatted with |
|
313 |
* given arguments. |
|
314 |
* |
|
315 |
* @param key the key for the desired string |
|
316 |
* @param o0 string or content argument to be formatted into the result |
|
317 |
* @param o1 string or content argument to be formatted into the result |
|
318 |
* @param o2 string or content argument to be formatted into the result |
|
319 |
* @return a content tree for the text |
|
320 |
*/ |
|
321 |
public Content getContent(String key, Object o0, Object o1, Object o2) { |
|
322 |
Content c = new ContentBuilder(); |
|
323 |
Pattern p = Pattern.compile("\\{([012])\\}"); |
|
324 |
String text = resources.getText(key); // TODO: cache |
|
325 |
Matcher m = p.matcher(text); |
|
326 |
int start = 0; |
|
327 |
while (m.find(start)) { |
|
328 |
c.addContent(text.substring(start, m.start())); |
|
329 |
||
330 |
Object o = null; |
|
331 |
switch (m.group(1).charAt(0)) { |
|
332 |
case '0': o = o0; break; |
|
333 |
case '1': o = o1; break; |
|
334 |
case '2': o = o2; break; |
|
335 |
} |
|
336 |
||
337 |
if (o == null) { |
|
338 |
c.addContent("{" + m.group(1) + "}"); |
|
339 |
} else if (o instanceof String) { |
|
340 |
c.addContent((String) o); |
|
341 |
} else if (o instanceof Content) { |
|
342 |
c.addContent((Content) o); |
|
343 |
} |
|
344 |
||
345 |
start = m.end(); |
|
346 |
} |
|
347 |
||
348 |
c.addContent(text.substring(start)); |
|
349 |
return c; |
|
350 |
} |
|
351 |
||
352 |
/** |
|
353 |
* Gets a {@code Content} object, containing the string for |
|
354 |
* a given key in the doclet's resources, substituting |
|
355 |
* <code> </code> for any space characters found in |
|
356 |
* the named resource string. |
|
357 |
* |
|
358 |
* @param key the key for the desired string |
|
359 |
* @return a content tree for the string |
|
360 |
*/ |
|
361 |
private Content getNonBreakContent(String key) { |
|
362 |
String text = resources.getText(key); // TODO: cache |
|
363 |
Content c = new ContentBuilder(); |
|
364 |
int start = 0; |
|
365 |
int p; |
|
366 |
while ((p = text.indexOf(" ", start)) != -1) { |
|
367 |
c.addContent(text.substring(start, p)); |
|
368 |
c.addContent(RawHtml.nbsp); |
|
369 |
start = p + 1; |
|
370 |
} |
|
371 |
c.addContent(text.substring(start)); |
|
372 |
return c; // TODO: should be made immutable |
|
373 |
} |
|
374 |
} |