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

Mon, 09 Mar 2009 23:53:41 -0700

author
tbell
date
Mon, 09 Mar 2009 23:53:41 -0700
changeset 240
8c55d5b0ed71
parent 182
47a62d8d98b4
child 243
edd944553131
permissions
-rw-r--r--

Merge

duke@1 1 /*
duke@1 2 * Copyright 1998-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
duke@1 28 import com.sun.javadoc.*;
duke@1 29 import java.io.*;
duke@1 30 import java.util.*;
duke@1 31
duke@1 32 /**
duke@1 33 * Abstract class to generate the overview files in
duke@1 34 * Frame and Non-Frame format. This will be sub-classed by to
duke@1 35 * generate overview-frame.html as well as overview-summary.html.
duke@1 36 *
duke@1 37 * @author Atul M Dambalkar
duke@1 38 */
duke@1 39 public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter {
duke@1 40
duke@1 41 /**
duke@1 42 * Array of Packages to be documented.
duke@1 43 */
duke@1 44 protected PackageDoc[] packages;
duke@1 45
duke@1 46 /**
duke@1 47 * Constructor. Also initialises the packages variable.
duke@1 48 *
duke@1 49 * @param filename Name of the package index file to be generated.
duke@1 50 */
duke@1 51 public AbstractPackageIndexWriter(ConfigurationImpl configuration,
duke@1 52 String filename) throws IOException {
duke@1 53 super(configuration, filename);
duke@1 54 this.relativepathNoSlash = ".";
duke@1 55 packages = configuration.packages;
duke@1 56 }
duke@1 57
duke@1 58 protected abstract void printNavigationBarHeader();
duke@1 59
duke@1 60 protected abstract void printNavigationBarFooter();
duke@1 61
duke@1 62 protected abstract void printOverviewHeader();
duke@1 63
duke@1 64 protected abstract void printIndexHeader(String text);
duke@1 65
duke@1 66 protected abstract void printIndexRow(PackageDoc pkg);
duke@1 67
duke@1 68 protected abstract void printIndexFooter();
duke@1 69
duke@1 70 /**
duke@1 71 * Generate the contants in the package index file. Call appropriate
duke@1 72 * methods from the sub-class in order to generate Frame or Non
duke@1 73 * Frame format.
duke@1 74 * @param title the title of the window.
duke@1 75 * @param includeScript boolean set true if windowtitle script is to be included
duke@1 76 */
duke@1 77 protected void generatePackageIndexFile(String title, boolean includeScript) throws IOException {
duke@1 78 String windowOverview = configuration.getText(title);
duke@1 79 printHtmlHeader(windowOverview,
duke@1 80 configuration.metakeywords.getOverviewMetaKeywords(title,
duke@1 81 configuration.doctitle),
duke@1 82 includeScript);
duke@1 83 printNavigationBarHeader();
duke@1 84 printOverviewHeader();
duke@1 85
duke@1 86 generateIndex();
duke@1 87
duke@1 88 printOverview();
duke@1 89
duke@1 90 printNavigationBarFooter();
duke@1 91 printBodyHtmlEnd();
duke@1 92 }
duke@1 93
duke@1 94 /**
duke@1 95 * Default to no overview, overwrite to add overview.
duke@1 96 */
duke@1 97 protected void printOverview() throws IOException {
duke@1 98 }
duke@1 99
duke@1 100 /**
duke@1 101 * Generate the frame or non-frame package index.
duke@1 102 */
duke@1 103 protected void generateIndex() {
duke@1 104 printIndexContents(packages, "doclet.Package_Summary");
duke@1 105 }
duke@1 106
duke@1 107 /**
duke@1 108 * Generate code for package index contents. Call appropriate methods from
duke@1 109 * the sub-classes.
duke@1 110 *
duke@1 111 * @param packages Array of packages to be documented.
duke@1 112 * @param text String which will be used as the heading.
duke@1 113 */
duke@1 114 protected void printIndexContents(PackageDoc[] packages, String text) {
duke@1 115 if (packages.length > 0) {
duke@1 116 Arrays.sort(packages);
duke@1 117 printIndexHeader(text);
duke@1 118 printAllClassesPackagesLink();
duke@1 119 for(int i = 0; i < packages.length; i++) {
duke@1 120 if (packages[i] != null) {
duke@1 121 printIndexRow(packages[i]);
duke@1 122 }
duke@1 123 }
duke@1 124 printIndexFooter();
duke@1 125 }
duke@1 126 }
duke@1 127
duke@1 128 /**
duke@1 129 * Print the doctitle, if it is specified on the command line.
duke@1 130 */
duke@1 131 protected void printConfigurationTitle() {
duke@1 132 if (configuration.doctitle.length() > 0) {
duke@1 133 center();
duke@1 134 h1(configuration.doctitle);
duke@1 135 centerEnd();
duke@1 136 }
duke@1 137 }
duke@1 138
duke@1 139 /**
bpatel@182 140 * Highlight "Overview" in the strong format, in the navigation bar as this
duke@1 141 * is the overview page.
duke@1 142 */
duke@1 143 protected void navLinkContents() {
duke@1 144 navCellRevStart();
duke@1 145 fontStyle("NavBarFont1Rev");
bpatel@182 146 strongText("doclet.Overview");
duke@1 147 fontEnd();
duke@1 148 navCellEnd();
duke@1 149 }
duke@1 150
duke@1 151 /**
duke@1 152 * Do nothing. This will be overridden in PackageIndexFrameWriter.
duke@1 153 */
duke@1 154 protected void printAllClassesPackagesLink() {
duke@1 155 }
duke@1 156 }

mercurial