1 /* 2 * Copyright (c) 1997, 2017, 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 */ 25 26 package jdk.javadoc.internal.doclets.formats.html.markup; 27 28 import javax.lang.model.element.ModuleElement; 29 import javax.lang.model.element.PackageElement; 30 import javax.lang.model.element.TypeElement; 31 32 import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; 33 import jdk.javadoc.internal.doclets.toolkit.Content; 34 import jdk.javadoc.internal.doclets.toolkit.Messages; 35 import jdk.javadoc.internal.doclets.toolkit.util.DocFile; 36 import jdk.javadoc.internal.doclets.toolkit.util.DocLink; 37 import jdk.javadoc.internal.doclets.toolkit.util.DocPath; 38 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; 39 40 41 /** 42 * Class for the Html Format Code Generation specific to JavaDoc. 43 * This Class contains methods related to the Html Code Generation which 44 * are used by the Sub-Classes in the package jdk.javadoc.internal.tool.standard. 45 * 46 * <p><b>This is NOT part of any supported API. 47 * If you write code that depends on this, you do so at your own risk. 48 * This code and its internal interfaces are subject to change or 49 * deletion without notice.</b> 50 * 51 * @author Atul M Dambalkar 52 * @author Robert Field 53 */ 54 public abstract class HtmlDocWriter { 55 56 private final HtmlConfiguration configuration; 57 58 /** 59 * Constructor. 60 * 61 * @param configuration the configuration for this doclet 62 * @param filename the path for the output file 63 */ 64 public HtmlDocWriter(HtmlConfiguration configuration, DocPath filename) { 65 this.configuration = configuration; 66 Messages messages = configuration.getMessages(); 67 messages.notice("doclet.Generating_0", 68 DocFile.createFileForOutput(configuration, filename).getPath()); 69 } 70 71 public Content getModuleFramesHyperLink(ModuleElement mdle, Content label, String target) { 72 DocLink mdlLink = new DocLink(DocPaths.moduleFrame(mdle)); 73 DocLink mtFrameLink = new DocLink(DocPaths.moduleTypeFrame(mdle)); 74 DocLink cFrameLink = new DocLink(DocPaths.moduleSummary(mdle)); 75 HtmlTree anchor = HtmlTree.A(mdlLink.toString(), label); 76 String onclickStr = "updateModuleFrame('" + mtFrameLink + "','" + cFrameLink + "');"; 77 anchor.addAttr(HtmlAttr.TARGET, target); 78 anchor.addAttr(HtmlAttr.ONCLICK, onclickStr); 79 return anchor; 80 } 81 82 /** 83 * Get the enclosed name of the package 84 * 85 * @param te TypeElement 86 * @return the name 87 */ 88 public String getEnclosingPackageName(TypeElement te) { 89 90 PackageElement encl = configuration.utils.containingPackage(te); 91 return (encl.isUnnamed()) ? "" : (encl.getQualifiedName() + "."); 92 } 93 }