src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocument.java

changeset 766
90af8d87741f
child 1359
25e14ad23cef
equal deleted inserted replaced
758:bcbc86cc5b31 766:90af8d87741f
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 */
25
26 package com.sun.tools.doclets.formats.html.markup;
27
28 import java.util.*;
29 import com.sun.tools.doclets.internal.toolkit.Content;
30 import com.sun.tools.doclets.internal.toolkit.util.*;
31
32 /**
33 * Class for generating an HTML document for javadoc output.
34 *
35 * @author Bhavesh Patel
36 */
37 public class HtmlDocument extends Content {
38
39 private List<Content> docContent = Collections.<Content>emptyList();
40
41 /**
42 * Constructor to construct an HTML document.
43 *
44 * @param docType document type for the HTML document
45 * @param docComment comment for the document
46 * @param htmlTree HTML tree of the document
47 */
48 public HtmlDocument(Content docType, Content docComment, Content htmlTree) {
49 docContent = new ArrayList<Content>();
50 addContent(nullCheck(docType));
51 addContent(nullCheck(docComment));
52 addContent(nullCheck(htmlTree));
53 }
54
55 /**
56 * Constructor to construct an HTML document.
57 *
58 * @param docType document type for the HTML document
59 * @param htmlTree HTML tree of the document
60 */
61 public HtmlDocument(Content docType, Content htmlTree) {
62 docContent = new ArrayList<Content>();
63 addContent(nullCheck(docType));
64 addContent(nullCheck(htmlTree));
65 }
66
67 /**
68 * Adds content for the HTML document.
69 *
70 * @param htmlContent html content to be added
71 */
72 public void addContent(Content htmlContent) {
73 if (htmlContent.isValid())
74 docContent.add(htmlContent);
75 }
76
77 /**
78 * This method is not supported by the class.
79 *
80 * @param stringContent string content that needs to be added
81 * @throws DocletAbortException this method will always throw a
82 * DocletAbortException because it
83 * is not supported.
84 */
85 public void addContent(String stringContent) {
86 throw new DocletAbortException();
87 }
88
89 /**
90 * {@inheritDoc}
91 */
92 public boolean isEmpty() {
93 return (docContent.isEmpty());
94 }
95
96 /**
97 * {@inheritDoc}
98 */
99 public void write(StringBuilder contentBuilder) {
100 for (Content c : docContent)
101 c.write(contentBuilder);
102 }
103 }

mercurial