Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseOptions.java
44719 views
1
/*
2
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
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.io.ByteArrayOutputStream;
29
import java.io.IOException;
30
import java.io.OutputStream;
31
import java.io.OutputStreamWriter;
32
import java.io.UnsupportedEncodingException;
33
import java.util.ArrayList;
34
import java.util.Arrays;
35
import java.util.HashSet;
36
import java.util.LinkedHashSet;
37
import java.util.List;
38
import java.util.MissingResourceException;
39
import java.util.Set;
40
import java.util.StringTokenizer;
41
import java.util.TreeSet;
42
43
import jdk.javadoc.doclet.Doclet;
44
import jdk.javadoc.doclet.Reporter;
45
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
46
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
47
48
import static javax.tools.Diagnostic.Kind.ERROR;
49
50
/**
51
* Storage for the format-independent options supported by the toolkit.
52
* The objects to handle command-line options, and to initialize this
53
* object, are all subtypes of {@link BaseOptions.Option},
54
* returned by {@link BaseOptions#getSupportedOptions()}.
55
*
56
* <p>Some of the methods used to access the values of options
57
* have names that begin with a verb, such as {@link #copyDocfileSubdirs}
58
* or {@link #showVersion}. Unless otherwise stated,
59
* these methods should all be taken as just accessing the value
60
* of the associated option.
61
*/
62
public abstract class BaseOptions {
63
64
//<editor-fold desc="Option values">
65
66
/**
67
* Argument for command-line option {@code --allow-script-in-comments}.
68
* Allow JavaScript in doc comments.
69
*/
70
private boolean allowScriptInComments = false;
71
72
/**
73
* Argument for command-line option {@code -docfilessubdirs}.
74
* True if we should recursively copy the doc-file subdirectories
75
*/
76
private boolean copyDocfileSubdirs = false;
77
78
/**
79
* Arguments for command-line option {@code -tag} and {@code -taglet}.
80
*/
81
private final LinkedHashSet<List<String>> customTagStrs = new LinkedHashSet<>();
82
83
/**
84
* Argument for command-line option {@code -d}.
85
* Destination directory name, in which doclet will generate the entire
86
* documentation. Default is current directory.
87
*/
88
private String destDirName = "";
89
90
/**
91
* Argument for command-line option {@code --disable-javafx-strict-checks}.
92
* Primarily used to disable strict checks in the regression
93
* tests allowing those tests to be executed successfully, for
94
* instance, with OpenJDK builds which may not contain FX libraries.
95
*/
96
private boolean disableJavaFxStrictChecks = false;
97
98
/**
99
* Argument for command-line option {@code -docencoding}.
100
* Encoding for this document. Default is default encoding for this
101
* platform.
102
*/
103
private String docEncoding = null;
104
105
/**
106
* Argument for command-line option {@code ???}.
107
* Destination directory name, in which doclet will copy the doc-files to.
108
*/
109
private String docFileDestDirName = "";
110
111
/**
112
* Argument for hidden command-line option {@code --dump-on-error}.
113
*/
114
private boolean dumpOnError = false;
115
116
/**
117
* Argument for command-line option {@code -encoding}.
118
* Encoding for this document. Default is default encoding for this
119
* platform.
120
*/
121
private String encoding = null;
122
123
/**
124
* Argument for command-line option {@code -excludedocfilessubdir}.
125
* The set of doc-file subdirectories to exclude.
126
*/
127
private Set<String> excludedDocFileDirs;
128
129
/**
130
* Argument for command-line option {@code -noqualifier}.
131
* The set of qualifiers to exclude.
132
*/
133
private Set<String> excludedQualifiers;
134
135
/**
136
* Arguments for command-line option {@code -group}
137
*/
138
private List<Utils.Pair<String, String>> groupPairs;
139
140
/**
141
* Argument for command-line option {@code --javafx} or {@code -javafx}.
142
* Generate documentation for JavaFX getters and setters automatically
143
* by copying it from the appropriate property definition.
144
*/
145
private boolean javafx = false;
146
147
/**
148
* Argument for command-line option {@code -keywords}.
149
* True if user wants to add member names as meta keywords.
150
* Set to false because meta keywords are ignored in general
151
* by most Internet search engines.
152
*/
153
private boolean keywords = false;
154
155
/**
156
* Arguments for command-line option {@code -link}.
157
*/
158
// A list containing urls
159
private final List<String> linkList = new ArrayList<>();
160
161
/**
162
* Arguments for command-line option {@code -linkoffline}.
163
*/
164
// A list of pairs containing urls and package list
165
private final List<Utils.Pair<String, String>> linkOfflineList = new ArrayList<>();
166
167
/**
168
* Location of alternative platform link properties file.
169
*/
170
private String linkPlatformProperties;
171
172
/**
173
* Argument for command-line option {@code -linksource}.
174
* True if we should generate browsable sources.
175
*/
176
private boolean linkSource = false;
177
178
/**
179
* Argument for command-line option {@code -nocomment}.
180
* True if user wants to suppress descriptions and tags.
181
*/
182
private boolean noComment = false;
183
184
/**
185
* Argument for command-line option {@code -nodeprecated}.
186
* Don't generate deprecated API information at all, if -nodeprecated
187
* option is used. <code>nodeprecated</code> is set to true if
188
* -nodeprecated option is used. Default is generate deprecated API
189
* information.
190
*/
191
private boolean noDeprecated = false;
192
193
/**
194
* Argument for command-line option {@code --no-platform-links}.
195
* True if command-line option "--no-platform-links" is used. Default value is
196
* false.
197
*/
198
private boolean noPlatformLinks = false;
199
200
/**
201
* Argument for command-line option {@code -nosince}.
202
* True if command-line option "-nosince" is used. Default value is
203
* false.
204
*/
205
private boolean noSince = false;
206
207
/**
208
* Argument for command-line option {@code -notimestamp}.
209
* True if user wants to suppress time stamp in output.
210
* Default is false.
211
*/
212
private boolean noTimestamp = false;
213
214
/**
215
* Argument for command-line option {@code -quiet}.
216
* Suppress all messages
217
*/
218
private boolean quiet = false;
219
220
/**
221
* Argument for command-line option {@code -serialwarn}.
222
* This is true if option "-serialwarn" is used. Default value is false to
223
* suppress excessive warnings about serial tag.
224
*/
225
private boolean serialWarn = false;
226
227
/**
228
* Argument for command-line option {@code -author}.
229
* Generate author specific information for all the classes if @author
230
* tag is used in the doc comment and if -author option is used.
231
* <code>showauthor</code> is set to true if -author option is used.
232
* Default is don't show author information.
233
*/
234
private boolean showAuthor = false;
235
236
/**
237
* Argument for command-line option {@code --show-taglets}.
238
* Show taglets (internal debug switch)
239
*/
240
private boolean showTaglets = false;
241
242
/**
243
* Argument for command-line option {@code -version}.
244
* Generate version specific information for the all the classes
245
* if @version tag is used in the doc comment and if -version option is
246
* used. {@code showVersion} is set to true if -version option is
247
* used. Default is don't show version information.
248
*/
249
private boolean showVersion = false;
250
251
/**
252
* Argument for command-line option {@code -sourcetab}.
253
* The specified amount of space between tab stops.
254
*/
255
private int sourceTabSize;
256
257
/**
258
* Value for command-line option {@code --override-methods summary}
259
* or {@code --override-methods detail}.
260
* Specifies whether those methods that override a super-type's method
261
* with no changes to the API contract should be summarized in the
262
* footnote section.
263
*/
264
private boolean summarizeOverriddenMethods = false;
265
266
/**
267
* Argument for command-line option {@code -tagletpath}.
268
* The path to Taglets
269
*/
270
private String tagletPath = null;
271
272
//</editor-fold>
273
274
private final BaseConfiguration config;
275
276
protected BaseOptions(BaseConfiguration config) {
277
this.config = config;
278
279
excludedDocFileDirs = new HashSet<>();
280
excludedQualifiers = new HashSet<>();
281
sourceTabSize = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
282
groupPairs = new ArrayList<>(0);
283
}
284
285
public Set<? extends Option> getSupportedOptions() {
286
Resources resources = config.getDocResources();
287
Messages messages = config.getMessages();
288
Reporter reporter = config.getReporter();
289
290
List<Option> options = List.of(
291
new Option(resources, "-author") {
292
@Override
293
public boolean process(String opt, List<String> args) {
294
showAuthor = true;
295
return true;
296
}
297
},
298
299
new Option(resources, "-d", 1) {
300
@Override
301
public boolean process(String opt, List<String> args) {
302
destDirName = addTrailingFileSep(args.get(0));
303
return true;
304
}
305
},
306
307
new Option(resources, "-docencoding", 1) {
308
@Override
309
public boolean process(String opt, List<String> args) {
310
docEncoding = args.get(0);
311
return true;
312
}
313
},
314
315
new Option(resources, "-docfilessubdirs") {
316
@Override
317
public boolean process(String opt, List<String> args) {
318
copyDocfileSubdirs = true;
319
return true;
320
}
321
},
322
323
new Hidden(resources, "-encoding", 1) {
324
@Override
325
public boolean process(String opt, List<String> args) {
326
encoding = args.get(0);
327
return true;
328
}
329
},
330
331
new Option(resources, "-excludedocfilessubdir", 1) {
332
@Override
333
public boolean process(String opt, List<String> args) {
334
addToSet(excludedDocFileDirs, args.get(0));
335
return true;
336
}
337
},
338
339
new Option(resources, "-group", 2) {
340
@Override
341
public boolean process(String opt, List<String> args) {
342
groupPairs.add(new Utils.Pair<>(args.get(0), args.get(1)));
343
return true;
344
}
345
},
346
347
new Option(resources, "--javafx -javafx") {
348
@Override
349
public boolean process(String opt, List<String> args) {
350
javafx = true;
351
return true;
352
}
353
},
354
355
new Option(resources, "-keywords") {
356
@Override
357
public boolean process(String opt, List<String> args) {
358
keywords = true;
359
return true;
360
}
361
},
362
363
new Option(resources, "-link", 1) {
364
@Override
365
public boolean process(String opt, List<String> args) {
366
linkList.add(args.get(0));
367
return true;
368
}
369
},
370
371
new Option(resources, "-linksource") {
372
@Override
373
public boolean process(String opt, List<String> args) {
374
linkSource = true;
375
return true;
376
}
377
},
378
379
new Option(resources, "-linkoffline", 2) {
380
@Override
381
public boolean process(String opt, List<String> args) {
382
linkOfflineList.add(new Utils.Pair<>(args.get(0), args.get(1)));
383
return true;
384
}
385
},
386
387
new Option(resources, "--link-platform-properties", 1) {
388
@Override
389
public boolean process(String opt, List<String> args) {
390
linkPlatformProperties = args.get(0);
391
return true;
392
}
393
},
394
395
new Option(resources, "-nocomment") {
396
@Override
397
public boolean process(String opt, List<String> args) {
398
noComment = true;
399
return true;
400
}
401
},
402
403
new Option(resources, "-nodeprecated") {
404
@Override
405
public boolean process(String opt, List<String> args) {
406
noDeprecated = true;
407
return true;
408
}
409
},
410
411
new Option(resources, "-nosince") {
412
@Override
413
public boolean process(String opt, List<String> args) {
414
noSince = true;
415
return true;
416
}
417
},
418
419
new Option(resources, "-notimestamp") {
420
@Override
421
public boolean process(String opt, List<String> args) {
422
noTimestamp = true;
423
return true;
424
}
425
},
426
427
new Option(resources, "-noqualifier", 1) {
428
@Override
429
public boolean process(String opt, List<String> args) {
430
addToSet(excludedQualifiers, args.get(0));
431
return true;
432
}
433
},
434
435
new Option(resources, "--no-platform-links") {
436
@Override
437
public boolean process(String opt, List<String> args) {
438
noPlatformLinks = true;
439
return true;
440
}
441
},
442
443
new Option(resources, "--override-methods", 1) {
444
@Override
445
public boolean process(String opt, List<String> args) {
446
String o = args.get(0);
447
switch (o) {
448
case "summary":
449
summarizeOverriddenMethods = true;
450
break;
451
case "detail":
452
summarizeOverriddenMethods = false;
453
break;
454
default:
455
reporter.print(ERROR,
456
resources.getText("doclet.Option_invalid",o, "--override-methods"));
457
return false;
458
}
459
return true;
460
}
461
},
462
463
new Hidden(resources, "-quiet") {
464
@Override
465
public boolean process(String opt, List<String> args) {
466
quiet = true;
467
return true;
468
}
469
},
470
471
new Option(resources, "-serialwarn") {
472
@Override
473
public boolean process(String opt, List<String> args) {
474
serialWarn = true;
475
return true;
476
}
477
},
478
479
new Option(resources, "-sourcetab", 1) {
480
@Override
481
public boolean process(String opt, List<String> args) {
482
linkSource = true;
483
try {
484
sourceTabSize = Integer.parseInt(args.get(0));
485
} catch (NumberFormatException e) {
486
//Set to -1 so that warning will be printed
487
//to indicate what is valid argument.
488
sourceTabSize = -1;
489
}
490
if (sourceTabSize <= 0) {
491
messages.warning("doclet.sourcetab_warning");
492
sourceTabSize = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
493
}
494
return true;
495
}
496
},
497
498
new Option(resources, "-tag", 1) {
499
@Override
500
public boolean process(String opt, List<String> args) {
501
ArrayList<String> list = new ArrayList<>();
502
list.add(opt);
503
list.add(args.get(0));
504
customTagStrs.add(list);
505
return true;
506
}
507
},
508
509
new Option(resources, "-taglet", 1) {
510
@Override
511
public boolean process(String opt, List<String> args) {
512
ArrayList<String> list = new ArrayList<>();
513
list.add(opt);
514
list.add(args.get(0));
515
customTagStrs.add(list);
516
return true;
517
}
518
},
519
520
new Option(resources, "-tagletpath", 1) {
521
@Override
522
public boolean process(String opt, List<String> args) {
523
tagletPath = args.get(0);
524
return true;
525
}
526
},
527
528
new Option(resources, "-version") {
529
@Override
530
public boolean process(String opt, List<String> args) {
531
showVersion = true;
532
return true;
533
}
534
},
535
536
new Hidden(resources, "--dump-on-error") {
537
@Override
538
public boolean process(String opt, List<String> args) {
539
dumpOnError = true;
540
return true;
541
}
542
},
543
544
new Option(resources, "--allow-script-in-comments") {
545
@Override
546
public boolean process(String opt, List<String> args) {
547
allowScriptInComments = true;
548
return true;
549
}
550
},
551
552
new Hidden(resources, "--disable-javafx-strict-checks") {
553
@Override
554
public boolean process(String opt, List<String> args) {
555
disableJavaFxStrictChecks = true;
556
return true;
557
}
558
},
559
560
new Hidden(resources, "--show-taglets") {
561
@Override
562
public boolean process(String opt, List<String> args) {
563
showTaglets = true;
564
return true;
565
}
566
}
567
);
568
return new TreeSet<>(options);
569
}
570
571
/**
572
* This checks for the validity of the options used by the user.
573
* As of this writing, this checks only docencoding.
574
*
575
* @return true if all the options are valid.
576
*/
577
protected boolean generalValidOptions() {
578
if (docEncoding != null) {
579
if (!checkOutputFileEncoding(docEncoding)) {
580
return false;
581
}
582
}
583
if (docEncoding == null && (encoding != null && !encoding.isEmpty())) {
584
if (!checkOutputFileEncoding(encoding)) {
585
return false;
586
}
587
}
588
return true;
589
}
590
591
/**
592
* Check the validity of the given Source or Output File encoding on this
593
* platform.
594
*
595
* @param docencoding output file encoding.
596
*/
597
private boolean checkOutputFileEncoding(String docencoding) {
598
OutputStream ost = new ByteArrayOutputStream();
599
OutputStreamWriter osw = null;
600
try {
601
osw = new OutputStreamWriter(ost, docencoding);
602
} catch (UnsupportedEncodingException exc) {
603
config.reporter.print(ERROR,
604
config.getDocResources().getText("doclet.Encoding_not_supported", docencoding));
605
return false;
606
} finally {
607
try {
608
if (osw != null) {
609
osw.close();
610
}
611
} catch (IOException exc) {
612
}
613
}
614
return true;
615
}
616
617
private void addToSet(Set<String> s, String str) {
618
StringTokenizer st = new StringTokenizer(str, ":");
619
String current;
620
while (st.hasMoreTokens()) {
621
current = st.nextToken();
622
s.add(current);
623
}
624
}
625
626
/**
627
* Add a trailing file separator, if not found. Remove superfluous
628
* file separators if any. Preserve the front double file separator for
629
* UNC paths.
630
*
631
* @param path Path under consideration.
632
* @return String Properly constructed path string.
633
*/
634
protected static String addTrailingFileSep(String path) {
635
String fs = System.getProperty("file.separator");
636
String dblfs = fs + fs;
637
int indexDblfs;
638
while ((indexDblfs = path.indexOf(dblfs, 1)) >= 0) {
639
path = path.substring(0, indexDblfs) +
640
path.substring(indexDblfs + fs.length());
641
}
642
if (!path.endsWith(fs))
643
path += fs;
644
return path;
645
}
646
647
/**
648
* Argument for command-line option {@code --allow-script-in-comments}.
649
* Allow JavaScript in doc comments.
650
*/
651
boolean allowScriptInComments() {
652
return allowScriptInComments;
653
}
654
655
/**
656
* Argument for command-line option {@code -docfilessubdirs}.
657
* True if we should recursively copy the doc-file subdirectories
658
*/
659
public boolean copyDocfileSubdirs() {
660
return copyDocfileSubdirs;
661
}
662
663
/**
664
* Arguments for command-line option {@code -tag} and {@code -taglet}.
665
*/
666
LinkedHashSet<List<String>> customTagStrs() {
667
return customTagStrs;
668
}
669
670
/**
671
* Argument for command-line option {@code -d}.
672
* Destination directory name, in which doclet will generate the entire
673
* documentation. Default is current directory.
674
*/
675
String destDirName() {
676
return destDirName;
677
}
678
679
/**
680
* Argument for command-line option {@code --disable-javafx-strict-checks}.
681
* Primarily used to disable strict checks in the regression
682
* tests allowing those tests to be executed successfully, for
683
* instance, with OpenJDK builds which may not contain FX libraries.
684
*/
685
boolean disableJavaFxStrictChecks() {
686
return disableJavaFxStrictChecks;
687
}
688
689
/**
690
* Argument for command-line option {@code -docencoding}.
691
* Encoding for this document. Default is default encoding for this
692
* platform.
693
*/
694
public String docEncoding() {
695
return docEncoding;
696
}
697
698
public void setDocEncoding(String docEncoding) {
699
this.docEncoding = docEncoding;
700
}
701
702
703
/**
704
* Argument for command-line option {@code ???}.
705
* Destination directory name, in which doclet will copy the doc-files to.
706
*/
707
String docFileDestDirName() {
708
return docFileDestDirName;
709
}
710
711
/**
712
* Argument for hidden command-line option {@code --dump-on-error}.
713
*/
714
boolean dumpOnError() {
715
return dumpOnError;
716
}
717
718
/**
719
* Argument for command-line option {@code -encoding}.
720
* Encoding for this document. Default is default encoding for this
721
* platform.
722
*/
723
public String encoding() {
724
return encoding;
725
}
726
727
/**
728
* Argument for command-line option {@code -excludedocfilessubdir}.
729
* The set of doc-file subdirectories to exclude.
730
*/
731
Set<String> excludedDocFileDirs() {
732
return excludedDocFileDirs;
733
}
734
735
/**
736
* Argument for command-line option {@code -noqualifier}.
737
* The set of qualifiers to exclude.
738
*/
739
Set<String> excludedQualifiers() {
740
return excludedQualifiers;
741
}
742
743
/**
744
* Arguments for command-line option {@code -group}
745
*/
746
List<Utils.Pair<String, String>> groupPairs() {
747
return groupPairs;
748
}
749
750
/**
751
* Argument for command-line option {@code --javafx} or {@code -javafx}.
752
* Generate documentation for JavaFX getters and setters automatically
753
* by copying it from the appropriate property definition.
754
*/
755
public boolean javafx() {
756
return javafx;
757
}
758
759
public void setJavaFX(boolean javafx) {
760
this.javafx = javafx;
761
}
762
763
/**
764
* Argument for command-line option {@code -keywords}.
765
* True if user wants to add member names as meta keywords.
766
* Set to false because meta keywords are ignored in general
767
* by most Internet search engines.
768
*/
769
public boolean keywords() {
770
return keywords;
771
}
772
773
/**
774
* Arguments for command-line option {@code -link}.
775
*/
776
List<String> linkList() {
777
return linkList;
778
}
779
780
/**
781
* Arguments for command-line option {@code -linkoffline}.
782
*/
783
List<Utils.Pair<String, String>> linkOfflineList() {
784
return linkOfflineList;
785
}
786
787
/**
788
* Argument for command-line option {@code --link-platform-properties}.
789
*/
790
String linkPlatformProperties() {
791
return linkPlatformProperties;
792
}
793
794
/**
795
* Argument for command-line option {@code -linksource}.
796
* True if we should generate browsable sources.
797
*/
798
public boolean linkSource() {
799
return linkSource;
800
}
801
802
/**
803
* Argument for command-line option {@code -nocomment}.
804
* True if user wants to suppress descriptions and tags.
805
*/
806
public boolean noComment() {
807
return noComment;
808
}
809
810
/**
811
* Argument for command-line option {@code -nodeprecated}.
812
* Don't generate deprecated API information at all if -nodeprecated
813
* option is used. {@code noDeprecated} is set to {@code true} if
814
* {@code -nodeprecated} option is used.
815
* Default is generate deprecated API information.
816
*/
817
public boolean noDeprecated() {
818
return noDeprecated;
819
}
820
821
/**
822
* Argument for command-line option {@code --no-platform-links}.
823
* True if command-line option {@code --no-platform-links"} is used.
824
* Default value is false.
825
*/
826
public boolean noPlatformLinks() {
827
return noPlatformLinks;
828
}
829
830
/**
831
* Argument for command-line option {@code -nosince}.
832
* True if command-line option {@code -nosince"} is used.
833
* Default value is false.
834
*/
835
public boolean noSince() {
836
return noSince;
837
}
838
839
/**
840
* Argument for command-line option {@code -notimestamp}.
841
* True if user wants to suppress time stamp in output.
842
* Default is false.
843
*/
844
public boolean noTimestamp() {
845
return noTimestamp;
846
}
847
848
/**
849
* Argument for command-line option {@code -quiet}.
850
* Suppress all messages
851
*/
852
boolean quiet() {
853
return quiet;
854
}
855
856
/**
857
* Argument for command-line option {@code -serialwarn}.
858
* This is true if option "-serialwarn" is used. Default value is false to
859
* suppress excessive warnings about serial tag.
860
*/
861
public boolean serialWarn() {
862
return serialWarn;
863
}
864
865
/**
866
* Argument for command-line option {@code -author}.
867
* Generate author specific information for all the classes if @author
868
* tag is used in the doc comment and if -author option is used.
869
* <code>showauthor</code> is set to true if -author option is used.
870
* Default is don't show author information.
871
*/
872
public boolean showAuthor() {
873
return showAuthor;
874
}
875
876
/**
877
* Argument for command-line option {@code --show-taglets}.
878
* Show taglets (internal debug switch)
879
*/
880
public boolean showTaglets() {
881
return showTaglets;
882
}
883
884
/**
885
* Argument for command-line option {@code -version}.
886
* Generate version specific information for the all the classes
887
* if @version tag is used in the doc comment and if -version option is
888
* used. {@code showVersion} is set to true if -version option is
889
* used. Default is don't show version information.
890
*/
891
public boolean showVersion() {
892
return showVersion;
893
}
894
895
/**
896
* Argument for command-line option {@code -sourcetab}.
897
* The specified amount of space between tab stops.
898
*/
899
public int sourceTabSize() {
900
return sourceTabSize;
901
}
902
903
/**
904
* Value for command-line option {@code --override-methods summary}
905
* or {@code --override-methods detail}.
906
* Specifies whether those methods that override a super-type's method
907
* with no changes to the API contract should be summarized in the
908
* footnote section.
909
*/
910
public boolean summarizeOverriddenMethods() {
911
return summarizeOverriddenMethods;
912
}
913
914
/**
915
* Argument for command-line option {@code -tagletpath}.
916
* The path to Taglets
917
*/
918
public String tagletPath() {
919
return tagletPath;
920
}
921
922
protected abstract static class Option implements Doclet.Option, Comparable<Option> {
923
private final String[] names;
924
private final String parameters;
925
private final String description;
926
private final int argCount;
927
928
protected Option(Resources resources, String name, int argCount) {
929
this(resources, null, name, argCount);
930
}
931
932
protected Option(Resources resources, String keyBase, String name, int argCount) {
933
this.names = name.trim().split("\\s+");
934
if (keyBase == null) {
935
keyBase = "doclet.usage." + Utils.toLowerCase(names[0]).replaceAll("^-+", "");
936
}
937
String desc = getOptionsMessage(resources, keyBase + ".description");
938
if (desc.isEmpty()) {
939
this.description = "<MISSING KEY>";
940
this.parameters = "<MISSING KEY>";
941
} else {
942
this.description = desc;
943
this.parameters = getOptionsMessage(resources, keyBase + ".parameters");
944
}
945
this.argCount = argCount;
946
}
947
948
protected Option(Resources resources, String name) {
949
this(resources, name, 0);
950
}
951
952
private String getOptionsMessage(Resources resources, String key) {
953
try {
954
return resources.getText(key);
955
} catch (MissingResourceException ignore) {
956
return "";
957
}
958
}
959
960
@Override
961
public String getDescription() {
962
return description;
963
}
964
965
@Override
966
public Kind getKind() {
967
return Kind.STANDARD;
968
}
969
970
@Override
971
public List<String> getNames() {
972
return Arrays.asList(names);
973
}
974
975
@Override
976
public String getParameters() {
977
return parameters;
978
}
979
980
@Override
981
public String toString() {
982
return Arrays.toString(names);
983
}
984
985
@Override
986
public int getArgumentCount() {
987
return argCount;
988
}
989
990
public boolean matches(String option) {
991
for (String name : names) {
992
boolean matchCase = name.startsWith("--");
993
if (option.startsWith("--") && option.contains("=")) {
994
return name.equals(option.substring(option.indexOf("=") + 1));
995
} else if (matchCase) {
996
return name.equals(option);
997
}
998
return name.equalsIgnoreCase(option);
999
}
1000
return false;
1001
}
1002
1003
@Override
1004
public int compareTo(Option that) {
1005
return this.getNames().get(0).compareTo(that.getNames().get(0));
1006
}
1007
}
1008
1009
protected abstract static class XOption extends Option {
1010
1011
public XOption(Resources resources, String prefix, String name, int argCount) {
1012
super(resources, prefix, name, argCount);
1013
}
1014
1015
public XOption(Resources resources, String name, int argCount) {
1016
super(resources, name, argCount);
1017
}
1018
1019
public XOption(Resources resources, String name) {
1020
this(resources, name, 0);
1021
}
1022
1023
@Override
1024
public Option.Kind getKind() {
1025
return Kind.EXTENDED;
1026
}
1027
}
1028
1029
protected abstract static class Hidden extends Option {
1030
1031
public Hidden(Resources resources, String name, int argCount) {
1032
super(resources, name, argCount);
1033
}
1034
1035
public Hidden(Resources resources, String name) {
1036
this(resources, name, 0);
1037
}
1038
1039
@Override
1040
public Option.Kind getKind() {
1041
return Kind.OTHER;
1042
}
1043
}
1044
}
1045
1046