0N/A/*
996N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.doclets.formats.html;
0N/A
232N/Aimport com.sun.javadoc.*;
0N/Aimport com.sun.tools.doclets.internal.toolkit.*;
0N/Aimport com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder;
0N/Aimport com.sun.tools.doclets.internal.toolkit.taglets.*;
0N/Aimport com.sun.tools.doclets.internal.toolkit.util.*;
0N/A
0N/A/**
0N/A * The taglet writer that writes HTML.
0N/A *
0N/A * @since 1.5
0N/A * @author Jamie Ho
232N/A * @author Bhavesh Patel (Modified)
0N/A */
0N/A
0N/Apublic class TagletWriterImpl extends TagletWriter {
0N/A
0N/A private HtmlDocletWriter htmlWriter;
0N/A
0N/A public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
0N/A this.htmlWriter = htmlWriter;
0N/A this.isFirstSentence = isFirstSentence;
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput getOutputInstance() {
0N/A return new TagletOutputImpl("");
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput getDocRootOutput() {
996N/A if (htmlWriter.configuration.docrootparent.length() > 0)
996N/A return new TagletOutputImpl(htmlWriter.configuration.docrootparent);
996N/A else
996N/A return new TagletOutputImpl(htmlWriter.relativepathNoSlash);
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput deprecatedTagOutput(Doc doc) {
0N/A StringBuffer output = new StringBuffer();
0N/A Tag[] deprs = doc.tags("deprecated");
0N/A if (doc instanceof ClassDoc) {
0N/A if (Util.isDeprecated((ProgramElementDoc) doc)) {
765N/A output.append("<span class=\"strong\">" +
0N/A ConfigurationImpl.getInstance().
765N/A getText("doclet.Deprecated") + "</span>&nbsp;");
0N/A if (deprs.length > 0) {
0N/A Tag[] commentTags = deprs[0].inlineTags();
0N/A if (commentTags.length > 0) {
0N/A
0N/A output.append(commentTagsToOutput(null, doc,
0N/A deprs[0].inlineTags(), false).toString()
0N/A );
0N/A }
0N/A }
0N/A }
0N/A } else {
0N/A MemberDoc member = (MemberDoc) doc;
0N/A if (Util.isDeprecated((ProgramElementDoc) doc)) {
765N/A output.append("<span class=\"strong\">" +
0N/A ConfigurationImpl.getInstance().
765N/A getText("doclet.Deprecated") + "</span>&nbsp;");
0N/A if (deprs.length > 0) {
765N/A output.append("<i>");
0N/A output.append(commentTagsToOutput(null, doc,
0N/A deprs[0].inlineTags(), false).toString());
765N/A output.append("</i>");
0N/A }
0N/A } else {
0N/A if (Util.isDeprecated(member.containingClass())) {
765N/A output.append("<span class=\"strong\">" +
0N/A ConfigurationImpl.getInstance().
765N/A getText("doclet.Deprecated") + "</span>&nbsp;");
0N/A }
0N/A }
0N/A }
0N/A return new TagletOutputImpl(output.toString());
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public MessageRetriever getMsgRetriever() {
0N/A return htmlWriter.configuration.message;
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput getParamHeader(String header) {
0N/A StringBuffer result = new StringBuffer();
765N/A result.append("<dt>");
765N/A result.append("<span class=\"strong\">" + header + "</span></dt>");
0N/A return new TagletOutputImpl(result.toString());
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput paramTagOutput(ParamTag paramTag, String paramName) {
765N/A TagletOutput result = new TagletOutputImpl("<dd><code>" + paramName + "</code>"
765N/A + " - " + htmlWriter.commentTagsToString(paramTag, null, paramTag.inlineTags(), false) + "</dd>");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput returnTagOutput(Tag returnTag) {
765N/A TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "<dt>" +
765N/A "<span class=\"strong\">" + htmlWriter.configuration.getText("doclet.Returns") +
765N/A "</span>" + "</dt>" + "<dd>" +
0N/A htmlWriter.commentTagsToString(returnTag, null, returnTag.inlineTags(),
765N/A false) + "</dd>");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput seeTagOutput(Doc holder, SeeTag[] seeTags) {
0N/A String result = "";
0N/A if (seeTags.length > 0) {
0N/A result = addSeeHeader(result);
0N/A for (int i = 0; i < seeTags.length; ++i) {
0N/A if (i > 0) {
0N/A result += ", " + DocletConstants.NL;
0N/A }
0N/A result += htmlWriter.seeTagToString(seeTags[i]);
0N/A }
0N/A }
0N/A if (holder.isField() && ((FieldDoc)holder).constantValue() != null &&
0N/A htmlWriter instanceof ClassWriterImpl) {
0N/A //Automatically add link to constant values page for constant fields.
0N/A result = addSeeHeader(result);
765N/A result += htmlWriter.getHyperLinkString(htmlWriter.relativePath +
0N/A ConfigurationImpl.CONSTANTS_FILE_NAME
0N/A + "#" + ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName()
0N/A + "." + ((FieldDoc) holder).name(),
0N/A htmlWriter.configuration.getText("doclet.Constants_Summary"));
0N/A }
0N/A if (holder.isClass() && ((ClassDoc)holder).isSerializable()) {
0N/A //Automatically add link to serialized form page for serializable classes.
232N/A if ((SerializedFormBuilder.serialInclude(holder) &&
0N/A SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) {
232N/A result = addSeeHeader(result);
765N/A result += htmlWriter.getHyperLinkString(htmlWriter.relativePath + "serialized-form.html",
232N/A ((ClassDoc)holder).qualifiedName(), htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
0N/A }
0N/A }
765N/A return result.equals("") ? null : new TagletOutputImpl(result + "</dd>");
0N/A }
0N/A
0N/A private String addSeeHeader(String result) {
0N/A if (result != null && result.length() > 0) {
0N/A return result + ", " + DocletConstants.NL;
0N/A } else {
765N/A return "<dt><span class=\"strong\">" +
765N/A htmlWriter.configuration().getText("doclet.See_Also") + "</span></dt><dd>";
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput simpleTagOutput(Tag[] simpleTags, String header) {
765N/A String result = "<dt><span class=\"strong\">" + header + "</span></dt>" + DocletConstants.NL +
765N/A " <dd>";
0N/A for (int i = 0; i < simpleTags.length; i++) {
0N/A if (i > 0) {
0N/A result += ", ";
0N/A }
0N/A result += htmlWriter.commentTagsToString(simpleTags[i], null, simpleTags[i].inlineTags(), false);
0N/A }
765N/A result += "</dd>" + DocletConstants.NL;
232N/A return new TagletOutputImpl(result);
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput simpleTagOutput(Tag simpleTag, String header) {
765N/A return new TagletOutputImpl("<dt><span class=\"strong\">" + header + "</span></dt>" + " <dd>"
0N/A + htmlWriter.commentTagsToString(simpleTag, null, simpleTag.inlineTags(), false)
765N/A + "</dd>" + DocletConstants.NL);
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput getThrowsHeader() {
765N/A return new TagletOutputImpl(DocletConstants.NL + "<dt>" + "<span class=\"strong\">" +
765N/A htmlWriter.configuration().getText("doclet.Throws") + "</span></dt>");
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput throwsTagOutput(ThrowsTag throwsTag) {
765N/A String result = DocletConstants.NL + "<dd>";
0N/A result += throwsTag.exceptionType() == null ?
0N/A htmlWriter.codeText(throwsTag.exceptionName()) :
0N/A htmlWriter.codeText(
0N/A htmlWriter.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
0N/A throwsTag.exceptionType())));
0N/A TagletOutput text = new TagletOutputImpl(
0N/A htmlWriter.commentTagsToString(throwsTag, null,
0N/A throwsTag.inlineTags(), false));
0N/A if (text != null && text.toString().length() > 0) {
0N/A result += " - " + text;
0N/A }
765N/A result += "</dd>";
0N/A return new TagletOutputImpl(result);
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput throwsTagOutput(Type throwsType) {
765N/A return new TagletOutputImpl(DocletConstants.NL + "<dd>" +
0N/A htmlWriter.codeText(htmlWriter.getLink(
765N/A new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "</dd>");
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput valueTagOutput(FieldDoc field, String constantVal,
0N/A boolean includeLink) {
0N/A return new TagletOutputImpl(includeLink ?
0N/A htmlWriter.getDocLink(LinkInfoImpl.CONTEXT_VALUE_TAG, field,
0N/A constantVal, false) : constantVal);
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput commentTagsToOutput(Tag holderTag, Tag[] tags) {
0N/A return commentTagsToOutput(holderTag, null, tags, false);
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput commentTagsToOutput(Doc holderDoc, Tag[] tags) {
0N/A return commentTagsToOutput(null, holderDoc, tags, false);
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public TagletOutput commentTagsToOutput(Tag holderTag,
0N/A Doc holderDoc, Tag[] tags, boolean isFirstSentence) {
0N/A return new TagletOutputImpl(htmlWriter.commentTagsToString(
0N/A holderTag, holderDoc, tags, isFirstSentence));
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public Configuration configuration() {
0N/A return htmlWriter.configuration();
0N/A }
0N/A
0N/A /**
0N/A * Return an instance of a TagletWriter that knows how to write HTML.
0N/A *
0N/A * @return an instance of a TagletWriter that knows how to write HTML.
0N/A */
0N/A public TagletOutput getTagletOutputInstance() {
0N/A return new TagletOutputImpl("");
0N/A }
0N/A}