Thu, 10 Jun 2010 17:09:56 -0700
6960407: Potential rebranding issues in openjdk/langtools repository sources
Reviewed-by: darcy
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 1998, 2004, Oracle and/or its affiliates. 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 |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle 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 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * 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 | import java.util.*; |
duke@1 | 30 | |
duke@1 | 31 | import com.sun.javadoc.*; |
bpatel@233 | 32 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 33 | |
duke@1 | 34 | /** |
duke@1 | 35 | * Generate Index for all the Member Names with Indexing in |
duke@1 | 36 | * Unicode Order. This class is a base class for {@link SingleIndexWriter} and |
duke@1 | 37 | * {@link SplitIndexWriter}. It uses the functionality from |
duke@1 | 38 | * {@link HtmlDocletWriter} to generate the Index Contents. |
duke@1 | 39 | * |
duke@1 | 40 | * @see IndexBuilder |
duke@1 | 41 | * @author Atul M Dambalkar |
duke@1 | 42 | */ |
duke@1 | 43 | public class AbstractIndexWriter extends HtmlDocletWriter { |
duke@1 | 44 | |
duke@1 | 45 | /** |
duke@1 | 46 | * The index of all the members with unicode character. |
duke@1 | 47 | */ |
duke@1 | 48 | protected IndexBuilder indexbuilder; |
duke@1 | 49 | |
duke@1 | 50 | /** |
duke@1 | 51 | * This constructor will be used by {@link SplitIndexWriter}. Initialises |
duke@1 | 52 | * path to this file and relative path from this file. |
duke@1 | 53 | * |
duke@1 | 54 | * @param path Path to the file which is getting generated. |
duke@1 | 55 | * @param filename Name of the file which is getting genrated. |
duke@1 | 56 | * @param relpath Relative path from this file to the current directory. |
duke@1 | 57 | * @param indexbuilder Unicode based Index from {@link IndexBuilder} |
duke@1 | 58 | */ |
duke@1 | 59 | protected AbstractIndexWriter(ConfigurationImpl configuration, |
duke@1 | 60 | String path, String filename, |
duke@1 | 61 | String relpath, IndexBuilder indexbuilder) |
duke@1 | 62 | throws IOException { |
duke@1 | 63 | super(configuration, path, filename, relpath); |
duke@1 | 64 | this.indexbuilder = indexbuilder; |
duke@1 | 65 | } |
duke@1 | 66 | |
duke@1 | 67 | /** |
duke@1 | 68 | * This Constructor will be used by {@link SingleIndexWriter}. |
duke@1 | 69 | * |
duke@1 | 70 | * @param filename Name of the file which is getting genrated. |
duke@1 | 71 | * @param indexbuilder Unicode based Index form {@link IndexBuilder} |
duke@1 | 72 | */ |
duke@1 | 73 | protected AbstractIndexWriter(ConfigurationImpl configuration, |
duke@1 | 74 | String filename, IndexBuilder indexbuilder) |
duke@1 | 75 | throws IOException { |
duke@1 | 76 | super(configuration, filename); |
duke@1 | 77 | this.indexbuilder = indexbuilder; |
duke@1 | 78 | } |
duke@1 | 79 | |
duke@1 | 80 | /** |
bpatel@182 | 81 | * Print the text "Index" in strong format in the navigation bar. |
duke@1 | 82 | */ |
duke@1 | 83 | protected void navLinkIndex() { |
duke@1 | 84 | navCellRevStart(); |
duke@1 | 85 | fontStyle("NavBarFont1Rev"); |
bpatel@182 | 86 | strongText("doclet.Index"); |
duke@1 | 87 | fontEnd(); |
duke@1 | 88 | navCellEnd(); |
duke@1 | 89 | } |
duke@1 | 90 | |
duke@1 | 91 | /** |
duke@1 | 92 | * Generate the member information for the unicode character along with the |
duke@1 | 93 | * list of the members. |
duke@1 | 94 | * |
duke@1 | 95 | * @param unicode Unicode for which member list information to be generated. |
duke@1 | 96 | * @param memberlist List of members for the unicode character. |
duke@1 | 97 | */ |
mcimadamore@184 | 98 | protected void generateContents(Character unicode, List<? extends Doc> memberlist) { |
duke@1 | 99 | anchor("_" + unicode + "_"); |
duke@1 | 100 | h2(); |
bpatel@182 | 101 | strong(unicode.toString()); |
duke@1 | 102 | h2End(); |
bpatel@233 | 103 | int memberListSize = memberlist.size(); |
bpatel@233 | 104 | // Display the list only if there are elements to be displayed. |
bpatel@233 | 105 | if (memberListSize > 0) { |
bpatel@233 | 106 | dl(); |
bpatel@233 | 107 | for (int i = 0; i < memberListSize; i++) { |
bpatel@233 | 108 | Doc element = memberlist.get(i); |
bpatel@233 | 109 | if (element instanceof MemberDoc) { |
bpatel@233 | 110 | printDescription((MemberDoc)element); |
bpatel@233 | 111 | } else if (element instanceof ClassDoc) { |
bpatel@233 | 112 | printDescription((ClassDoc)element); |
bpatel@233 | 113 | } else if (element instanceof PackageDoc) { |
bpatel@233 | 114 | printDescription((PackageDoc)element); |
bpatel@233 | 115 | } |
duke@1 | 116 | } |
bpatel@233 | 117 | dlEnd(); |
duke@1 | 118 | } |
duke@1 | 119 | hr(); |
duke@1 | 120 | } |
duke@1 | 121 | |
duke@1 | 122 | |
duke@1 | 123 | /** |
duke@1 | 124 | * Print one line summary comment for the package. |
duke@1 | 125 | * |
duke@1 | 126 | * @param pkg PackageDoc passed. |
duke@1 | 127 | */ |
duke@1 | 128 | protected void printDescription(PackageDoc pkg) { |
duke@1 | 129 | dt(); |
duke@1 | 130 | printPackageLink(pkg, Util.getPackageName(pkg), true); |
duke@1 | 131 | print(" - "); |
duke@1 | 132 | print(configuration.getText("doclet.package") + " " + pkg.name()); |
bpatel@233 | 133 | dtEnd(); |
duke@1 | 134 | dd(); |
duke@1 | 135 | printSummaryComment(pkg); |
bpatel@233 | 136 | ddEnd(); |
duke@1 | 137 | } |
duke@1 | 138 | |
duke@1 | 139 | /** |
duke@1 | 140 | * Print one line summary comment for the class. |
duke@1 | 141 | * |
duke@1 | 142 | * @param cd ClassDoc passed. |
duke@1 | 143 | */ |
duke@1 | 144 | protected void printDescription(ClassDoc cd) { |
duke@1 | 145 | dt(); |
duke@1 | 146 | printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true)); |
duke@1 | 147 | print(" - "); |
duke@1 | 148 | printClassInfo(cd); |
bpatel@233 | 149 | dtEnd(); |
duke@1 | 150 | dd(); |
duke@1 | 151 | printComment(cd); |
bpatel@233 | 152 | ddEnd(); |
duke@1 | 153 | } |
duke@1 | 154 | |
duke@1 | 155 | /** |
duke@1 | 156 | * Print the classkind(class, interface, exception, error of the class |
duke@1 | 157 | * passed. |
duke@1 | 158 | * |
duke@1 | 159 | * @param cd ClassDoc. |
duke@1 | 160 | */ |
duke@1 | 161 | protected void printClassInfo(ClassDoc cd) { |
duke@1 | 162 | print(configuration.getText("doclet.in", |
duke@1 | 163 | Util.getTypeName(configuration, cd, false), |
duke@1 | 164 | getPackageLink(cd.containingPackage(), |
duke@1 | 165 | Util.getPackageName(cd.containingPackage()), false))); |
duke@1 | 166 | } |
duke@1 | 167 | |
duke@1 | 168 | |
duke@1 | 169 | /** |
duke@1 | 170 | * Generate Description for Class, Field, Method or Constructor. |
duke@1 | 171 | * for Java.* Packages Class Members. |
duke@1 | 172 | * |
duke@1 | 173 | * @param member MemberDoc for the member of the Class Kind. |
duke@1 | 174 | * @see com.sun.javadoc.MemberDoc |
duke@1 | 175 | */ |
duke@1 | 176 | protected void printDescription(MemberDoc member) { |
duke@1 | 177 | String name = (member instanceof ExecutableMemberDoc)? |
duke@1 | 178 | member.name() + ((ExecutableMemberDoc)member).flatSignature() : |
duke@1 | 179 | member.name(); |
duke@1 | 180 | if (name.indexOf("<") != -1 || name.indexOf(">") != -1) { |
duke@1 | 181 | name = Util.escapeHtmlChars(name); |
duke@1 | 182 | } |
duke@1 | 183 | ClassDoc containing = member.containingClass(); |
duke@1 | 184 | dt(); |
duke@1 | 185 | printDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name, true); |
duke@1 | 186 | println(" - "); |
duke@1 | 187 | printMemberDesc(member); |
duke@1 | 188 | println(); |
bpatel@233 | 189 | dtEnd(); |
duke@1 | 190 | dd(); |
duke@1 | 191 | printComment(member); |
bpatel@233 | 192 | ddEnd(); |
duke@1 | 193 | println(); |
duke@1 | 194 | } |
duke@1 | 195 | |
duke@1 | 196 | |
duke@1 | 197 | /** |
duke@1 | 198 | * Print comment for each element in the index. If the element is deprecated |
duke@1 | 199 | * and it has a @deprecated tag, use that comment. Else if the containing |
duke@1 | 200 | * class for this element is deprecated, then add the word "Deprecated." at |
duke@1 | 201 | * the start and then print the normal comment. |
duke@1 | 202 | * |
duke@1 | 203 | * @param element Index element. |
duke@1 | 204 | */ |
duke@1 | 205 | protected void printComment(ProgramElementDoc element) { |
duke@1 | 206 | Tag[] tags; |
duke@1 | 207 | if (Util.isDeprecated(element)) { |
bpatel@182 | 208 | strongText("doclet.Deprecated"); space(); |
duke@1 | 209 | if ((tags = element.tags("deprecated")).length > 0) |
duke@1 | 210 | printInlineDeprecatedComment(element, tags[0]); |
duke@1 | 211 | } else { |
duke@1 | 212 | ClassDoc cont = element.containingClass(); |
duke@1 | 213 | while (cont != null) { |
duke@1 | 214 | if (Util.isDeprecated(cont)) { |
bpatel@182 | 215 | strongText("doclet.Deprecated"); space(); |
duke@1 | 216 | break; |
duke@1 | 217 | } |
duke@1 | 218 | cont = cont.containingClass(); |
duke@1 | 219 | } |
duke@1 | 220 | printSummaryComment(element); |
duke@1 | 221 | } |
duke@1 | 222 | } |
duke@1 | 223 | |
duke@1 | 224 | /** |
duke@1 | 225 | * Print description about the Static Varible/Method/Constructor for a |
duke@1 | 226 | * member. |
duke@1 | 227 | * |
duke@1 | 228 | * @param member MemberDoc for the member within the Class Kind. |
duke@1 | 229 | * @see com.sun.javadoc.MemberDoc |
duke@1 | 230 | */ |
duke@1 | 231 | protected void printMemberDesc(MemberDoc member) { |
duke@1 | 232 | ClassDoc containing = member.containingClass(); |
duke@1 | 233 | String classdesc = Util.getTypeName(configuration, containing, true) + " " + |
duke@1 | 234 | getPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing, |
duke@1 | 235 | false); |
duke@1 | 236 | if (member.isField()) { |
duke@1 | 237 | if (member.isStatic()) { |
duke@1 | 238 | printText("doclet.Static_variable_in", classdesc); |
duke@1 | 239 | } else { |
duke@1 | 240 | printText("doclet.Variable_in", classdesc); |
duke@1 | 241 | } |
duke@1 | 242 | } else if (member.isConstructor()) { |
duke@1 | 243 | printText("doclet.Constructor_for", classdesc); |
duke@1 | 244 | } else if (member.isMethod()) { |
duke@1 | 245 | if (member.isStatic()) { |
duke@1 | 246 | printText("doclet.Static_method_in", classdesc); |
duke@1 | 247 | } else { |
duke@1 | 248 | printText("doclet.Method_in", classdesc); |
duke@1 | 249 | } |
duke@1 | 250 | } |
duke@1 | 251 | } |
duke@1 | 252 | } |