src/share/classes/com/sun/tools/doclets/formats/html/AbstractProfileIndexWriter.java

Tue, 24 Dec 2013 09:17:37 -0800

author
ksrini
date
Tue, 24 Dec 2013 09:17:37 -0800
changeset 2227
998b10c43157
parent 0
959103a6100f
permissions
-rw-r--r--

8029230: Update copyright year to match last edit in jdk8 langtools repository for 2013
Reviewed-by: ksrini
Contributed-by: steve.sides@oracle.com

     1 /*
     2  * Copyright (c) 2013, 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.formats.html;
    28 import java.io.*;
    30 import com.sun.tools.javac.sym.Profiles;
    31 import com.sun.tools.doclets.formats.html.markup.*;
    32 import com.sun.tools.doclets.internal.toolkit.*;
    33 import com.sun.tools.doclets.internal.toolkit.util.DocPath;
    35 /**
    36  * Abstract class to generate the profile overview files in
    37  * Frame and Non-Frame format. This will be sub-classed to
    38  * generate profile-overview-frame.html as well as profile-overview-summary.html.
    39  *
    40  *  <p><b>This is NOT part of any supported API.
    41  *  If you write code that depends on this, you do so at your own risk.
    42  *  This code and its internal interfaces are subject to change or
    43  *  deletion without notice.</b>
    44  *
    45  * @author Bhavesh Patel
    46  */
    47 public abstract class AbstractProfileIndexWriter extends HtmlDocletWriter {
    49     /**
    50      * Profiles to be documented.
    51      */
    52     protected Profiles profiles;
    54     /**
    55      * Constructor. Also initializes the profiles variable.
    56      *
    57      * @param configuration  The current configuration
    58      * @param filename Name of the profile index file to be generated.
    59      */
    60     public AbstractProfileIndexWriter(ConfigurationImpl configuration,
    61                                       DocPath filename) throws IOException {
    62         super(configuration, filename);
    63         profiles = configuration.profiles;
    64     }
    66     /**
    67      * Adds the navigation bar header to the documentation tree.
    68      *
    69      * @param body the document tree to which the navigation bar header will be added
    70      */
    71     protected abstract void addNavigationBarHeader(Content body);
    73     /**
    74      * Adds the navigation bar footer to the documentation tree.
    75      *
    76      * @param body the document tree to which the navigation bar footer will be added
    77      */
    78     protected abstract void addNavigationBarFooter(Content body);
    80     /**
    81      * Adds the overview header to the documentation tree.
    82      *
    83      * @param body the document tree to which the overview header will be added
    84      */
    85     protected abstract void addOverviewHeader(Content body);
    87     /**
    88      * Adds the profiles list to the documentation tree.
    89      *
    90      * @param profiles profiles object
    91      * @param text caption for the table
    92      * @param tableSummary summary for the table
    93      * @param body the document tree to which the profiles list will be added
    94      */
    95     protected abstract void addProfilesList(Profiles profiles, String text,
    96             String tableSummary, Content body);
    98     /**
    99      * Adds the profile packages list to the documentation tree.
   100      *
   101      * @param profiles profiles object
   102      * @param text caption for the table
   103      * @param tableSummary summary for the table
   104      * @param body the document tree to which the profiles list will be added
   105      * @param profileName the name for the profile being documented
   106      */
   107     protected abstract void addProfilePackagesList(Profiles profiles, String text,
   108             String tableSummary, Content body, String profileName);
   110     /**
   111      * Generate and prints the contents in the profile index file. Call appropriate
   112      * methods from the sub-class in order to generate Frame or Non
   113      * Frame format.
   114      *
   115      * @param title the title of the window.
   116      * @param includeScript boolean set true if windowtitle script is to be included
   117      */
   118     protected void buildProfileIndexFile(String title, boolean includeScript) throws IOException {
   119         String windowOverview = configuration.getText(title);
   120         Content body = getBody(includeScript, getWindowTitle(windowOverview));
   121         addNavigationBarHeader(body);
   122         addOverviewHeader(body);
   123         addIndex(body);
   124         addOverview(body);
   125         addNavigationBarFooter(body);
   126         printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
   127                 configuration.doctitle), includeScript, body);
   128     }
   130     /**
   131      * Generate and prints the contents in the profile packages index file. Call appropriate
   132      * methods from the sub-class in order to generate Frame or Non
   133      * Frame format.
   134      *
   135      * @param title the title of the window.
   136      * @param includeScript boolean set true if windowtitle script is to be included
   137      * @param profileName the name of the profile being documented
   138      */
   139     protected void buildProfilePackagesIndexFile(String title,
   140             boolean includeScript, String profileName) throws IOException {
   141         String windowOverview = configuration.getText(title);
   142         Content body = getBody(includeScript, getWindowTitle(windowOverview));
   143         addNavigationBarHeader(body);
   144         addOverviewHeader(body);
   145         addProfilePackagesIndex(body, profileName);
   146         addOverview(body);
   147         addNavigationBarFooter(body);
   148         printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
   149                 configuration.doctitle), includeScript, body);
   150     }
   152     /**
   153      * Default to no overview, override to add overview.
   154      *
   155      * @param body the document tree to which the overview will be added
   156      */
   157     protected void addOverview(Content body) throws IOException {
   158     }
   160     /**
   161      * Adds the frame or non-frame profile index to the documentation tree.
   162      *
   163      * @param body the document tree to which the index will be added
   164      */
   165     protected void addIndex(Content body) {
   166         addIndexContents(profiles, "doclet.Profile_Summary",
   167                 configuration.getText("doclet.Member_Table_Summary",
   168                 configuration.getText("doclet.Profile_Summary"),
   169                 configuration.getText("doclet.profiles")), body);
   170     }
   172     /**
   173      * Adds the frame or non-frame profile packages index to the documentation tree.
   174      *
   175      * @param body the document tree to which the index will be added
   176      * @param profileName  the name of the profile being documented
   177      */
   178     protected void addProfilePackagesIndex(Content body, String profileName) {
   179         addProfilePackagesIndexContents(profiles, "doclet.Profile_Summary",
   180                 configuration.getText("doclet.Member_Table_Summary",
   181                 configuration.getText("doclet.Profile_Summary"),
   182                 configuration.getText("doclet.profiles")), body, profileName);
   183     }
   185     /**
   186      * Adds profile index contents. Call appropriate methods from
   187      * the sub-classes. Adds it to the body HtmlTree
   188      *
   189      * @param profiles profiles to be documented
   190      * @param text string which will be used as the heading
   191      * @param tableSummary summary for the table
   192      * @param body the document tree to which the index contents will be added
   193      */
   194     protected void addIndexContents(Profiles profiles, String text,
   195             String tableSummary, Content body) {
   196         if (profiles.getProfileCount() > 0) {
   197             HtmlTree div = new HtmlTree(HtmlTag.DIV);
   198             div.addStyle(HtmlStyle.indexHeader);
   199             addAllClassesLink(div);
   200             addAllPackagesLink(div);
   201             body.addContent(div);
   202             addProfilesList(profiles, text, tableSummary, body);
   203         }
   204     }
   206     /**
   207      * Adds profile packages index contents. Call appropriate methods from
   208      * the sub-classes. Adds it to the body HtmlTree
   209      *
   210      * @param profiles profiles to be documented
   211      * @param text string which will be used as the heading
   212      * @param tableSummary summary for the table
   213      * @param body the document tree to which the index contents will be added
   214      * @param profileName the name of the profile being documented
   215      */
   216     protected void addProfilePackagesIndexContents(Profiles profiles, String text,
   217             String tableSummary, Content body, String profileName) {
   218         HtmlTree div = new HtmlTree(HtmlTag.DIV);
   219         div.addStyle(HtmlStyle.indexHeader);
   220         addAllClassesLink(div);
   221         addAllPackagesLink(div);
   222         addAllProfilesLink(div);
   223         body.addContent(div);
   224         addProfilePackagesList(profiles, text, tableSummary, body, profileName);
   225     }
   227     /**
   228      * Adds the doctitle to the documentation tree, if it is specified on the command line.
   229      *
   230      * @param body the document tree to which the title will be added
   231      */
   232     protected void addConfigurationTitle(Content body) {
   233         if (configuration.doctitle.length() > 0) {
   234             Content title = new RawHtml(configuration.doctitle);
   235             Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
   236                     HtmlStyle.title, title);
   237             Content div = HtmlTree.DIV(HtmlStyle.header, heading);
   238             body.addContent(div);
   239         }
   240     }
   242     /**
   243      * Returns highlighted "Overview", in the navigation bar as this is the
   244      * overview page.
   245      *
   246      * @return a Content object to be added to the documentation tree
   247      */
   248     protected Content getNavLinkContents() {
   249         Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
   250         return li;
   251     }
   253     /**
   254      * Do nothing. This will be overridden in ProfileIndexFrameWriter.
   255      *
   256      * @param div the document tree to which the all classes link will be added
   257      */
   258     protected void addAllClassesLink(Content div) {
   259     }
   261     /**
   262      * Do nothing. This will be overridden in ProfileIndexFrameWriter.
   263      *
   264      * @param div the document tree to which the all packages link will be added
   265      */
   266     protected void addAllPackagesLink(Content div) {
   267     }
   269     /**
   270      * Do nothing. This will be overridden in ProfilePackageIndexFrameWriter.
   271      *
   272      * @param div the document tree to which the all profiles link will be added
   273      */
   274     protected void addAllProfilesLink(Content div) {
   275     }
   276 }

mercurial