author | jjg |
Fri, 27 May 2016 13:06:58 -0700 | |
changeset 38617 | d93a7f64e231 |
parent 38515 | 6ae7f7d9b44c |
permissions | -rw-r--r-- |
10 | 1 |
/* |
35419 | 2 |
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.doclets.internal.toolkit; |
|
27 |
||
14258 | 28 |
import java.io.*; |
29 |
import java.util.*; |
|
17563
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
30 |
import java.util.regex.Matcher; |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
31 |
import java.util.regex.Pattern; |
35419 | 32 |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
19937
diff
changeset
|
33 |
import javax.tools.JavaFileManager; |
36526 | 34 |
import javax.tools.JavaFileManager.Location; |
14258 | 35 |
|
36 |
import com.sun.javadoc.*; |
|
37 |
import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory; |
|
10 | 38 |
import com.sun.tools.doclets.internal.toolkit.taglets.*; |
39 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
19937
diff
changeset
|
40 |
import com.sun.tools.javac.util.StringUtils; |
10 | 41 |
|
42 |
/** |
|
43 |
* Configure the output based on the options. Doclets should sub-class |
|
44 |
* Configuration, to configure and add their own options. This class contains |
|
45 |
* all user options which are supported by the 1.1 doclet and the standard |
|
46 |
* doclet. |
|
47 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
48 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
49 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
50 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
51 |
* deletion without notice.</b> |
10 | 52 |
* |
53 |
* @author Robert Field. |
|
54 |
* @author Atul Dambalkar. |
|
55 |
* @author Jamie Ho |
|
56 |
*/ |
|
38617 | 57 |
@Deprecated |
10 | 58 |
public abstract class Configuration { |
59 |
||
60 |
/** |
|
16324 | 61 |
* Exception used to report a problem during setOptions. |
62 |
*/ |
|
16560 | 63 |
public static class Fault extends Exception { |
16324 | 64 |
private static final long serialVersionUID = 0; |
65 |
||
66 |
Fault(String msg) { |
|
67 |
super(msg); |
|
68 |
} |
|
69 |
||
70 |
Fault(String msg, Exception cause) { |
|
71 |
super(msg, cause); |
|
72 |
} |
|
73 |
} |
|
74 |
||
75 |
/** |
|
10 | 76 |
* The factory for builders. |
77 |
*/ |
|
78 |
protected BuilderFactory builderFactory; |
|
79 |
||
80 |
/** |
|
81 |
* The taglet manager. |
|
82 |
*/ |
|
83 |
public TagletManager tagletManager; |
|
84 |
||
85 |
/** |
|
86 |
* The path to the builder XML input file. |
|
87 |
*/ |
|
88 |
public String builderXMLPath; |
|
89 |
||
90 |
/** |
|
91 |
* The default path to the builder XML. |
|
92 |
*/ |
|
93 |
private static final String DEFAULT_BUILDER_XML = "resources/doclet.xml"; |
|
94 |
||
95 |
/** |
|
96 |
* The path to Taglets |
|
97 |
*/ |
|
98 |
public String tagletpath = ""; |
|
99 |
||
100 |
/** |
|
101 |
* This is true if option "-serialwarn" is used. Defualt value is false to |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
102 |
* suppress excessive warnings about serial tag. |
10 | 103 |
*/ |
104 |
public boolean serialwarn = false; |
|
105 |
||
106 |
/** |
|
107 |
* The specified amount of space between tab stops. |
|
108 |
*/ |
|
14542 | 109 |
public int sourcetab; |
110 |
||
111 |
public String tabSpaces; |
|
10 | 112 |
|
113 |
/** |
|
114 |
* True if we should generate browsable sources. |
|
115 |
*/ |
|
116 |
public boolean linksource = false; |
|
117 |
||
118 |
/** |
|
119 |
* True if command line option "-nosince" is used. Default value is |
|
120 |
* false. |
|
121 |
*/ |
|
122 |
public boolean nosince = false; |
|
123 |
||
124 |
/** |
|
125 |
* True if we should recursively copy the doc-file subdirectories |
|
126 |
*/ |
|
127 |
public boolean copydocfilesubdirs = false; |
|
128 |
||
129 |
/** |
|
130 |
* The META charset tag used for cross-platform viewing. |
|
131 |
*/ |
|
132 |
public String charset = ""; |
|
133 |
||
134 |
/** |
|
135 |
* True if user wants to add member names as meta keywords. |
|
136 |
* Set to false because meta keywords are ignored in general |
|
137 |
* by most Internet search engines. |
|
138 |
*/ |
|
139 |
public boolean keywords = false; |
|
140 |
||
141 |
/** |
|
1475 | 142 |
* The meta tag keywords instance. |
10 | 143 |
*/ |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
144 |
public final MetaKeywords metakeywords; |
10 | 145 |
|
146 |
/** |
|
147 |
* The list of doc-file subdirectories to exclude |
|
148 |
*/ |
|
868 | 149 |
protected Set<String> excludedDocFileDirs; |
10 | 150 |
|
151 |
/** |
|
152 |
* The list of qualifiers to exclude |
|
153 |
*/ |
|
868 | 154 |
protected Set<String> excludedQualifiers; |
10 | 155 |
|
156 |
/** |
|
157 |
* The Root of the generated Program Structure from the Doclet API. |
|
158 |
*/ |
|
159 |
public RootDoc root; |
|
160 |
||
161 |
/** |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
162 |
* An utility class for commonly used helpers |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
163 |
*/ |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
164 |
public Utils utils; |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
165 |
/** |
10 | 166 |
* Destination directory name, in which doclet will generate the entire |
167 |
* documentation. Default is current directory. |
|
168 |
*/ |
|
169 |
public String destDirName = ""; |
|
170 |
||
171 |
/** |
|
172 |
* Destination directory name, in which doclet will copy the doc-files to. |
|
173 |
*/ |
|
174 |
public String docFileDestDirName = ""; |
|
175 |
||
176 |
/** |
|
177 |
* Encoding for this document. Default is default encoding for this |
|
178 |
* platform. |
|
179 |
*/ |
|
180 |
public String docencoding = null; |
|
181 |
||
182 |
/** |
|
183 |
* True if user wants to suppress descriptions and tags. |
|
184 |
*/ |
|
185 |
public boolean nocomment = false; |
|
186 |
||
187 |
/** |
|
188 |
* Encoding for this document. Default is default encoding for this |
|
189 |
* platform. |
|
190 |
*/ |
|
191 |
public String encoding = null; |
|
192 |
||
193 |
/** |
|
194 |
* Generate author specific information for all the classes if @author |
|
195 |
* tag is used in the doc comment and if -author option is used. |
|
196 |
* <code>showauthor</code> is set to true if -author option is used. |
|
197 |
* Default is don't show author information. |
|
198 |
*/ |
|
199 |
public boolean showauthor = false; |
|
200 |
||
201 |
/** |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15725
diff
changeset
|
202 |
* Generate documentation for JavaFX getters and setters automatically |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15725
diff
changeset
|
203 |
* by copying it from the appropriate property definition. |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15725
diff
changeset
|
204 |
*/ |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15725
diff
changeset
|
205 |
public boolean javafx = false; |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15725
diff
changeset
|
206 |
|
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15725
diff
changeset
|
207 |
/** |
10 | 208 |
* Generate version specific information for the all the classes |
209 |
* if @version tag is used in the doc comment and if -version option is |
|
210 |
* used. <code>showversion</code> is set to true if -version option is |
|
211 |
* used.Default is don't show version information. |
|
212 |
*/ |
|
213 |
public boolean showversion = false; |
|
15723
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14545
diff
changeset
|
214 |
|
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14545
diff
changeset
|
215 |
/** |
10 | 216 |
* Don't generate deprecated API information at all, if -nodeprecated |
217 |
* option is used. <code>nodepracted</code> is set to true if |
|
218 |
* -nodeprecated option is used. Default is generate deprected API |
|
219 |
* information. |
|
220 |
*/ |
|
221 |
public boolean nodeprecated = false; |
|
222 |
||
223 |
/** |
|
224 |
* The catalog of classes specified on the command-line |
|
225 |
*/ |
|
226 |
public ClassDocCatalog classDocCatalog; |
|
227 |
||
228 |
/** |
|
229 |
* Message Retriever for the doclet, to retrieve message from the resource |
|
230 |
* file for this Configuration, which is common for 1.1 and standard |
|
231 |
* doclets. |
|
232 |
* |
|
233 |
* TODO: Make this private!!! |
|
234 |
*/ |
|
235 |
public MessageRetriever message = null; |
|
236 |
||
237 |
/** |
|
238 |
* True if user wants to suppress time stamp in output. |
|
239 |
* Default is false. |
|
240 |
*/ |
|
241 |
public boolean notimestamp= false; |
|
242 |
||
243 |
/** |
|
1475 | 244 |
* The package grouping instance. |
10 | 245 |
*/ |
1475 | 246 |
public final Group group = new Group(this); |
10 | 247 |
|
248 |
/** |
|
1475 | 249 |
* The tracker of external package links. |
10 | 250 |
*/ |
251 |
public final Extern extern = new Extern(this); |
|
252 |
||
253 |
/** |
|
254 |
* Return the build date for the doclet. |
|
255 |
*/ |
|
256 |
public abstract String getDocletSpecificBuildDate(); |
|
257 |
||
258 |
/** |
|
259 |
* This method should be defined in all those doclets(configurations), |
|
260 |
* which want to derive themselves from this Configuration. This method |
|
261 |
* can be used to set its own command line options. |
|
262 |
* |
|
263 |
* @param options The array of option names and values. |
|
264 |
* @throws DocletAbortException |
|
265 |
*/ |
|
16324 | 266 |
public abstract void setSpecificDocletOptions(String[][] options) throws Fault; |
10 | 267 |
|
268 |
/** |
|
269 |
* Return the doclet specific {@link MessageRetriever} |
|
270 |
* @return the doclet specific MessageRetriever. |
|
271 |
*/ |
|
272 |
public abstract MessageRetriever getDocletSpecificMsg(); |
|
273 |
||
274 |
/** |
|
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
22165
diff
changeset
|
275 |
* A sorted set of packages specified on the command-line merged with a |
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
22165
diff
changeset
|
276 |
* collection of packages that contain the classes specified on the |
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
22165
diff
changeset
|
277 |
* command-line. |
10 | 278 |
*/ |
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
22165
diff
changeset
|
279 |
public SortedSet<PackageDoc> packages; |
10 | 280 |
|
36526 | 281 |
public boolean exportInternalAPI; |
35420 | 282 |
|
10 | 283 |
/** |
284 |
* Constructor. Constructs the message retriever with resource file. |
|
285 |
*/ |
|
286 |
public Configuration() { |
|
287 |
message = |
|
288 |
new MessageRetriever(this, |
|
289 |
"com.sun.tools.doclets.internal.toolkit.resources.doclets"); |
|
22163 | 290 |
excludedDocFileDirs = new HashSet<>(); |
291 |
excludedQualifiers = new HashSet<>(); |
|
14542 | 292 |
setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH); |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
293 |
utils = new Utils(); |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
294 |
metakeywords = new MetaKeywords(this); |
10 | 295 |
} |
296 |
||
297 |
/** |
|
298 |
* Return the builder factory for this doclet. |
|
299 |
* |
|
300 |
* @return the builder factory for this doclet. |
|
301 |
*/ |
|
302 |
public BuilderFactory getBuilderFactory() { |
|
303 |
if (builderFactory == null) { |
|
304 |
builderFactory = new BuilderFactory(this); |
|
305 |
} |
|
306 |
return builderFactory; |
|
307 |
} |
|
308 |
||
309 |
/** |
|
310 |
* This method should be defined in all those doclets |
|
311 |
* which want to inherit from this Configuration. This method |
|
312 |
* should return the number of arguments to the command line |
|
313 |
* option (including the option name). For example, |
|
314 |
* -notimestamp is a single-argument option, so this method would |
|
315 |
* return 1. |
|
316 |
* |
|
317 |
* @param option Command line option under consideration. |
|
318 |
* @return number of arguments to option (including the |
|
319 |
* option name). Zero return means option not known. |
|
320 |
* Negative value means error occurred. |
|
321 |
*/ |
|
322 |
public int optionLength(String option) { |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
19937
diff
changeset
|
323 |
option = StringUtils.toLowerCase(option); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
324 |
switch (option) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
325 |
case "-author": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
326 |
case "-docfilessubdirs": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
327 |
case "-javafx": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
328 |
case "-keywords": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
329 |
case "-linksource": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
330 |
case "-nocomment": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
331 |
case "-nodeprecated": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
332 |
case "-nosince": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
333 |
case "-notimestamp": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
334 |
case "-quiet": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
335 |
case "-xnodate": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
336 |
case "-version": |
36526 | 337 |
case "-xdaccessinternalapi": |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
338 |
return 1; |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
339 |
case "-d": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
340 |
case "-docencoding": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
341 |
case "-encoding": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
342 |
case "-excludedocfilessubdir": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
343 |
case "-link": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
344 |
case "-sourcetab": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
345 |
case "-noqualifier": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
346 |
case "-output": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
347 |
case "-sourcepath": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
348 |
case "-tag": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
349 |
case "-taglet": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
350 |
case "-tagletpath": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
351 |
return 2; |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
352 |
case "-group": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
353 |
case "-linkoffline": |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
354 |
return 3; |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
355 |
default: |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
356 |
return -1; // indicate we don't know about it |
10 | 357 |
} |
358 |
} |
|
359 |
||
360 |
/** |
|
361 |
* Perform error checking on the given options. |
|
362 |
* |
|
363 |
* @param options the given options to check. |
|
364 |
* @param reporter the reporter used to report errors. |
|
365 |
*/ |
|
366 |
public abstract boolean validOptions(String options[][], |
|
367 |
DocErrorReporter reporter); |
|
368 |
||
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
22165
diff
changeset
|
369 |
private void initPackages() { |
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
22165
diff
changeset
|
370 |
packages = new TreeSet<>(Arrays.asList(root.specifiedPackages())); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
371 |
for (ClassDoc aClass : root.specifiedClasses()) { |
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
22165
diff
changeset
|
372 |
packages.add(aClass.containingPackage()); |
10 | 373 |
} |
374 |
} |
|
375 |
||
376 |
/** |
|
377 |
* Set the command line options supported by this configuration. |
|
378 |
* |
|
379 |
* @param options the two dimensional array of options. |
|
380 |
*/ |
|
16324 | 381 |
public void setOptions(String[][] options) throws Fault { |
22163 | 382 |
LinkedHashSet<String[]> customTagStrs = new LinkedHashSet<>(); |
16324 | 383 |
|
384 |
// Some options, specifically -link and -linkoffline, require that |
|
385 |
// the output directory has already been created: so do that first. |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
386 |
for (String[] os : options) { |
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
19937
diff
changeset
|
387 |
String opt = StringUtils.toLowerCase(os[0]); |
10 | 388 |
if (opt.equals("-d")) { |
389 |
destDirName = addTrailingFileSep(os[1]); |
|
390 |
docFileDestDirName = destDirName; |
|
16324 | 391 |
ensureOutputDirExists(); |
392 |
break; |
|
393 |
} |
|
394 |
} |
|
395 |
||
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
396 |
for (String[] os : options) { |
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
19937
diff
changeset
|
397 |
String opt = StringUtils.toLowerCase(os[0]); |
16324 | 398 |
if (opt.equals("-docfilessubdirs")) { |
10 | 399 |
copydocfilesubdirs = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
400 |
} else if (opt.equals("-docencoding")) { |
10 | 401 |
docencoding = os[1]; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
402 |
} else if (opt.equals("-encoding")) { |
10 | 403 |
encoding = os[1]; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
404 |
} else if (opt.equals("-author")) { |
10 | 405 |
showauthor = true; |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15725
diff
changeset
|
406 |
} else if (opt.equals("-javafx")) { |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15725
diff
changeset
|
407 |
javafx = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
408 |
} else if (opt.equals("-nosince")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
409 |
nosince = true; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
410 |
} else if (opt.equals("-version")) { |
10 | 411 |
showversion = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
412 |
} else if (opt.equals("-nodeprecated")) { |
10 | 413 |
nodeprecated = true; |
414 |
} else if (opt.equals("-excludedocfilessubdir")) { |
|
415 |
addToSet(excludedDocFileDirs, os[1]); |
|
416 |
} else if (opt.equals("-noqualifier")) { |
|
417 |
addToSet(excludedQualifiers, os[1]); |
|
418 |
} else if (opt.equals("-linksource")) { |
|
419 |
linksource = true; |
|
420 |
} else if (opt.equals("-sourcetab")) { |
|
421 |
linksource = true; |
|
422 |
try { |
|
14542 | 423 |
setTabWidth(Integer.parseInt(os[1])); |
10 | 424 |
} catch (NumberFormatException e) { |
425 |
//Set to -1 so that warning will be printed |
|
426 |
//to indicate what is valid argument. |
|
427 |
sourcetab = -1; |
|
428 |
} |
|
429 |
if (sourcetab <= 0) { |
|
430 |
message.warning("doclet.sourcetab_warning"); |
|
14542 | 431 |
setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH); |
10 | 432 |
} |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
433 |
} else if (opt.equals("-notimestamp")) { |
10 | 434 |
notimestamp = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
435 |
} else if (opt.equals("-nocomment")) { |
10 | 436 |
nocomment = true; |
437 |
} else if (opt.equals("-tag") || opt.equals("-taglet")) { |
|
438 |
customTagStrs.add(os); |
|
439 |
} else if (opt.equals("-tagletpath")) { |
|
440 |
tagletpath = os[1]; |
|
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
441 |
} else if (opt.equals("-keywords")) { |
10 | 442 |
keywords = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
443 |
} else if (opt.equals("-serialwarn")) { |
10 | 444 |
serialwarn = true; |
445 |
} else if (opt.equals("-group")) { |
|
446 |
group.checkPackageGroups(os[1], os[2]); |
|
447 |
} else if (opt.equals("-link")) { |
|
448 |
String url = os[1]; |
|
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14263
diff
changeset
|
449 |
extern.link(url, url, root, false); |
10 | 450 |
} else if (opt.equals("-linkoffline")) { |
451 |
String url = os[1]; |
|
452 |
String pkglisturl = os[2]; |
|
14361
2814fa6977ac
8001219: Clean up use of URLs in javadoc Extern class
jjg
parents:
14263
diff
changeset
|
453 |
extern.link(url, pkglisturl, root, true); |
36526 | 454 |
} else if (opt.equals("-xdaccessinternalapi")) { |
455 |
exportInternalAPI = true; |
|
10 | 456 |
} |
457 |
} |
|
458 |
if (docencoding == null) { |
|
459 |
docencoding = encoding; |
|
460 |
} |
|
461 |
||
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
462 |
classDocCatalog = new ClassDocCatalog(root.specifiedClasses(), this); |
10 | 463 |
initTagletManager(customTagStrs); |
464 |
} |
|
465 |
||
466 |
/** |
|
467 |
* Set the command line options supported by this configuration. |
|
468 |
* |
|
469 |
* @throws DocletAbortException |
|
470 |
*/ |
|
16324 | 471 |
public void setOptions() throws Fault { |
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
22165
diff
changeset
|
472 |
initPackages(); |
10 | 473 |
setOptions(root.options()); |
474 |
setSpecificDocletOptions(root.options()); |
|
475 |
} |
|
476 |
||
16324 | 477 |
private void ensureOutputDirExists() throws Fault { |
478 |
DocFile destDir = DocFile.createFileForDirectory(this, destDirName); |
|
479 |
if (!destDir.exists()) { |
|
480 |
//Create the output directory (in case it doesn't exist yet) |
|
481 |
root.printNotice(getText("doclet.dest_dir_create", destDirName)); |
|
482 |
destDir.mkdirs(); |
|
483 |
} else if (!destDir.isDirectory()) { |
|
484 |
throw new Fault(getText( |
|
485 |
"doclet.destination_directory_not_directory_0", |
|
486 |
destDir.getPath())); |
|
487 |
} else if (!destDir.canWrite()) { |
|
488 |
throw new Fault(getText( |
|
489 |
"doclet.destination_directory_not_writable_0", |
|
490 |
destDir.getPath())); |
|
491 |
} |
|
492 |
} |
|
493 |
||
10 | 494 |
|
495 |
/** |
|
496 |
* Initialize the taglet manager. The strings to initialize the simple custom tags should |
|
497 |
* be in the following format: "[tag name]:[location str]:[heading]". |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
498 |
* @param customTagStrs the set two dimensional arrays of strings. These arrays contain |
10 | 499 |
* either -tag or -taglet arguments. |
500 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1475
diff
changeset
|
501 |
private void initTagletManager(Set<String[]> customTagStrs) { |
36526 | 502 |
tagletManager = (tagletManager == null) |
503 |
? new TagletManager(nosince, showversion, showauthor, javafx, exportInternalAPI, message) |
|
504 |
: tagletManager; |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
505 |
for (String[] args : customTagStrs) { |
10 | 506 |
if (args[0].equals("-taglet")) { |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
507 |
tagletManager.addCustomTag(args[1], getFileManager(), tagletpath); |
10 | 508 |
continue; |
509 |
} |
|
14368
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
510 |
String[] tokens = tokenize(args[1], |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
511 |
TagletManager.SIMPLE_TAGLET_OPT_SEPARATOR, 3); |
10 | 512 |
if (tokens.length == 1) { |
513 |
String tagName = args[1]; |
|
514 |
if (tagletManager.isKnownCustomTag(tagName)) { |
|
515 |
//reorder a standard tag |
|
516 |
tagletManager.addNewSimpleCustomTag(tagName, null, ""); |
|
517 |
} else { |
|
518 |
//Create a simple tag with the heading that has the same name as the tag. |
|
14263 | 519 |
StringBuilder heading = new StringBuilder(tagName + ":"); |
10 | 520 |
heading.setCharAt(0, Character.toUpperCase(tagName.charAt(0))); |
521 |
tagletManager.addNewSimpleCustomTag(tagName, heading.toString(), "a"); |
|
522 |
} |
|
523 |
} else if (tokens.length == 2) { |
|
524 |
//Add simple taglet without heading, probably to excluding it in the output. |
|
525 |
tagletManager.addNewSimpleCustomTag(tokens[0], tokens[1], ""); |
|
526 |
} else if (tokens.length >= 3) { |
|
527 |
tagletManager.addNewSimpleCustomTag(tokens[0], tokens[2], tokens[1]); |
|
528 |
} else { |
|
529 |
message.error("doclet.Error_invalid_custom_tag_argument", args[1]); |
|
530 |
} |
|
531 |
} |
|
532 |
} |
|
533 |
||
14368
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
534 |
/** |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
535 |
* Given a string, return an array of tokens. The separator can be escaped |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
536 |
* with the '\' character. The '\' character may also be escaped by the |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
537 |
* '\' character. |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
538 |
* |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
539 |
* @param s the string to tokenize. |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
540 |
* @param separator the separator char. |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
541 |
* @param maxTokens the maximum number of tokens returned. If the |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
542 |
* max is reached, the remaining part of s is appended |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
543 |
* to the end of the last token. |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
544 |
* |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
545 |
* @return an array of tokens. |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
546 |
*/ |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
547 |
private String[] tokenize(String s, char separator, int maxTokens) { |
22163 | 548 |
List<String> tokens = new ArrayList<>(); |
14368
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
549 |
StringBuilder token = new StringBuilder (); |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
550 |
boolean prevIsEscapeChar = false; |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
551 |
for (int i = 0; i < s.length(); i += Character.charCount(i)) { |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
552 |
int currentChar = s.codePointAt(i); |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
553 |
if (prevIsEscapeChar) { |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
554 |
// Case 1: escaped character |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
555 |
token.appendCodePoint(currentChar); |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
556 |
prevIsEscapeChar = false; |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
557 |
} else if (currentChar == separator && tokens.size() < maxTokens-1) { |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
558 |
// Case 2: separator |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
559 |
tokens.add(token.toString()); |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
560 |
token = new StringBuilder(); |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
561 |
} else if (currentChar == '\\') { |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
562 |
// Case 3: escape character |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
563 |
prevIsEscapeChar = true; |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
564 |
} else { |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
565 |
// Case 4: regular character |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
566 |
token.appendCodePoint(currentChar); |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
567 |
} |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
568 |
} |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
569 |
if (token.length() > 0) { |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
570 |
tokens.add(token.toString()); |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
571 |
} |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
572 |
return tokens.toArray(new String[] {}); |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
573 |
} |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
574 |
|
868 | 575 |
private void addToSet(Set<String> s, String str){ |
10 | 576 |
StringTokenizer st = new StringTokenizer(str, ":"); |
577 |
String current; |
|
578 |
while(st.hasMoreTokens()){ |
|
579 |
current = st.nextToken(); |
|
580 |
s.add(current); |
|
581 |
} |
|
582 |
} |
|
583 |
||
584 |
/** |
|
14061
9ac68cf0048b
4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents:
13842
diff
changeset
|
585 |
* Add a trailing file separator, if not found. Remove superfluous |
9ac68cf0048b
4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents:
13842
diff
changeset
|
586 |
* file separators if any. Preserve the front double file separator for |
9ac68cf0048b
4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents:
13842
diff
changeset
|
587 |
* UNC paths. |
10 | 588 |
* |
589 |
* @param path Path under consideration. |
|
590 |
* @return String Properly constructed path string. |
|
591 |
*/ |
|
14061
9ac68cf0048b
4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents:
13842
diff
changeset
|
592 |
public static String addTrailingFileSep(String path) { |
10 | 593 |
String fs = System.getProperty("file.separator"); |
594 |
String dblfs = fs + fs; |
|
595 |
int indexDblfs; |
|
14061
9ac68cf0048b
4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents:
13842
diff
changeset
|
596 |
while ((indexDblfs = path.indexOf(dblfs, 1)) >= 0) { |
10 | 597 |
path = path.substring(0, indexDblfs) + |
598 |
path.substring(indexDblfs + fs.length()); |
|
599 |
} |
|
600 |
if (!path.endsWith(fs)) |
|
601 |
path += fs; |
|
602 |
return path; |
|
603 |
} |
|
604 |
||
605 |
/** |
|
606 |
* This checks for the validity of the options used by the user. |
|
607 |
* This works exactly like |
|
608 |
* {@link com.sun.javadoc.Doclet#validOptions(String[][], |
|
609 |
* DocErrorReporter)}. This will validate the options which are shared |
|
610 |
* by our doclets. For example, this method will flag an error using |
|
611 |
* the DocErrorReporter if user has used "-nohelp" and "-helpfile" option |
|
612 |
* together. |
|
613 |
* |
|
614 |
* @param options options used on the command line. |
|
615 |
* @param reporter used to report errors. |
|
616 |
* @return true if all the options are valid. |
|
617 |
*/ |
|
618 |
public boolean generalValidOptions(String options[][], |
|
619 |
DocErrorReporter reporter) { |
|
620 |
boolean docencodingfound = false; |
|
621 |
String encoding = ""; |
|
622 |
for (int oi = 0; oi < options.length; oi++) { |
|
623 |
String[] os = options[oi]; |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
19937
diff
changeset
|
624 |
String opt = StringUtils.toLowerCase(os[0]); |
16324 | 625 |
if (opt.equals("-docencoding")) { |
10 | 626 |
docencodingfound = true; |
627 |
if (!checkOutputFileEncoding(os[1], reporter)) { |
|
628 |
return false; |
|
629 |
} |
|
630 |
} else if (opt.equals("-encoding")) { |
|
631 |
encoding = os[1]; |
|
632 |
} |
|
633 |
} |
|
634 |
if (!docencodingfound && encoding.length() > 0) { |
|
635 |
if (!checkOutputFileEncoding(encoding, reporter)) { |
|
636 |
return false; |
|
637 |
} |
|
638 |
} |
|
639 |
return true; |
|
640 |
} |
|
641 |
||
642 |
/** |
|
643 |
* Check the validity of the given Source or Output File encoding on this |
|
644 |
* platform. |
|
645 |
* |
|
646 |
* @param docencoding output file encoding. |
|
647 |
* @param reporter used to report errors. |
|
648 |
*/ |
|
649 |
private boolean checkOutputFileEncoding(String docencoding, |
|
650 |
DocErrorReporter reporter) { |
|
651 |
OutputStream ost= new ByteArrayOutputStream(); |
|
652 |
OutputStreamWriter osw = null; |
|
653 |
try { |
|
654 |
osw = new OutputStreamWriter(ost, docencoding); |
|
655 |
} catch (UnsupportedEncodingException exc) { |
|
656 |
reporter.printError(getText("doclet.Encoding_not_supported", |
|
657 |
docencoding)); |
|
658 |
return false; |
|
659 |
} finally { |
|
660 |
try { |
|
661 |
if (osw != null) { |
|
662 |
osw.close(); |
|
663 |
} |
|
664 |
} catch (IOException exc) { |
|
665 |
} |
|
666 |
} |
|
667 |
return true; |
|
668 |
} |
|
669 |
||
670 |
/** |
|
671 |
* Return true if the given doc-file subdirectory should be excluded and |
|
672 |
* false otherwise. |
|
673 |
* @param docfilesubdir the doc-files subdirectory to check. |
|
674 |
*/ |
|
675 |
public boolean shouldExcludeDocFileDir(String docfilesubdir){ |
|
676 |
if (excludedDocFileDirs.contains(docfilesubdir)) { |
|
677 |
return true; |
|
678 |
} else { |
|
679 |
return false; |
|
680 |
} |
|
681 |
} |
|
682 |
||
683 |
/** |
|
684 |
* Return true if the given qualifier should be excluded and false otherwise. |
|
685 |
* @param qualifier the qualifier to check. |
|
686 |
*/ |
|
687 |
public boolean shouldExcludeQualifier(String qualifier){ |
|
688 |
if (excludedQualifiers.contains("all") || |
|
689 |
excludedQualifiers.contains(qualifier) || |
|
690 |
excludedQualifiers.contains(qualifier + ".*")) { |
|
691 |
return true; |
|
692 |
} else { |
|
693 |
int index = -1; |
|
694 |
while ((index = qualifier.indexOf(".", index + 1)) != -1) { |
|
695 |
if (excludedQualifiers.contains(qualifier.substring(0, index + 1) + "*")) { |
|
696 |
return true; |
|
697 |
} |
|
698 |
} |
|
699 |
return false; |
|
700 |
} |
|
701 |
} |
|
702 |
||
703 |
/** |
|
704 |
* Return the qualified name of the <code>ClassDoc</code> if it's qualifier is not excluded. Otherwise, |
|
705 |
* return the unqualified <code>ClassDoc</code> name. |
|
706 |
* @param cd the <code>ClassDoc</code> to check. |
|
707 |
*/ |
|
708 |
public String getClassName(ClassDoc cd) { |
|
709 |
PackageDoc pd = cd.containingPackage(); |
|
710 |
if (pd != null && shouldExcludeQualifier(cd.containingPackage().name())) { |
|
711 |
return cd.name(); |
|
712 |
} else { |
|
713 |
return cd.qualifiedName(); |
|
714 |
} |
|
715 |
} |
|
716 |
||
717 |
public String getText(String key) { |
|
38515
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
718 |
// Check the doclet specific properties file. |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
719 |
MessageRetriever docletMessage = getDocletSpecificMsg(); |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
720 |
if (docletMessage.containsKey(key)) { |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
721 |
return docletMessage.getText(key); |
10 | 722 |
} |
38515
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
723 |
// Check the shared properties file. |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
724 |
return message.getText(key); |
10 | 725 |
} |
726 |
||
727 |
public String getText(String key, String a1) { |
|
38515
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
728 |
// Check the doclet specific properties file. |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
729 |
MessageRetriever docletMessage = getDocletSpecificMsg(); |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
730 |
if (docletMessage.containsKey(key)) { |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
731 |
return docletMessage.getText(key, a1); |
10 | 732 |
} |
38515
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
733 |
// Check the shared properties file. |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
734 |
return message.getText(key, a1); |
10 | 735 |
} |
736 |
||
737 |
public String getText(String key, String a1, String a2) { |
|
38515
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
738 |
// Check the doclet specific properties file. |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
739 |
MessageRetriever docletMessage = getDocletSpecificMsg(); |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
740 |
if (docletMessage.containsKey(key)) { |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
741 |
return docletMessage.getText(key, a1, a2); |
10 | 742 |
} |
38515
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
743 |
// Check the shared properties file. |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
744 |
return message.getText(key, a1, a2); |
10 | 745 |
} |
746 |
||
747 |
public String getText(String key, String a1, String a2, String a3) { |
|
38515
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
748 |
// Check the doclet specific properties file. |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
749 |
MessageRetriever docletMessage = getDocletSpecificMsg(); |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
750 |
if (docletMessage.containsKey(key)) { |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
751 |
return docletMessage.getText(key, a1, a2, a3); |
10 | 752 |
} |
38515
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
753 |
// Check the shared properties file. |
6ae7f7d9b44c
8157102: Avoid exceptional control flow in Configuration.getText
redestad
parents:
36526
diff
changeset
|
754 |
return message.getText(key, a1, a2, a3); |
10 | 755 |
} |
756 |
||
17570
78512b2899db
8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents:
17563
diff
changeset
|
757 |
public abstract Content newContent(); |
17563
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
758 |
|
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
759 |
/** |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
760 |
* Get the configuration string as a content. |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
761 |
* |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
762 |
* @param key the key to look for in the configuration file |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
763 |
* @return a content tree for the text |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
764 |
*/ |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
765 |
public Content getResource(String key) { |
17570
78512b2899db
8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents:
17563
diff
changeset
|
766 |
Content c = newContent(); |
17563
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
767 |
c.addContent(getText(key)); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
768 |
return c; |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
769 |
} |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
770 |
|
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
771 |
/** |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
772 |
* Get the configuration string as a content. |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
773 |
* |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
774 |
* @param key the key to look for in the configuration file |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
775 |
* @param o string or content argument added to configuration text |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
776 |
* @return a content tree for the text |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
777 |
*/ |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
778 |
public Content getResource(String key, Object o) { |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
779 |
return getResource(key, o, null, null); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
780 |
} |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
781 |
|
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
782 |
/** |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
783 |
* Get the configuration string as a content. |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
784 |
* |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
785 |
* @param key the key to look for in the configuration file |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
786 |
* @param o string or content argument added to configuration text |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
787 |
* @return a content tree for the text |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
788 |
*/ |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
789 |
public Content getResource(String key, Object o1, Object o2) { |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
790 |
return getResource(key, o1, o2, null); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
791 |
} |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
792 |
|
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
793 |
/** |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
794 |
* Get the configuration string as a content. |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
795 |
* |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
796 |
* @param key the key to look for in the configuration file |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
797 |
* @param o1 string or content argument added to configuration text |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
798 |
* @param o2 string or content argument added to configuration text |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
799 |
* @return a content tree for the text |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
800 |
*/ |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
801 |
public Content getResource(String key, Object o0, Object o1, Object o2) { |
17570
78512b2899db
8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents:
17563
diff
changeset
|
802 |
Content c = newContent(); |
17563
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
803 |
Pattern p = Pattern.compile("\\{([012])\\}"); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
804 |
String text = getText(key); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
805 |
Matcher m = p.matcher(text); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
806 |
int start = 0; |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
807 |
while (m.find(start)) { |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
808 |
c.addContent(text.substring(start, m.start())); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
809 |
|
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
810 |
Object o = null; |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
811 |
switch (m.group(1).charAt(0)) { |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
812 |
case '0': o = o0; break; |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
813 |
case '1': o = o1; break; |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
814 |
case '2': o = o2; break; |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
815 |
} |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
816 |
|
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
817 |
if (o == null) { |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
818 |
c.addContent("{" + m.group(1) + "}"); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
819 |
} else if (o instanceof String) { |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
820 |
c.addContent((String) o); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
821 |
} else if (o instanceof Content) { |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
822 |
c.addContent((Content) o); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
823 |
} |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
824 |
|
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
825 |
start = m.end(); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
826 |
} |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
827 |
|
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
828 |
c.addContent(text.substring(start)); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
829 |
return c; |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
830 |
} |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
831 |
|
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
16560
diff
changeset
|
832 |
|
10 | 833 |
/** |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
834 |
* Return true if the ClassDoc element is getting documented, depending upon |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
835 |
* -nodeprecated option and the deprecation information. Return true if |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
836 |
* -nodeprecated is not used. Return false if -nodeprecated is used and if |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
837 |
* either ClassDoc element is deprecated or the containing package is deprecated. |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
838 |
* |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
839 |
* @param cd the ClassDoc for which the page generation is checked |
10 | 840 |
*/ |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
841 |
public boolean isGeneratedDoc(ClassDoc cd) { |
10 | 842 |
if (!nodeprecated) { |
843 |
return true; |
|
844 |
} |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
24221
diff
changeset
|
845 |
return !(utils.isDeprecated(cd) || utils.isDeprecated(cd.containingPackage())); |
10 | 846 |
} |
847 |
||
848 |
/** |
|
849 |
* Return the doclet specific instance of a writer factory. |
|
850 |
* @return the {@link WriterFactory} for the doclet. |
|
851 |
*/ |
|
852 |
public abstract WriterFactory getWriterFactory(); |
|
853 |
||
854 |
/** |
|
855 |
* Return the input stream to the builder XML. |
|
856 |
* |
|
857 |
* @return the input steam to the builder XML. |
|
858 |
* @throws FileNotFoundException when the given XML file cannot be found. |
|
859 |
*/ |
|
14544 | 860 |
public InputStream getBuilderXML() throws IOException { |
10 | 861 |
return builderXMLPath == null ? |
862 |
Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) : |
|
14368
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14361
diff
changeset
|
863 |
DocFile.createFileForInput(this, builderXMLPath).openInputStream(); |
10 | 864 |
} |
865 |
||
866 |
/** |
|
1863
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1789
diff
changeset
|
867 |
* Return the Locale for this document. |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1789
diff
changeset
|
868 |
*/ |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1789
diff
changeset
|
869 |
public abstract Locale getLocale(); |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1789
diff
changeset
|
870 |
|
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1789
diff
changeset
|
871 |
/** |
14544 | 872 |
* Return the current file manager. |
873 |
*/ |
|
874 |
public abstract JavaFileManager getFileManager(); |
|
875 |
||
876 |
/** |
|
10 | 877 |
* Return the comparator that will be used to sort member documentation. |
878 |
* To no do any sorting, return null. |
|
879 |
* |
|
880 |
* @return the {@link java.util.Comparator} used to sort members. |
|
881 |
*/ |
|
868 | 882 |
public abstract Comparator<ProgramElementDoc> getMemberComparator(); |
14542 | 883 |
|
884 |
private void setTabWidth(int n) { |
|
885 |
sourcetab = n; |
|
886 |
tabSpaces = String.format("%" + n + "s", ""); |
|
887 |
} |
|
15354 | 888 |
|
889 |
public abstract boolean showMessage(SourcePosition pos, String key); |
|
36526 | 890 |
|
891 |
public abstract Location getLocationForPackage(PackageDoc pd); |
|
10 | 892 |
} |