Sun, 11 Apr 2010 23:24:24 -0700
6875904: Java 7 message synchronization 1
Reviewed-by: ogino, faryad
duke@1 | 1 | /* |
duke@1 | 2 | * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. Sun designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
duke@1 | 9 | * by Sun in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
duke@1 | 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | * have any questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.doclets.formats.html; |
duke@1 | 27 | |
bpatel@233 | 28 | import java.io.*; |
bpatel@233 | 29 | |
bpatel@233 | 30 | import com.sun.javadoc.*; |
duke@1 | 31 | import com.sun.tools.doclets.internal.toolkit.util.*; |
bpatel@233 | 32 | |
duke@1 | 33 | /** |
duke@1 | 34 | * Generate Class Hierarchy page for all the Classes in this run. Use |
duke@1 | 35 | * ClassTree for building the Tree. The name of |
duke@1 | 36 | * the generated file is "overview-tree.html" and it is generated in the |
duke@1 | 37 | * current or the destination directory. |
duke@1 | 38 | * |
duke@1 | 39 | * @author Atul M Dambalkar |
duke@1 | 40 | */ |
duke@1 | 41 | public class TreeWriter extends AbstractTreeWriter { |
duke@1 | 42 | |
duke@1 | 43 | /** |
duke@1 | 44 | * Packages in this run. |
duke@1 | 45 | */ |
duke@1 | 46 | private PackageDoc[] packages; |
duke@1 | 47 | |
duke@1 | 48 | /** |
duke@1 | 49 | * True if there are no packages specified on the command line, |
duke@1 | 50 | * False otherwise. |
duke@1 | 51 | */ |
duke@1 | 52 | private boolean classesonly; |
duke@1 | 53 | |
duke@1 | 54 | /** |
duke@1 | 55 | * Constructor to construct TreeWriter object. |
duke@1 | 56 | * |
duke@1 | 57 | * @param configuration the current configuration of the doclet. |
duke@1 | 58 | * @param filename String filename |
duke@1 | 59 | * @param classtree the tree being built. |
duke@1 | 60 | */ |
duke@1 | 61 | public TreeWriter(ConfigurationImpl configuration, |
duke@1 | 62 | String filename, ClassTree classtree) |
duke@1 | 63 | throws IOException { |
duke@1 | 64 | super(configuration, filename, classtree); |
duke@1 | 65 | packages = configuration.packages; |
duke@1 | 66 | classesonly = packages.length == 0; |
duke@1 | 67 | } |
duke@1 | 68 | |
duke@1 | 69 | /** |
duke@1 | 70 | * Create a TreeWriter object and use it to generate the |
duke@1 | 71 | * "overview-tree.html" file. |
duke@1 | 72 | * |
duke@1 | 73 | * @param classtree the class tree being documented. |
duke@1 | 74 | * @throws DocletAbortException |
duke@1 | 75 | */ |
duke@1 | 76 | public static void generate(ConfigurationImpl configuration, |
duke@1 | 77 | ClassTree classtree) { |
duke@1 | 78 | TreeWriter treegen; |
duke@1 | 79 | String filename = "overview-tree.html"; |
duke@1 | 80 | try { |
duke@1 | 81 | treegen = new TreeWriter(configuration, filename, classtree); |
duke@1 | 82 | treegen.generateTreeFile(); |
duke@1 | 83 | treegen.close(); |
duke@1 | 84 | } catch (IOException exc) { |
duke@1 | 85 | configuration.standardmessage.error( |
duke@1 | 86 | "doclet.exception_encountered", |
duke@1 | 87 | exc.toString(), filename); |
duke@1 | 88 | throw new DocletAbortException(); |
duke@1 | 89 | } |
duke@1 | 90 | } |
duke@1 | 91 | |
duke@1 | 92 | /** |
duke@1 | 93 | * Print the interface hierarchy and class hierarchy in the file. |
duke@1 | 94 | */ |
duke@1 | 95 | public void generateTreeFile() throws IOException { |
duke@1 | 96 | printHtmlHeader(configuration.getText("doclet.Window_Class_Hierarchy"), |
duke@1 | 97 | null, true); |
duke@1 | 98 | |
duke@1 | 99 | printTreeHeader(); |
duke@1 | 100 | |
duke@1 | 101 | printPageHeading(); |
duke@1 | 102 | |
duke@1 | 103 | printPackageTreeLinks(); |
duke@1 | 104 | |
duke@1 | 105 | generateTree(classtree.baseclasses(), "doclet.Class_Hierarchy"); |
duke@1 | 106 | generateTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy"); |
duke@1 | 107 | generateTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy"); |
duke@1 | 108 | generateTree(classtree.baseEnums(), "doclet.Enum_Hierarchy"); |
duke@1 | 109 | |
duke@1 | 110 | printTreeFooter(); |
duke@1 | 111 | } |
duke@1 | 112 | |
duke@1 | 113 | /** |
duke@1 | 114 | * Generate the links to all the package tree files. |
duke@1 | 115 | */ |
duke@1 | 116 | protected void printPackageTreeLinks() { |
duke@1 | 117 | //Do nothing if only unnamed package is used |
duke@1 | 118 | if (packages.length == 1 && packages[0].name().length() == 0) { |
duke@1 | 119 | return; |
duke@1 | 120 | } |
duke@1 | 121 | if (!classesonly) { |
duke@1 | 122 | dl(); |
duke@1 | 123 | dt(); |
bpatel@182 | 124 | strongText("doclet.Package_Hierarchies"); |
bpatel@233 | 125 | dtEnd(); |
duke@1 | 126 | dd(); |
duke@1 | 127 | for (int i = 0; i < packages.length; i++) { |
duke@1 | 128 | if (packages[i].name().length() == 0) { |
duke@1 | 129 | continue; |
duke@1 | 130 | } |
duke@1 | 131 | String filename = pathString(packages[i], "package-tree.html"); |
duke@1 | 132 | printHyperLink(filename, "", packages[i].name()); |
duke@1 | 133 | if (i < packages.length - 1) { |
duke@1 | 134 | print(", "); |
duke@1 | 135 | } |
duke@1 | 136 | } |
bpatel@233 | 137 | ddEnd(); |
duke@1 | 138 | dlEnd(); |
duke@1 | 139 | hr(); |
duke@1 | 140 | } |
duke@1 | 141 | } |
duke@1 | 142 | |
duke@1 | 143 | /** |
duke@1 | 144 | * Print the top text (from the -top option) and |
duke@1 | 145 | * navigation bar at the top of page. |
duke@1 | 146 | */ |
duke@1 | 147 | protected void printTreeHeader() { |
duke@1 | 148 | printTop(); |
duke@1 | 149 | navLinks(true); |
duke@1 | 150 | hr(); |
duke@1 | 151 | } |
duke@1 | 152 | |
duke@1 | 153 | /** |
duke@1 | 154 | * Print the navigation bar and bottom text (from the -bottom option) |
duke@1 | 155 | * at the bottom of page. |
duke@1 | 156 | */ |
duke@1 | 157 | protected void printTreeFooter() { |
duke@1 | 158 | hr(); |
duke@1 | 159 | navLinks(false); |
duke@1 | 160 | printBottom(); |
duke@1 | 161 | printBodyHtmlEnd(); |
duke@1 | 162 | } |
duke@1 | 163 | |
duke@1 | 164 | /** |
duke@1 | 165 | * Print the page title "Hierarchy For All Packages" at the top of the tree |
duke@1 | 166 | * page. |
duke@1 | 167 | */ |
duke@1 | 168 | protected void printPageHeading() { |
duke@1 | 169 | center(); |
duke@1 | 170 | h2(); |
duke@1 | 171 | printText("doclet.Hierarchy_For_All_Packages"); |
duke@1 | 172 | h2End(); |
duke@1 | 173 | centerEnd(); |
duke@1 | 174 | } |
duke@1 | 175 | } |