Thu, 23 May 2013 12:50:40 +0100
Merge
duke@1 | 1 | /* |
jjg@1737 | 2 | * Copyright (c) 1997, 2013, 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.markup; |
duke@1 | 27 | |
jjg@197 | 28 | import java.io.*; |
jjg@197 | 29 | import java.util.*; |
duke@1 | 30 | |
duke@1 | 31 | import com.sun.javadoc.*; |
jjg@1361 | 32 | import com.sun.tools.doclets.formats.html.ConfigurationImpl; |
jjg@197 | 33 | import com.sun.tools.doclets.internal.toolkit.*; |
jjg@1412 | 34 | import com.sun.tools.doclets.internal.toolkit.util.DocFile; |
jjg@1373 | 35 | import com.sun.tools.doclets.internal.toolkit.util.DocLink; |
jjg@1372 | 36 | import com.sun.tools.doclets.internal.toolkit.util.DocPath; |
duke@1 | 37 | |
duke@1 | 38 | |
duke@1 | 39 | /** |
duke@1 | 40 | * Class for the Html Format Code Generation specific to JavaDoc. |
duke@1 | 41 | * This Class contains methods related to the Html Code Generation which |
duke@1 | 42 | * are used by the Sub-Classes in the package com.sun.tools.doclets.standard |
duke@1 | 43 | * and com.sun.tools.doclets.oneone. |
duke@1 | 44 | * |
jjg@1359 | 45 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 46 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 47 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 48 | * deletion without notice.</b> |
jjg@1359 | 49 | * |
duke@1 | 50 | * @since 1.2 |
duke@1 | 51 | * @author Atul M Dambalkar |
duke@1 | 52 | * @author Robert Field |
duke@1 | 53 | */ |
duke@1 | 54 | public abstract class HtmlDocWriter extends HtmlWriter { |
duke@1 | 55 | |
duke@1 | 56 | /** |
duke@1 | 57 | * Constructor. Initializes the destination file name through the super |
duke@1 | 58 | * class HtmlWriter. |
duke@1 | 59 | * |
duke@1 | 60 | * @param filename String file name. |
duke@1 | 61 | */ |
jjg@1372 | 62 | public HtmlDocWriter(Configuration configuration, DocPath filename) |
jjg@1372 | 63 | throws IOException { |
jjg@1372 | 64 | super(configuration, filename); |
duke@1 | 65 | configuration.message.notice("doclet.Generating_0", |
jjg@1412 | 66 | DocFile.createFileForOutput(configuration, filename).getPath()); |
duke@1 | 67 | } |
duke@1 | 68 | |
duke@1 | 69 | /** |
duke@1 | 70 | * Accessor for configuration. |
duke@1 | 71 | */ |
duke@1 | 72 | public abstract Configuration configuration(); |
duke@1 | 73 | |
jjg@1740 | 74 | public Content getHyperLink(DocPath link, String label) { |
jjg@1740 | 75 | return getHyperLink(link, new StringContent(label), false, "", "", ""); |
jjg@1740 | 76 | } |
jjg@1740 | 77 | |
duke@1 | 78 | /** |
duke@1 | 79 | * Get Html Hyper Link string. |
duke@1 | 80 | * |
jjg@1372 | 81 | * @param where Position of the link in the file. Character '#' is not |
jjg@1372 | 82 | * needed. |
jjg@1372 | 83 | * @param label Tag for the link. |
jjg@1372 | 84 | * @return a content tree for the hyper link |
jjg@1372 | 85 | */ |
jjg@1372 | 86 | public Content getHyperLink(String where, |
jjg@1372 | 87 | Content label) { |
jjg@1373 | 88 | return getHyperLink(DocLink.fragment(where), label, "", ""); |
jjg@1372 | 89 | } |
jjg@1372 | 90 | |
jjg@1372 | 91 | /** |
jjg@1737 | 92 | * Get Html hyperlink. |
jjg@1372 | 93 | * |
jjg@1737 | 94 | * @param link path of the file. |
bpatel@766 | 95 | * @param label Tag for the link. |
bpatel@766 | 96 | * @return a content tree for the hyper link |
bpatel@766 | 97 | */ |
jjg@1737 | 98 | public Content getHyperLink(DocPath link, Content label) { |
jjg@1373 | 99 | return getHyperLink(link, label, "", ""); |
jjg@1373 | 100 | } |
jjg@1373 | 101 | |
jjg@1737 | 102 | public Content getHyperLink(DocLink link, Content label) { |
jjg@1373 | 103 | return getHyperLink(link, label, "", ""); |
duke@1 | 104 | } |
duke@1 | 105 | |
jjg@1740 | 106 | public Content getHyperLink(DocPath link, |
jjg@1740 | 107 | Content label, boolean strong, |
jjg@1740 | 108 | String stylename, String title, String target) { |
jjg@1740 | 109 | return getHyperLink(new DocLink(link), label, strong, |
jjg@1740 | 110 | stylename, title, target); |
jjg@1740 | 111 | } |
jjg@1740 | 112 | |
jjg@1737 | 113 | public Content getHyperLink(DocLink link, |
jjg@1737 | 114 | Content label, boolean strong, |
jjg@1737 | 115 | String stylename, String title, String target) { |
jjg@1737 | 116 | Content body = label; |
jjg@1737 | 117 | if (strong) { |
jjg@1737 | 118 | body = HtmlTree.SPAN(HtmlStyle.strong, body); |
jjg@1737 | 119 | } |
jjg@1737 | 120 | if (stylename != null && stylename.length() != 0) { |
jjg@1737 | 121 | HtmlTree t = new HtmlTree(HtmlTag.FONT, body); |
jjg@1737 | 122 | t.addAttr(HtmlAttr.CLASS, stylename); |
jjg@1737 | 123 | body = t; |
jjg@1737 | 124 | } |
jjg@1737 | 125 | HtmlTree l = HtmlTree.A(link.toString(), body); |
jjg@1737 | 126 | if (title != null && title.length() != 0) { |
jjg@1737 | 127 | l.addAttr(HtmlAttr.TITLE, title); |
jjg@1737 | 128 | } |
jjg@1737 | 129 | if (target != null && target.length() != 0) { |
jjg@1737 | 130 | l.addAttr(HtmlAttr.TARGET, target); |
jjg@1737 | 131 | } |
jjg@1737 | 132 | return l; |
jjg@1737 | 133 | } |
jjg@1737 | 134 | |
duke@1 | 135 | /** |
bpatel@766 | 136 | * Get Html Hyper Link. |
duke@1 | 137 | * |
duke@1 | 138 | * @param link String name of the file. |
duke@1 | 139 | * @param label Tag for the link. |
bpatel@766 | 140 | * @param title String that describes the link's content for accessibility. |
bpatel@766 | 141 | * @param target Target frame. |
bpatel@766 | 142 | * @return a content tree for the hyper link. |
duke@1 | 143 | */ |
jjg@1373 | 144 | public Content getHyperLink(DocPath link, |
jjg@1372 | 145 | Content label, String title, String target) { |
jjg@1373 | 146 | return getHyperLink(new DocLink(link), label, title, target); |
jjg@1372 | 147 | } |
jjg@1373 | 148 | |
jjg@1373 | 149 | public Content getHyperLink(DocLink link, |
bpatel@766 | 150 | Content label, String title, String target) { |
jjg@1373 | 151 | HtmlTree anchor = HtmlTree.A(link.toString(), label); |
bpatel@766 | 152 | if (title != null && title.length() != 0) { |
bpatel@766 | 153 | anchor.addAttr(HtmlAttr.TITLE, title); |
bpatel@766 | 154 | } |
bpatel@766 | 155 | if (target != null && target.length() != 0) { |
bpatel@766 | 156 | anchor.addAttr(HtmlAttr.TARGET, target); |
bpatel@766 | 157 | } |
bpatel@766 | 158 | return anchor; |
bpatel@766 | 159 | } |
bpatel@766 | 160 | |
bpatel@766 | 161 | /** |
duke@1 | 162 | * Get the name of the package, this class is in. |
duke@1 | 163 | * |
duke@1 | 164 | * @param cd ClassDoc. |
duke@1 | 165 | */ |
duke@1 | 166 | public String getPkgName(ClassDoc cd) { |
duke@1 | 167 | String pkgName = cd.containingPackage().name(); |
duke@1 | 168 | if (pkgName.length() > 0) { |
duke@1 | 169 | pkgName += "."; |
duke@1 | 170 | return pkgName; |
duke@1 | 171 | } |
duke@1 | 172 | return ""; |
duke@1 | 173 | } |
duke@1 | 174 | |
bpatel@233 | 175 | public boolean getMemberDetailsListPrinted() { |
bpatel@233 | 176 | return memberDetailsListPrinted; |
bpatel@233 | 177 | } |
bpatel@233 | 178 | |
bpatel@233 | 179 | /** |
duke@1 | 180 | * Print the frameset version of the Html file header. |
duke@1 | 181 | * Called only when generating an HTML frameset file. |
duke@1 | 182 | * |
bpatel@766 | 183 | * @param title Title of this HTML document |
bpatel@766 | 184 | * @param noTimeStamp If true, don't print time stamp in header |
bpatel@766 | 185 | * @param frameset the frameset to be added to the HTML document |
duke@1 | 186 | */ |
bpatel@766 | 187 | public void printFramesetDocument(String title, boolean noTimeStamp, |
jjg@1364 | 188 | Content frameset) throws IOException { |
jjg@1410 | 189 | Content htmlDocType = DocType.FRAMESET; |
bpatel@766 | 190 | Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); |
bpatel@766 | 191 | Content head = new HtmlTree(HtmlTag.HEAD); |
duke@1 | 192 | if (! noTimeStamp) { |
jjg@1361 | 193 | Content headComment = new Comment(getGeneratedByString()); |
bpatel@766 | 194 | head.addContent(headComment); |
duke@1 | 195 | } |
duke@1 | 196 | if (configuration.charset.length() > 0) { |
bpatel@766 | 197 | Content meta = HtmlTree.META("Content-Type", "text/html", |
bpatel@766 | 198 | configuration.charset); |
bpatel@766 | 199 | head.addContent(meta); |
duke@1 | 200 | } |
bpatel@766 | 201 | Content windowTitle = HtmlTree.TITLE(new StringContent(title)); |
bpatel@766 | 202 | head.addContent(windowTitle); |
bpatel@766 | 203 | head.addContent(getFramesetJavaScript()); |
bpatel@766 | 204 | Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), |
bpatel@766 | 205 | head, frameset); |
bpatel@766 | 206 | Content htmlDocument = new HtmlDocument(htmlDocType, |
bpatel@766 | 207 | htmlComment, htmlTree); |
jjg@1365 | 208 | write(htmlDocument); |
duke@1 | 209 | } |
duke@1 | 210 | |
jjg@1361 | 211 | protected String getGeneratedByString() { |
duke@1 | 212 | Calendar calendar = new GregorianCalendar(TimeZone.getDefault()); |
jjg@1361 | 213 | Date today = calendar.getTime(); |
jjg@1361 | 214 | return "Generated by javadoc ("+ ConfigurationImpl.BUILD_DATE + ") on " + today; |
duke@1 | 215 | } |
duke@1 | 216 | } |