src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java
changeset 47849 0e38db7cf1cc
parent 47748 dfc709c80775
child 47850 4a28dc8a86c2
equal deleted inserted replaced
47848:6b1311fbbaba 47849:0e38db7cf1cc
    25 
    25 
    26 package jdk.javadoc.internal.doclets.formats.html;
    26 package jdk.javadoc.internal.doclets.formats.html;
    27 
    27 
    28 import java.net.*;
    28 import java.net.*;
    29 import java.util.*;
    29 import java.util.*;
       
    30 import java.util.stream.Collectors;
    30 
    31 
    31 import javax.lang.model.element.Element;
    32 import javax.lang.model.element.Element;
    32 import javax.lang.model.element.PackageElement;
    33 import javax.lang.model.element.PackageElement;
    33 import javax.lang.model.element.TypeElement;
    34 import javax.lang.model.element.TypeElement;
    34 import javax.tools.JavaFileManager;
    35 import javax.tools.JavaFileManager;
    80  * @author Bhavesh Patel (Modified)
    81  * @author Bhavesh Patel (Modified)
    81  */
    82  */
    82 public class HtmlConfiguration extends BaseConfiguration {
    83 public class HtmlConfiguration extends BaseConfiguration {
    83 
    84 
    84     /**
    85     /**
    85      * The build date.  Note: For now, we will use
       
    86      * a version number instead of a date.
       
    87      */
       
    88     public static final String BUILD_DATE = System.getProperty("java.version");
       
    89 
       
    90     /**
       
    91      * Argument for command line option "-header".
    86      * Argument for command line option "-header".
    92      */
    87      */
    93     public String header = "";
    88     public String header = "";
    94 
    89 
    95     /**
    90     /**
   247     protected Contents contents;
   242     protected Contents contents;
   248 
   243 
   249     protected Messages messages;
   244     protected Messages messages;
   250 
   245 
   251     /**
   246     /**
   252      * Constructor. Initializes resource for the
   247      * Creates an object to hold the configuration for a doclet.
   253      * {@link jdk.javadoc.internal.tool.Messager Messager}.
   248      *
       
   249      * @param doclet the doclet
   254      */
   250      */
   255     public HtmlConfiguration(Doclet doclet) {
   251     public HtmlConfiguration(Doclet doclet) {
   256         super(doclet);
   252         super(doclet);
   257         resources = new Resources(this,
   253         resources = new Resources(this,
   258                 BaseConfiguration.sharedResourceBundleName,
   254                 BaseConfiguration.sharedResourceBundleName,
   259                 "jdk.javadoc.internal.doclets.formats.html.resources.standard");
   255                 "jdk.javadoc.internal.doclets.formats.html.resources.standard");
   260 
   256 
   261         messages = new Messages(this);
   257         messages = new Messages(this);
   262         contents = new Contents(this);
   258         contents = new Contents(this);
   263     }
   259 
   264 
   260         String v;
   265     private final String versionRBName = "jdk.javadoc.internal.tool.resources.version";
   261         try {
   266     private ResourceBundle versionRB;
   262             ResourceBundle rb = ResourceBundle.getBundle(versionBundleName, getLocale());
   267 
       
   268     /**
       
   269      * Return the build date for the doclet.
       
   270      * @return the build date
       
   271      */
       
   272     @Override
       
   273     public String getDocletSpecificBuildDate() {
       
   274         if (versionRB == null) {
       
   275             try {
   263             try {
   276                 versionRB = ResourceBundle.getBundle(versionRBName, getLocale());
   264                 v = rb.getString("release");
   277             } catch (MissingResourceException e) {
   265             } catch (MissingResourceException e) {
   278                 return BUILD_DATE;
   266                 v = defaultDocletVersion;
   279             }
   267             }
   280         }
       
   281 
       
   282         try {
       
   283             return versionRB.getString("release");
       
   284         } catch (MissingResourceException e) {
   268         } catch (MissingResourceException e) {
   285             return BUILD_DATE;
   269             v = defaultDocletVersion;
   286         }
   270         }
       
   271         docletVersion = v;
       
   272     }
       
   273 
       
   274     private static final String versionBundleName = "jdk.javadoc.internal.tool.resources.version";
       
   275     private static final String defaultDocletVersion = System.getProperty("java.version");
       
   276     public final String docletVersion;
       
   277 
       
   278     @Override
       
   279     public String getDocletVersion() {
       
   280         return docletVersion;
   287     }
   281     }
   288 
   282 
   289     @Override
   283     @Override
   290     public Resources getResources() {
   284     public Resources getResources() {
   291         return resources;
   285         return resources;
   478             return fm.getJavaFileObjects(overviewpath).iterator().next();
   472             return fm.getJavaFileObjects(overviewpath).iterator().next();
   479         }
   473         }
   480         return null;
   474         return null;
   481     }
   475     }
   482 
   476 
       
   477     public DocFile getMainStylesheet() {
       
   478         return stylesheetfile.isEmpty() ? null : DocFile.createFileForInput(this, stylesheetfile);
       
   479     }
       
   480 
       
   481     public List<DocFile> getAdditionalStylesheets() {
       
   482         return additionalStylesheets.stream()
       
   483                 .map(ssf -> DocFile.createFileForInput(this, ssf))
       
   484                 .collect(Collectors.toList());
       
   485     }
       
   486 
   483     /**
   487     /**
   484      * {@inheritDoc}
   488      * {@inheritDoc}
   485      */
   489      */
   486     @Override
   490     @Override
   487     public JavaFileManager getFileManager() {
   491     public JavaFileManager getFileManager() {