src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java

Wed, 31 Oct 2012 13:48:15 -0700

author
jjg
date
Wed, 31 Oct 2012 13:48:15 -0700
changeset 1383
b980e8e6aabf
parent 1376
217c265158fe
child 1410
bfec2a1cc869
permissions
-rw-r--r--

8001664: refactor javadoc to use abstraction to handle files
Reviewed-by: darcy

     1 /*
     2  * Copyright (c) 1997, 2012, 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  */
    26 package com.sun.tools.doclets.internal.toolkit;
    28 import java.io.*;
    29 import java.util.*;
    31 import com.sun.javadoc.*;
    32 import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory;
    33 import com.sun.tools.doclets.internal.toolkit.taglets.*;
    34 import com.sun.tools.doclets.internal.toolkit.util.*;
    36 /**
    37  * Configure the output based on the options. Doclets should sub-class
    38  * Configuration, to configure and add their own options. This class contains
    39  * all user options which are supported by the 1.1 doclet and the standard
    40  * doclet.
    41  *
    42  *  <p><b>This is NOT part of any supported API.
    43  *  If you write code that depends on this, you do so at your own risk.
    44  *  This code and its internal interfaces are subject to change or
    45  *  deletion without notice.</b>
    46  *
    47  * @author Robert Field.
    48  * @author Atul Dambalkar.
    49  * @author Jamie Ho
    50  */
    51 public abstract class Configuration {
    53     /**
    54      * The factory for builders.
    55      */
    56     protected BuilderFactory builderFactory;
    58     /**
    59      * The taglet manager.
    60      */
    61     public TagletManager tagletManager;
    63     /**
    64      * The path to the builder XML input file.
    65      */
    66     public String builderXMLPath;
    68     /**
    69      * The default path to the builder XML.
    70      */
    71     private static final String DEFAULT_BUILDER_XML = "resources/doclet.xml";
    73     /**
    74      * The path to Taglets
    75      */
    76     public String tagletpath = "";
    78     /**
    79      * This is true if option "-serialwarn" is used. Defualt value is false to
    80      * supress excessive warnings about serial tag.
    81      */
    82     public boolean serialwarn = false;
    84     /**
    85      * The specified amount of space between tab stops.
    86      */
    87     public int sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
    89     /**
    90      * True if we should generate browsable sources.
    91      */
    92     public boolean linksource = false;
    94     /**
    95      * True if command line option "-nosince" is used. Default value is
    96      * false.
    97      */
    98     public boolean nosince = false;
   100     /**
   101      * True if we should recursively copy the doc-file subdirectories
   102      */
   103     public boolean copydocfilesubdirs = false;
   105     /**
   106      * The META charset tag used for cross-platform viewing.
   107      */
   108     public String charset = "";
   110     /**
   111      * True if user wants to add member names as meta keywords.
   112      * Set to false because meta keywords are ignored in general
   113      * by most Internet search engines.
   114      */
   115     public boolean keywords = false;
   117     /**
   118      * The meta tag keywords instance.
   119      */
   120     public final MetaKeywords metakeywords = new MetaKeywords(this);
   122     /**
   123      * The list of doc-file subdirectories to exclude
   124      */
   125     protected Set<String> excludedDocFileDirs;
   127     /**
   128      * The list of qualifiers to exclude
   129      */
   130     protected Set<String> excludedQualifiers;
   132     /**
   133      * The Root of the generated Program Structure from the Doclet API.
   134      */
   135     public RootDoc root;
   137     /**
   138      * Destination directory name, in which doclet will generate the entire
   139      * documentation. Default is current directory.
   140      */
   141     public String destDirName = "";
   143     /**
   144      * Destination directory name, in which doclet will copy the doc-files to.
   145      */
   146     public String docFileDestDirName = "";
   148     /**
   149      * Encoding for this document. Default is default encoding for this
   150      * platform.
   151      */
   152     public String docencoding = null;
   154     /**
   155      * True if user wants to suppress descriptions and tags.
   156      */
   157     public boolean nocomment = false;
   159     /**
   160      * Encoding for this document. Default is default encoding for this
   161      * platform.
   162      */
   163     public String encoding = null;
   165     /**
   166      * Generate author specific information for all the classes if @author
   167      * tag is used in the doc comment and if -author option is used.
   168      * <code>showauthor</code> is set to true if -author option is used.
   169      * Default is don't show author information.
   170      */
   171     public boolean showauthor = false;
   173     /**
   174      * Generate version specific information for the all the classes
   175      * if @version tag is used in the doc comment and if -version option is
   176      * used. <code>showversion</code> is set to true if -version option is
   177      * used.Default is don't show version information.
   178      */
   179     public boolean showversion = false;
   181     /**
   182      * Sourcepath from where to read the source files. Default is classpath.
   183      *
   184      */
   185     public String sourcepath = "";
   187     /**
   188      * Don't generate deprecated API information at all, if -nodeprecated
   189      * option is used. <code>nodepracted</code> is set to true if
   190      * -nodeprecated option is used. Default is generate deprected API
   191      * information.
   192      */
   193     public boolean nodeprecated = false;
   195     /**
   196      * The catalog of classes specified on the command-line
   197      */
   198     public ClassDocCatalog classDocCatalog;
   200     /**
   201      * Message Retriever for the doclet, to retrieve message from the resource
   202      * file for this Configuration, which is common for 1.1 and standard
   203      * doclets.
   204      *
   205      * TODO:  Make this private!!!
   206      */
   207     public MessageRetriever message = null;
   209     /**
   210      * True if user wants to suppress time stamp in output.
   211      * Default is false.
   212      */
   213     public boolean notimestamp= false;
   215     /**
   216      * The package grouping instance.
   217      */
   218     public final Group group = new Group(this);
   220     /**
   221      * The tracker of external package links.
   222      */
   223     public final Extern extern = new Extern(this);
   225     /**
   226      * Return the build date for the doclet.
   227      */
   228     public abstract String getDocletSpecificBuildDate();
   230     /**
   231      * This method should be defined in all those doclets(configurations),
   232      * which want to derive themselves from this Configuration. This method
   233      * can be used to set its own command line options.
   234      *
   235      * @param options The array of option names and values.
   236      * @throws DocletAbortException
   237      */
   238     public abstract void setSpecificDocletOptions(String[][] options);
   240     /**
   241      * Return the doclet specific {@link MessageRetriever}
   242      * @return the doclet specific MessageRetriever.
   243      */
   244     public abstract MessageRetriever getDocletSpecificMsg();
   246     /**
   247      * An array of the packages specified on the command-line merged
   248      * with the array of packages that contain the classes specified on the
   249      * command-line.  The array is sorted.
   250      */
   251     public PackageDoc[] packages;
   253     /**
   254      * Constructor. Constructs the message retriever with resource file.
   255      */
   256     public Configuration() {
   257         message =
   258             new MessageRetriever(this,
   259             "com.sun.tools.doclets.internal.toolkit.resources.doclets");
   260         excludedDocFileDirs = new HashSet<String>();
   261         excludedQualifiers = new HashSet<String>();
   262     }
   264     /**
   265      * Return the builder factory for this doclet.
   266      *
   267      * @return the builder factory for this doclet.
   268      */
   269     public BuilderFactory getBuilderFactory() {
   270         if (builderFactory == null) {
   271             builderFactory = new BuilderFactory(this);
   272         }
   273         return builderFactory;
   274     }
   276     /**
   277      * This method should be defined in all those doclets
   278      * which want to inherit from this Configuration. This method
   279      * should return the number of arguments to the command line
   280      * option (including the option name).  For example,
   281      * -notimestamp is a single-argument option, so this method would
   282      * return 1.
   283      *
   284      * @param option Command line option under consideration.
   285      * @return number of arguments to option (including the
   286      * option name). Zero return means option not known.
   287      * Negative value means error occurred.
   288      */
   289     public int optionLength(String option) {
   290         option = option.toLowerCase();
   291         if (option.equals("-author") ||
   292             option.equals("-docfilessubdirs") ||
   293             option.equals("-keywords") ||
   294             option.equals("-linksource") ||
   295             option.equals("-nocomment") ||
   296             option.equals("-nodeprecated") ||
   297             option.equals("-nosince") ||
   298             option.equals("-notimestamp") ||
   299             option.equals("-quiet") ||
   300             option.equals("-xnodate") ||
   301             option.equals("-version")) {
   302             return 1;
   303         } else if (option.equals("-d") ||
   304                    option.equals("-docencoding") ||
   305                    option.equals("-encoding") ||
   306                    option.equals("-excludedocfilessubdir") ||
   307                    option.equals("-link") ||
   308                    option.equals("-sourcetab") ||
   309                    option.equals("-noqualifier") ||
   310                    option.equals("-output") ||
   311                    option.equals("-sourcepath") ||
   312                    option.equals("-tag") ||
   313                    option.equals("-taglet") ||
   314                    option.equals("-tagletpath")) {
   315             return 2;
   316         } else if (option.equals("-group") ||
   317                    option.equals("-linkoffline")) {
   318             return 3;
   319         } else {
   320             return -1;  // indicate we don't know about it
   321         }
   322     }
   324     /**
   325      * Perform error checking on the given options.
   326      *
   327      * @param options  the given options to check.
   328      * @param reporter the reporter used to report errors.
   329      */
   330     public abstract boolean validOptions(String options[][],
   331         DocErrorReporter reporter);
   333     private void initPackageArray() {
   334         Set<PackageDoc> set = new HashSet<PackageDoc>(Arrays.asList(root.specifiedPackages()));
   335         ClassDoc[] classes = root.specifiedClasses();
   336         for (int i = 0; i < classes.length; i++) {
   337             set.add(classes[i].containingPackage());
   338         }
   339         ArrayList<PackageDoc> results = new ArrayList<PackageDoc>(set);
   340         Collections.sort(results);
   341         packages = results.toArray(new PackageDoc[] {});
   342     }
   344     /**
   345      * Set the command line options supported by this configuration.
   346      *
   347      * @param options the two dimensional array of options.
   348      */
   349     public void setOptions(String[][] options) {
   350         LinkedHashSet<String[]> customTagStrs = new LinkedHashSet<String[]>();
   351         for (int oi = 0; oi < options.length; ++oi) {
   352             String[] os = options[oi];
   353             String opt = os[0].toLowerCase();
   354             if (opt.equals("-d")) {
   355                 destDirName = addTrailingFileSep(os[1]);
   356                 docFileDestDirName = destDirName;
   357             } else if (opt.equals("-docfilessubdirs")) {
   358                 copydocfilesubdirs = true;
   359             } else if (opt.equals("-docencoding")) {
   360                 docencoding = os[1];
   361             } else if (opt.equals("-encoding")) {
   362                 encoding = os[1];
   363             } else if (opt.equals("-author")) {
   364                 showauthor = true;
   365             } else if (opt.equals("-nosince")) {
   366                 nosince = true;
   367             } else if (opt.equals("-version")) {
   368                 showversion = true;
   369             } else if (opt.equals("-nodeprecated")) {
   370                 nodeprecated = true;
   371             } else if (opt.equals("-sourcepath")) {
   372                 sourcepath = os[1];
   373             } else if (opt.equals("-classpath") &&
   374                        sourcepath.length() == 0) {
   375                 sourcepath = os[1];
   376             } else if (opt.equals("-excludedocfilessubdir")) {
   377                 addToSet(excludedDocFileDirs, os[1]);
   378             } else if (opt.equals("-noqualifier")) {
   379                 addToSet(excludedQualifiers, os[1]);
   380             } else if (opt.equals("-linksource")) {
   381                 linksource = true;
   382             } else if (opt.equals("-sourcetab")) {
   383                 linksource = true;
   384                 try {
   385                     sourcetab = Integer.parseInt(os[1]);
   386                 } catch (NumberFormatException e) {
   387                     //Set to -1 so that warning will be printed
   388                     //to indicate what is valid argument.
   389                     sourcetab = -1;
   390                 }
   391                 if (sourcetab <= 0) {
   392                     message.warning("doclet.sourcetab_warning");
   393                     sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
   394                 }
   395             } else if (opt.equals("-notimestamp")) {
   396                 notimestamp = true;
   397             } else if (opt.equals("-nocomment")) {
   398                 nocomment = true;
   399             } else if (opt.equals("-tag") || opt.equals("-taglet")) {
   400                 customTagStrs.add(os);
   401             } else if (opt.equals("-tagletpath")) {
   402                 tagletpath = os[1];
   403             } else if (opt.equals("-keywords")) {
   404                 keywords = true;
   405             } else if (opt.equals("-serialwarn")) {
   406                 serialwarn = true;
   407             } else if (opt.equals("-group")) {
   408                 group.checkPackageGroups(os[1], os[2]);
   409             } else if (opt.equals("-link")) {
   410                 String url = os[1];
   411                 extern.link(url, url, root, false);
   412             } else if (opt.equals("-linkoffline")) {
   413                 String url = os[1];
   414                 String pkglisturl = os[2];
   415                 extern.link(url, pkglisturl, root, true);
   416             }
   417         }
   418         if (sourcepath.length() == 0) {
   419             sourcepath = System.getProperty("env.class.path") == null ? "" :
   420                 System.getProperty("env.class.path");
   421         }
   422         if (docencoding == null) {
   423             docencoding = encoding;
   424         }
   426         classDocCatalog = new ClassDocCatalog(root.specifiedClasses(), this);
   427         initTagletManager(customTagStrs);
   428     }
   430     /**
   431      * Set the command line options supported by this configuration.
   432      *
   433      * @throws DocletAbortException
   434      */
   435     public void setOptions() {
   436         initPackageArray();
   437         setOptions(root.options());
   438         setSpecificDocletOptions(root.options());
   439     }
   442     /**
   443      * Initialize the taglet manager.  The strings to initialize the simple custom tags should
   444      * be in the following format:  "[tag name]:[location str]:[heading]".
   445      * @param customTagStrs the set two dimentional arrays of strings.  These arrays contain
   446      * either -tag or -taglet arguments.
   447      */
   448     private void initTagletManager(Set<String[]> customTagStrs) {
   449         tagletManager = tagletManager == null ?
   450             new TagletManager(nosince, showversion, showauthor, message) :
   451             tagletManager;
   452         String[] args;
   453         for (Iterator<String[]> it = customTagStrs.iterator(); it.hasNext(); ) {
   454             args = it.next();
   455             if (args[0].equals("-taglet")) {
   456                 tagletManager.addCustomTag(args[1], tagletpath);
   457                 continue;
   458             }
   459             String[] tokens = tokenize(args[1],
   460                 TagletManager.SIMPLE_TAGLET_OPT_SEPERATOR, 3);
   461             if (tokens.length == 1) {
   462                 String tagName = args[1];
   463                 if (tagletManager.isKnownCustomTag(tagName)) {
   464                     //reorder a standard tag
   465                     tagletManager.addNewSimpleCustomTag(tagName, null, "");
   466                 } else {
   467                     //Create a simple tag with the heading that has the same name as the tag.
   468                     StringBuilder heading = new StringBuilder(tagName + ":");
   469                     heading.setCharAt(0, Character.toUpperCase(tagName.charAt(0)));
   470                     tagletManager.addNewSimpleCustomTag(tagName, heading.toString(), "a");
   471                 }
   472             } else if (tokens.length == 2) {
   473                 //Add simple taglet without heading, probably to excluding it in the output.
   474                 tagletManager.addNewSimpleCustomTag(tokens[0], tokens[1], "");
   475             } else if (tokens.length >= 3) {
   476                 tagletManager.addNewSimpleCustomTag(tokens[0], tokens[2], tokens[1]);
   477             } else {
   478                 message.error("doclet.Error_invalid_custom_tag_argument", args[1]);
   479             }
   480         }
   481     }
   483     /**
   484      * Given a string, return an array of tokens.  The separator can be escaped
   485      * with the '\' character.  The '\' character may also be escaped by the
   486      * '\' character.
   487      *
   488      * @param s         the string to tokenize.
   489      * @param separator the separator char.
   490      * @param maxTokens the maximum number of tokens returned.  If the
   491      *                  max is reached, the remaining part of s is appended
   492      *                  to the end of the last token.
   493      *
   494      * @return an array of tokens.
   495      */
   496     private String[] tokenize(String s, char separator, int maxTokens) {
   497         List<String> tokens = new ArrayList<String>();
   498         StringBuilder  token = new StringBuilder ();
   499         boolean prevIsEscapeChar = false;
   500         for (int i = 0; i < s.length(); i += Character.charCount(i)) {
   501             int currentChar = s.codePointAt(i);
   502             if (prevIsEscapeChar) {
   503                 // Case 1:  escaped character
   504                 token.appendCodePoint(currentChar);
   505                 prevIsEscapeChar = false;
   506             } else if (currentChar == separator && tokens.size() < maxTokens-1) {
   507                 // Case 2:  separator
   508                 tokens.add(token.toString());
   509                 token = new StringBuilder();
   510             } else if (currentChar == '\\') {
   511                 // Case 3:  escape character
   512                 prevIsEscapeChar = true;
   513             } else {
   514                 // Case 4:  regular character
   515                 token.appendCodePoint(currentChar);
   516             }
   517         }
   518         if (token.length() > 0) {
   519             tokens.add(token.toString());
   520         }
   521         return tokens.toArray(new String[] {});
   522     }
   524     private void addToSet(Set<String> s, String str){
   525         StringTokenizer st = new StringTokenizer(str, ":");
   526         String current;
   527         while(st.hasMoreTokens()){
   528             current = st.nextToken();
   529             s.add(current);
   530         }
   531     }
   533     /**
   534      * Add a trailing file separator, if not found. Remove superfluous
   535      * file separators if any. Preserve the front double file separator for
   536      * UNC paths.
   537      *
   538      * @param path Path under consideration.
   539      * @return String Properly constructed path string.
   540      */
   541     public static String addTrailingFileSep(String path) {
   542         String fs = System.getProperty("file.separator");
   543         String dblfs = fs + fs;
   544         int indexDblfs;
   545         while ((indexDblfs = path.indexOf(dblfs, 1)) >= 0) {
   546             path = path.substring(0, indexDblfs) +
   547                 path.substring(indexDblfs + fs.length());
   548         }
   549         if (!path.endsWith(fs))
   550             path += fs;
   551         return path;
   552     }
   554     /**
   555      * This checks for the validity of the options used by the user.
   556      * This works exactly like
   557      * {@link com.sun.javadoc.Doclet#validOptions(String[][],
   558      * DocErrorReporter)}. This will validate the options which are shared
   559      * by our doclets. For example, this method will flag an error using
   560      * the DocErrorReporter if user has used "-nohelp" and "-helpfile" option
   561      * together.
   562      *
   563      * @param options  options used on the command line.
   564      * @param reporter used to report errors.
   565      * @return true if all the options are valid.
   566      */
   567     public boolean generalValidOptions(String options[][],
   568             DocErrorReporter reporter) {
   569         boolean docencodingfound = false;
   570         String encoding = "";
   571         for (int oi = 0; oi < options.length; oi++) {
   572             String[] os = options[oi];
   573             String opt = os[0].toLowerCase();
   574             if (opt.equals("-d")) {
   575                 String destdirname = addTrailingFileSep(os[1]);
   576                 DocFile destDir = DocFile.createFileForDirectory(this, destdirname);
   577                 if (!destDir.exists()) {
   578                     //Create the output directory (in case it doesn't exist yet)
   579                     reporter.printNotice(getText("doclet.dest_dir_create",
   580                         destdirname));
   581                     destDir.mkdirs();
   582                 } else if (!destDir.isDirectory()) {
   583                     reporter.printError(getText(
   584                         "doclet.destination_directory_not_directory_0",
   585                         destDir.getPath()));
   586                     return false;
   587                 } else if (!destDir.canWrite()) {
   588                     reporter.printError(getText(
   589                         "doclet.destination_directory_not_writable_0",
   590                         destDir.getPath()));
   591                     return false;
   592                 }
   593             } else if (opt.equals("-docencoding")) {
   594                 docencodingfound = true;
   595                 if (!checkOutputFileEncoding(os[1], reporter)) {
   596                     return false;
   597                 }
   598             } else if (opt.equals("-encoding")) {
   599                 encoding = os[1];
   600             }
   601         }
   602         if (!docencodingfound && encoding.length() > 0) {
   603             if (!checkOutputFileEncoding(encoding, reporter)) {
   604                 return false;
   605             }
   606         }
   607         return true;
   608     }
   610     /**
   611      * Check the validity of the given Source or Output File encoding on this
   612      * platform.
   613      *
   614      * @param docencoding output file encoding.
   615      * @param reporter    used to report errors.
   616      */
   617     private boolean checkOutputFileEncoding(String docencoding,
   618             DocErrorReporter reporter) {
   619         OutputStream ost= new ByteArrayOutputStream();
   620         OutputStreamWriter osw = null;
   621         try {
   622             osw = new OutputStreamWriter(ost, docencoding);
   623         } catch (UnsupportedEncodingException exc) {
   624             reporter.printError(getText("doclet.Encoding_not_supported",
   625                 docencoding));
   626             return false;
   627         } finally {
   628             try {
   629                 if (osw != null) {
   630                     osw.close();
   631                 }
   632             } catch (IOException exc) {
   633             }
   634         }
   635         return true;
   636     }
   638     /**
   639      * Return true if the given doc-file subdirectory should be excluded and
   640      * false otherwise.
   641      * @param docfilesubdir the doc-files subdirectory to check.
   642      */
   643     public boolean shouldExcludeDocFileDir(String docfilesubdir){
   644         if (excludedDocFileDirs.contains(docfilesubdir)) {
   645             return true;
   646         } else {
   647             return false;
   648         }
   649     }
   651     /**
   652      * Return true if the given qualifier should be excluded and false otherwise.
   653      * @param qualifier the qualifier to check.
   654      */
   655     public boolean shouldExcludeQualifier(String qualifier){
   656         if (excludedQualifiers.contains("all") ||
   657             excludedQualifiers.contains(qualifier) ||
   658             excludedQualifiers.contains(qualifier + ".*")) {
   659             return true;
   660         } else {
   661             int index = -1;
   662             while ((index = qualifier.indexOf(".", index + 1)) != -1) {
   663                 if (excludedQualifiers.contains(qualifier.substring(0, index + 1) + "*")) {
   664                     return true;
   665                 }
   666             }
   667             return false;
   668         }
   669     }
   671     /**
   672      * Return the qualified name of the <code>ClassDoc</code> if it's qualifier is not excluded.  Otherwise,
   673      * return the unqualified <code>ClassDoc</code> name.
   674      * @param cd the <code>ClassDoc</code> to check.
   675      */
   676     public String getClassName(ClassDoc cd) {
   677         PackageDoc pd = cd.containingPackage();
   678         if (pd != null && shouldExcludeQualifier(cd.containingPackage().name())) {
   679             return cd.name();
   680         } else {
   681             return cd.qualifiedName();
   682         }
   683     }
   685     public String getText(String key) {
   686         try {
   687             //Check the doclet specific properties file.
   688             return getDocletSpecificMsg().getText(key);
   689         } catch (Exception e) {
   690             //Check the shared properties file.
   691             return message.getText(key);
   692         }
   693     }
   695     public String getText(String key, String a1) {
   696         try {
   697             //Check the doclet specific properties file.
   698             return getDocletSpecificMsg().getText(key, a1);
   699         } catch (Exception e) {
   700             //Check the shared properties file.
   701             return message.getText(key, a1);
   702         }
   703     }
   705     public String getText(String key, String a1, String a2) {
   706         try {
   707             //Check the doclet specific properties file.
   708             return getDocletSpecificMsg().getText(key, a1, a2);
   709         } catch (Exception e) {
   710             //Check the shared properties file.
   711             return message.getText(key, a1, a2);
   712         }
   713     }
   715     public String getText(String key, String a1, String a2, String a3) {
   716         try {
   717             //Check the doclet specific properties file.
   718             return getDocletSpecificMsg().getText(key, a1, a2, a3);
   719         } catch (Exception e) {
   720             //Check the shared properties file.
   721             return message.getText(key, a1, a2, a3);
   722         }
   723     }
   725     /**
   726      * Return true if the ClassDoc element is getting documented, depending upon
   727      * -nodeprecated option and the deprecation information. Return true if
   728      * -nodeprecated is not used. Return false if -nodeprecated is used and if
   729      * either ClassDoc element is deprecated or the containing package is deprecated.
   730      *
   731      * @param cd the ClassDoc for which the page generation is checked
   732      */
   733     public boolean isGeneratedDoc(ClassDoc cd) {
   734         if (!nodeprecated) {
   735             return true;
   736         }
   737         return !(Util.isDeprecated(cd) || Util.isDeprecated(cd.containingPackage()));
   738     }
   740     /**
   741      * Return the doclet specific instance of a writer factory.
   742      * @return the {@link WriterFactory} for the doclet.
   743      */
   744     public abstract WriterFactory getWriterFactory();
   746     /**
   747      * Return the input stream to the builder XML.
   748      *
   749      * @return the input steam to the builder XML.
   750      * @throws FileNotFoundException when the given XML file cannot be found.
   751      */
   752     public InputStream getBuilderXML() throws FileNotFoundException {
   753         return builderXMLPath == null ?
   754             Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) :
   755             DocFile.createFileForInput(this, builderXMLPath).openInputStream();
   756     }
   758     /**
   759      * Return the Locale for this document.
   760      */
   761     public abstract Locale getLocale();
   763     /**
   764      * Return the comparator that will be used to sort member documentation.
   765      * To no do any sorting, return null.
   766      *
   767      * @return the {@link java.util.Comparator} used to sort members.
   768      */
   769     public abstract Comparator<ProgramElementDoc> getMemberComparator();
   770 }

mercurial