Wed, 01 Dec 2010 11:02:38 -0800
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
Reviewed-by: jjg
1 /*
2 * Copyright (c) 2010, 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 */
26 package com.sun.tools.doclets.formats.html.markup;
28 import com.sun.tools.doclets.internal.toolkit.Content;
29 import com.sun.tools.doclets.internal.toolkit.util.*;
31 /**
32 * Class for generating document type for HTML pages of javadoc output.
33 *
34 * @author Bhavesh Patel
35 */
36 public class DocType extends Content{
38 private String docType;
40 private static DocType transitional;
42 private static DocType frameset;
44 /**
45 * Constructor to construct a DocType object.
46 *
47 * @param type the doctype to be added
48 */
49 private DocType(String type, String dtd) {
50 docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " + type +
51 "//EN\" \"" + dtd + "\">\n";
52 }
54 /**
55 * Construct and return a HTML 4.01 transitional DocType content
56 *
57 * @return a content tree for transitional DocType
58 */
59 public static DocType Transitional() {
60 if (transitional == null)
61 transitional = new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd");
62 return transitional;
63 }
65 /**
66 * Construct and return a HTML 4.01 frameset DocType content
67 *
68 * @return a content tree for frameset DocType
69 */
70 public static DocType Frameset() {
71 if (frameset == null)
72 frameset = new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd");
73 return frameset;
74 }
76 /**
77 * This method is not supported by the class.
78 *
79 * @param content content that needs to be added
80 * @throws DocletAbortException this method will always throw a
81 * DocletAbortException because it
82 * is not supported.
83 */
84 public void addContent(Content content) {
85 throw new DocletAbortException();
86 }
88 /**
89 * This method is not supported by the class.
90 *
91 * @param stringContent string content that needs to be added
92 * @throws DocletAbortException this method will always throw a
93 * DocletAbortException because it
94 * is not supported.
95 */
96 public void addContent(String stringContent) {
97 throw new DocletAbortException();
98 }
100 /**
101 * {@inheritDoc}
102 */
103 public boolean isEmpty() {
104 return (docType.length() == 0);
105 }
107 /**
108 * {@inheritDoc}
109 */
110 public void write(StringBuilder contentBuilder) {
111 contentBuilder.append(docType);
112 }
113 }