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

Mon, 13 Dec 2010 13:44:47 -0800

author
bpatel
date
Mon, 13 Dec 2010 13:44:47 -0800
changeset 793
ffbf2b2a8611
parent 766
90af8d87741f
child 798
4868a36f6fd8
permissions
-rw-r--r--

7006270: Several javadoc regression tests are failing on windows
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 1997, 2004, 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.*;
    29 import com.sun.javadoc.*;
    30 import com.sun.tools.doclets.internal.toolkit.*;
    31 import com.sun.tools.doclets.internal.toolkit.util.*;
    32 import com.sun.tools.doclets.formats.html.markup.*;
    34 /**
    35  * This abstract class exists to provide functionality needed in the
    36  * the formatting of member information.  Since AbstractSubWriter and its
    37  * subclasses control this, they would be the logical place to put this.
    38  * However, because each member type has its own subclass, subclassing
    39  * can not be used effectively to change formatting.  The concrete
    40  * class subclass of this class can be subclassed to change formatting.
    41  *
    42  * @see AbstractMemberWriter
    43  * @see ClassWriterImpl
    44  *
    45  * @author Robert Field
    46  * @author Atul M Dambalkar
    47  * @author Bhavesh Patel (Modified)
    48  */
    49 public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
    51     public SubWriterHolderWriter(ConfigurationImpl configuration,
    52                                  String filename) throws IOException {
    53         super(configuration, filename);
    54     }
    57     public SubWriterHolderWriter(ConfigurationImpl configuration,
    58                                  String path, String filename, String relpath)
    59                                  throws IOException {
    60         super(configuration, path, filename, relpath);
    61     }
    63     public void printTypeSummaryHeader() {
    64         tdIndex();
    65         font("-1");
    66         code();
    67     }
    69     public void printTypeSummaryFooter() {
    70         codeEnd();
    71         fontEnd();
    72         tdEnd();
    73     }
    75     /**
    76      * Add the summary header.
    77      *
    78      * @param mw the writer for the member being documented
    79      * @param cd the classdoc to be documented
    80      * @param memberTree the content tree to which the summary header will be added
    81      */
    82     public void addSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
    83             Content memberTree) {
    84         mw.addSummaryAnchor(cd, memberTree);
    85         mw.addSummaryLabel(memberTree);
    86     }
    88     /**
    89      * Get the summary table.
    90      *
    91      * @param mw the writer for the member being documented
    92      * @param cd the classdoc to be documented
    93      * @return the content tree for the summary table
    94      */
    95     public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) {
    96         Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0,
    97                 mw.getTableSummary(), getTableCaption(mw.getCaption()));
    98         table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col"));
    99         return table;
   100     }
   102     public void printTableHeadingBackground(String str) {
   103         tableIndexDetail();
   104         tableHeaderStart("#CCCCFF", 1);
   105         strong(str);
   106         tableHeaderEnd();
   107         tableEnd();
   108     }
   110     /**
   111      * Add the inherited summary header.
   112      *
   113      * @param mw the writer for the member being documented
   114      * @param cd the classdoc to be documented
   115      * @param inheritedTree the content tree to which the inherited summary header will be added
   116      */
   117     public void addInheritedSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
   118             Content inheritedTree) {
   119         mw.addInheritedSummaryAnchor(cd, inheritedTree);
   120         mw.addInheritedSummaryLabel(cd, inheritedTree);
   121     }
   123     public void printSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) {
   124         tableEnd();
   125         space();
   126     }
   128     public void printInheritedSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) {
   129         codeEnd();
   130         summaryRowEnd();
   131         trEnd();
   132         tableEnd();
   133         space();
   134     }
   136     /**
   137      * Add the index comment.
   138      *
   139      * @param member the member being documented
   140      * @param contentTree the content tree to which the comment will be added
   141      */
   142     protected void addIndexComment(Doc member, Content contentTree) {
   143         addIndexComment(member, member.firstSentenceTags(), contentTree);
   144     }
   146     protected void printIndexComment(Doc member, Tag[] firstSentenceTags) {
   147         Tag[] deprs = member.tags("deprecated");
   148         if (Util.isDeprecated((ProgramElementDoc) member)) {
   149             strongText("doclet.Deprecated");
   150             space();
   151             if (deprs.length > 0) {
   152                 printInlineDeprecatedComment(member, deprs[0]);
   153             }
   154             return;
   155         } else {
   156             ClassDoc cd = ((ProgramElementDoc)member).containingClass();
   157             if (cd != null && Util.isDeprecated(cd)) {
   158                 strongText("doclet.Deprecated"); space();
   159             }
   160         }
   161         printSummaryComment(member, firstSentenceTags);
   162     }
   164     /**
   165      * Add the index comment.
   166      *
   167      * @param member the member being documented
   168      * @param firstSentenceTags the first sentence tags for the member to be documented
   169      * @param tdSummary the content tree to which the comment will be added
   170      */
   171     protected void addIndexComment(Doc member, Tag[] firstSentenceTags,
   172             Content tdSummary) {
   173         Tag[] deprs = member.tags("deprecated");
   174         Content div;
   175         if (Util.isDeprecated((ProgramElementDoc) member)) {
   176             Content strong = HtmlTree.STRONG(deprecatedPhrase);
   177             div = HtmlTree.DIV(HtmlStyle.block, strong);
   178             div.addContent(getSpace());
   179             if (deprs.length > 0) {
   180                 addInlineDeprecatedComment(member, deprs[0], div);
   181             }
   182             tdSummary.addContent(div);
   183             return;
   184         } else {
   185             ClassDoc cd = ((ProgramElementDoc)member).containingClass();
   186             if (cd != null && Util.isDeprecated(cd)) {
   187                 Content strong = HtmlTree.STRONG(deprecatedPhrase);
   188                 div = HtmlTree.DIV(HtmlStyle.block, strong);
   189                 div.addContent(getSpace());
   190                 tdSummary.addContent(div);
   191             }
   192         }
   193         addSummaryComment(member, firstSentenceTags, tdSummary);
   194     }
   196     /**
   197      * Add the summary type for the member.
   198      *
   199      * @param mw the writer for the member being documented
   200      * @param member the member to be documented
   201      * @param tdSummaryType the content tree to which the type will be added
   202      */
   203     public void addSummaryType(AbstractMemberWriter mw, ProgramElementDoc member,
   204             Content tdSummaryType) {
   205         mw.addSummaryType(member, tdSummaryType);
   206     }
   208     /**
   209      * Add the summary link for the member.
   210      *
   211      * @param mw the writer for the member being documented
   212      * @param member the member to be documented
   213      * @param contentTree the content tree to which the link will be added
   214      */
   215     public void addSummaryLinkComment(AbstractMemberWriter mw,
   216             ProgramElementDoc member, Content contentTree) {
   217         addSummaryLinkComment(mw, member, member.firstSentenceTags(), contentTree);
   218     }
   220     public void printSummaryLinkComment(AbstractMemberWriter mw,
   221                                         ProgramElementDoc member,
   222                                         Tag[] firstSentenceTags) {
   223         codeEnd();
   224         println();
   225         br();
   226         printNbsps();
   227         printIndexComment(member, firstSentenceTags);
   228         summaryRowEnd();
   229         trEnd();
   230     }
   232     /**
   233      * Add the summary link comment.
   234      *
   235      * @param mw the writer for the member being documented
   236      * @param member the member being documented
   237      * @param firstSentenceTags the first sentence tags for the member to be documented
   238      * @param tdSummary the content tree to which the comment will be added
   239      */
   240     public void addSummaryLinkComment(AbstractMemberWriter mw,
   241             ProgramElementDoc member, Tag[] firstSentenceTags, Content tdSummary) {
   242         addIndexComment(member, firstSentenceTags, tdSummary);
   243     }
   245     /**
   246      * Add the inherited member summary.
   247      *
   248      * @param mw the writer for the member being documented
   249      * @param cd the class being documented
   250      * @param member the member being documented
   251      * @param isFirst true if its the first link being documented
   252      * @param linksTree the content tree to which the summary will be added
   253      */
   254     public void addInheritedMemberSummary(AbstractMemberWriter mw, ClassDoc cd,
   255             ProgramElementDoc member, boolean isFirst, Content linksTree) {
   256         if (! isFirst) {
   257             linksTree.addContent(", ");
   258         }
   259         mw.addInheritedSummaryLink(cd, member, linksTree);
   260     }
   262     public void printMemberHeader() {
   263         hr();
   264     }
   266     public void printMemberFooter() {
   267     }
   269     /**
   270      * Get the document content header tree
   271      *
   272      * @return a content tree the document content header
   273      */
   274     public Content getContentHeader() {
   275         HtmlTree div = new HtmlTree(HtmlTag.DIV);
   276         div.addStyle(HtmlStyle.contentContainer);
   277         return div;
   278     }
   280     /**
   281      * Get the member header tree
   282      *
   283      * @return a content tree the member header
   284      */
   285     public Content getMemberTreeHeader() {
   286         HtmlTree li = new HtmlTree(HtmlTag.LI);
   287         li.addStyle(HtmlStyle.blockList);
   288         return li;
   289     }
   291     /**
   292      * Get the member tree
   293      *
   294      * @param contentTree the tree used to generate the complete member tree
   295      * @return a content tree for the member
   296      */
   297     public Content getMemberTree(Content contentTree) {
   298         Content ul = HtmlTree.UL(HtmlStyle.blockList, contentTree);
   299         return ul;
   300     }
   302     /**
   303      * Get the member summary tree
   304      *
   305      * @param contentTree the tree used to generate the member summary tree
   306      * @return a content tree for the member summary
   307      */
   308     public Content getMemberSummaryTree(Content contentTree) {
   309         return getMemberTree(HtmlStyle.summary, contentTree);
   310     }
   312     /**
   313      * Get the member details tree
   314      *
   315      * @param contentTree the tree used to generate the member details tree
   316      * @return a content tree for the member details
   317      */
   318     public Content getMemberDetailsTree(Content contentTree) {
   319         return getMemberTree(HtmlStyle.details, contentTree);
   320     }
   322     /**
   323      * Get the member tree
   324      *
   325      * @param style the style class to be added to the content tree
   326      * @param contentTree the tree used to generate the complete member tree
   327      */
   328     public Content getMemberTree(HtmlStyle style, Content contentTree) {
   329         Content div = HtmlTree.DIV(style, getMemberTree(contentTree));
   330         return div;
   331     }
   332 }

mercurial