Wed, 01 Dec 2010 11:02:38 -0800
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
Reviewed-by: jjg
bpatel@766 | 1 | /* |
bpatel@766 | 2 | * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
bpatel@766 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bpatel@766 | 4 | * |
bpatel@766 | 5 | * This code is free software; you can redistribute it and/or modify it |
bpatel@766 | 6 | * under the terms of the GNU General Public License version 2 only, as |
bpatel@766 | 7 | * published by the Free Software Foundation. Oracle designates this |
bpatel@766 | 8 | * particular file as subject to the "Classpath" exception as provided |
bpatel@766 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
bpatel@766 | 10 | * |
bpatel@766 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
bpatel@766 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bpatel@766 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bpatel@766 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
bpatel@766 | 15 | * accompanied this code). |
bpatel@766 | 16 | * |
bpatel@766 | 17 | * You should have received a copy of the GNU General Public License version |
bpatel@766 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
bpatel@766 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bpatel@766 | 20 | * |
bpatel@766 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bpatel@766 | 22 | * or visit www.oracle.com if you need additional information or have any |
bpatel@766 | 23 | * questions. |
bpatel@766 | 24 | */ |
bpatel@766 | 25 | |
bpatel@766 | 26 | package com.sun.tools.doclets.formats.html.markup; |
bpatel@766 | 27 | |
bpatel@766 | 28 | import com.sun.tools.doclets.internal.toolkit.Content; |
bpatel@766 | 29 | import com.sun.tools.doclets.internal.toolkit.util.*; |
bpatel@766 | 30 | |
bpatel@766 | 31 | /** |
bpatel@766 | 32 | * Class for generating document type for HTML pages of javadoc output. |
bpatel@766 | 33 | * |
bpatel@766 | 34 | * @author Bhavesh Patel |
bpatel@766 | 35 | */ |
bpatel@766 | 36 | public class DocType extends Content{ |
bpatel@766 | 37 | |
bpatel@766 | 38 | private String docType; |
bpatel@766 | 39 | |
bpatel@766 | 40 | private static DocType transitional; |
bpatel@766 | 41 | |
bpatel@766 | 42 | private static DocType frameset; |
bpatel@766 | 43 | |
bpatel@766 | 44 | /** |
bpatel@766 | 45 | * Constructor to construct a DocType object. |
bpatel@766 | 46 | * |
bpatel@766 | 47 | * @param type the doctype to be added |
bpatel@766 | 48 | */ |
bpatel@766 | 49 | private DocType(String type, String dtd) { |
bpatel@766 | 50 | docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " + type + |
bpatel@766 | 51 | "//EN\" \"" + dtd + "\">\n"; |
bpatel@766 | 52 | } |
bpatel@766 | 53 | |
bpatel@766 | 54 | /** |
bpatel@766 | 55 | * Construct and return a HTML 4.01 transitional DocType content |
bpatel@766 | 56 | * |
bpatel@766 | 57 | * @return a content tree for transitional DocType |
bpatel@766 | 58 | */ |
bpatel@766 | 59 | public static DocType Transitional() { |
bpatel@766 | 60 | if (transitional == null) |
bpatel@766 | 61 | transitional = new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd"); |
bpatel@766 | 62 | return transitional; |
bpatel@766 | 63 | } |
bpatel@766 | 64 | |
bpatel@766 | 65 | /** |
bpatel@766 | 66 | * Construct and return a HTML 4.01 frameset DocType content |
bpatel@766 | 67 | * |
bpatel@766 | 68 | * @return a content tree for frameset DocType |
bpatel@766 | 69 | */ |
bpatel@766 | 70 | public static DocType Frameset() { |
bpatel@766 | 71 | if (frameset == null) |
bpatel@766 | 72 | frameset = new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd"); |
bpatel@766 | 73 | return frameset; |
bpatel@766 | 74 | } |
bpatel@766 | 75 | |
bpatel@766 | 76 | /** |
bpatel@766 | 77 | * This method is not supported by the class. |
bpatel@766 | 78 | * |
bpatel@766 | 79 | * @param content content that needs to be added |
bpatel@766 | 80 | * @throws DocletAbortException this method will always throw a |
bpatel@766 | 81 | * DocletAbortException because it |
bpatel@766 | 82 | * is not supported. |
bpatel@766 | 83 | */ |
bpatel@766 | 84 | public void addContent(Content content) { |
bpatel@766 | 85 | throw new DocletAbortException(); |
bpatel@766 | 86 | } |
bpatel@766 | 87 | |
bpatel@766 | 88 | /** |
bpatel@766 | 89 | * This method is not supported by the class. |
bpatel@766 | 90 | * |
bpatel@766 | 91 | * @param stringContent string content that needs to be added |
bpatel@766 | 92 | * @throws DocletAbortException this method will always throw a |
bpatel@766 | 93 | * DocletAbortException because it |
bpatel@766 | 94 | * is not supported. |
bpatel@766 | 95 | */ |
bpatel@766 | 96 | public void addContent(String stringContent) { |
bpatel@766 | 97 | throw new DocletAbortException(); |
bpatel@766 | 98 | } |
bpatel@766 | 99 | |
bpatel@766 | 100 | /** |
bpatel@766 | 101 | * {@inheritDoc} |
bpatel@766 | 102 | */ |
bpatel@766 | 103 | public boolean isEmpty() { |
bpatel@766 | 104 | return (docType.length() == 0); |
bpatel@766 | 105 | } |
bpatel@766 | 106 | |
bpatel@766 | 107 | /** |
bpatel@766 | 108 | * {@inheritDoc} |
bpatel@766 | 109 | */ |
bpatel@766 | 110 | public void write(StringBuilder contentBuilder) { |
bpatel@766 | 111 | contentBuilder.append(docType); |
bpatel@766 | 112 | } |
bpatel@766 | 113 | } |