/* * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package jdk.javadoc.internal.doclets.toolkit; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.MissingResourceException; import java.util.Set; import java.util.StringTokenizer; import java.util.TreeSet; import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.Reporter; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; import jdk.javadoc.internal.doclets.toolkit.util.Utils; import static javax.tools.Diagnostic.Kind.ERROR; /** * Storage for the format-independent options supported by the toolkit. * The objects to handle command-line options, and to initialize this * object, are all subtypes of {@link BaseOptions.Option}, * returned by {@link BaseOptions#getSupportedOptions()}. */ public abstract class BaseOptions { // /** * Argument for command-line option {@code --allow-script-in-comments}. * Allow JavaScript in doc comments. */ public boolean allowScriptInComments = false; /** * Argument for command-line option {@code -docfilessubdirs}. * True if we should recursively copy the doc-file subdirectories */ public boolean copyDocfileSubdirs = false; /** * Arguments for command-line option {@code -tag} and {@code -taglet}. */ final LinkedHashSet> customTagStrs = new LinkedHashSet<>(); /** * Argument for command-line option {@code -d}. * Destination directory name, in which doclet will generate the entire * documentation. Default is current directory. */ public String destDirName = ""; /** * Argument for command-line option {@code --disable-javafx-strict-checks}. * Primarily used to disable strict checks in the regression * tests allowing those tests to be executed successfully, for * instance, with OpenJDK builds which may not contain FX libraries. */ public boolean disableJavaFxStrictChecks = false; /** * Argument for command-line option {@code -docencoding}. * Encoding for this document. Default is default encoding for this * platform. */ public String docEncoding = null; /** * Argument for command-line option {@code ???}. * Destination directory name, in which doclet will copy the doc-files to. */ public String docFileDestDirName = ""; /** * Argument for hidden command-line option {@code --dump-on-error}. */ public boolean dumpOnError = false; /** * Argument for command-line option {@code -encoding}. * Encoding for this document. Default is default encoding for this * platform. */ public String encoding = null; /** * Argument for command-line option {@code -excludedocfilessubdir}. * The set of doc-file subdirectories to exclude. */ protected Set excludedDocFileDirs; /** * Argument for command-line option {@code -noqualifier}. * The set of qualifiers to exclude. */ protected Set excludedQualifiers; /** * Arguments for command-line option {@code -group} */ List> groupPairs; /** * Argument for command-line option {@code --javafx} or {@code -javafx}. * Generate documentation for JavaFX getters and setters automatically * by copying it from the appropriate property definition. */ public boolean javafx = false; /** * Argument for command-line option {@code -keywords}. * True if user wants to add member names as meta keywords. * Set to false because meta keywords are ignored in general * by most Internet search engines. */ public boolean keywords = false; /** * Arguments for command-line option {@code -link}. */ // A list containing urls final List linkList = new ArrayList<>(); /** * Arguments for command-line option {@code -linkoffline}. */ // A list of pairs containing urls and package list final List> linkOfflineList = new ArrayList<>(); /** * Argument for command-line option {@code -linksource}. * True if we should generate browsable sources. */ public boolean linkSource = false; /** * Argument for command-line option {@code -nocomment}. * True if user wants to suppress descriptions and tags. */ public boolean noComment = false; /** * Argument for command-line option {@code -nodeprecated}. * Don't generate deprecated API information at all, if -nodeprecated * option is used. nodeprecated is set to true if * -nodeprecated option is used. Default is generate deprecated API * information. */ public boolean noDeprecated = false; /** * Argument for command-line option {@code -nosince}. * True if command-line option "-nosince" is used. Default value is * false. */ public boolean noSince = false; /** * Argument for command-line option {@code -notimestamp}. * True if user wants to suppress time stamp in output. * Default is false. */ public boolean noTimestamp = false; /** * Argument for command-line option {@code -quiet}. * Suppress all messages */ public boolean quiet = false; /** * Argument for command-line option {@code -serialwarn}. * This is true if option "-serialwarn" is used. Default value is false to * suppress excessive warnings about serial tag. */ public boolean serialWarn = false; /** * Argument for command-line option {@code -author}. * Generate author specific information for all the classes if @author * tag is used in the doc comment and if -author option is used. * showauthor is set to true if -author option is used. * Default is don't show author information. */ public boolean showAuthor = false; /** * Argument for command-line option {@code --show-taglets}. * Show taglets (internal debug switch) */ public boolean showTaglets = false; /** * Argument for command-line option {@code -version}. * Generate version specific information for the all the classes * if @version tag is used in the doc comment and if -version option is * used. {@code showVersion} is set to true if -version option is * used. Default is don't show version information. */ public boolean showVersion = false; /** * Argument for command-line option {@code -sourcetab}. * The specified amount of space between tab stops. */ public int sourceTabSize; /** * Value for command-line option {@code --override-methods summary} * or {@code --override-methods detail}. * Specifies whether those methods that override a super-type's method * with no changes to the API contract should be summarized in the * footnote section. */ public boolean summarizeOverriddenMethods = false; /** * Argument for command-line option {@code -tagletpath}. * The path to Taglets */ public String tagletPath = null; // private final BaseConfiguration config; protected BaseOptions(BaseConfiguration config) { this.config = config; excludedDocFileDirs = new HashSet<>(); excludedQualifiers = new HashSet<>(); sourceTabSize = DocletConstants.DEFAULT_TAB_STOP_LENGTH; groupPairs = new ArrayList<>(0); } public Set getSupportedOptions() { Resources resources = config.getResources(); Messages messages = config.getMessages(); Reporter reporter = config.getReporter(); List