Mon, 21 Jan 2013 00:45:35 -0500
8006124: javadoc/doclet should be updated to support profiles
Reviewed-by: jjg
bpatel@766 | 1 | /* |
jjg@1359 | 2 | * Copyright (c) 2010, 2012, 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 | |
jjg@1364 | 28 | import java.io.IOException; |
jjg@1364 | 29 | import java.io.Writer; |
bpatel@766 | 30 | import java.util.*; |
jjg@1364 | 31 | |
bpatel@766 | 32 | import com.sun.tools.doclets.internal.toolkit.Content; |
bpatel@766 | 33 | import com.sun.tools.doclets.internal.toolkit.util.*; |
bpatel@766 | 34 | |
bpatel@766 | 35 | /** |
bpatel@766 | 36 | * Class for generating an HTML document for javadoc output. |
bpatel@766 | 37 | * |
jjg@1359 | 38 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 39 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 40 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 41 | * deletion without notice.</b> |
jjg@1359 | 42 | * |
bpatel@766 | 43 | * @author Bhavesh Patel |
bpatel@766 | 44 | */ |
bpatel@766 | 45 | public class HtmlDocument extends Content { |
bpatel@766 | 46 | |
bpatel@766 | 47 | private List<Content> docContent = Collections.<Content>emptyList(); |
bpatel@766 | 48 | |
bpatel@766 | 49 | /** |
bpatel@766 | 50 | * Constructor to construct an HTML document. |
bpatel@766 | 51 | * |
bpatel@766 | 52 | * @param docType document type for the HTML document |
bpatel@766 | 53 | * @param docComment comment for the document |
bpatel@766 | 54 | * @param htmlTree HTML tree of the document |
bpatel@766 | 55 | */ |
bpatel@766 | 56 | public HtmlDocument(Content docType, Content docComment, Content htmlTree) { |
bpatel@766 | 57 | docContent = new ArrayList<Content>(); |
bpatel@766 | 58 | addContent(nullCheck(docType)); |
bpatel@766 | 59 | addContent(nullCheck(docComment)); |
bpatel@766 | 60 | addContent(nullCheck(htmlTree)); |
bpatel@766 | 61 | } |
bpatel@766 | 62 | |
bpatel@766 | 63 | /** |
bpatel@766 | 64 | * Constructor to construct an HTML document. |
bpatel@766 | 65 | * |
bpatel@766 | 66 | * @param docType document type for the HTML document |
bpatel@766 | 67 | * @param htmlTree HTML tree of the document |
bpatel@766 | 68 | */ |
bpatel@766 | 69 | public HtmlDocument(Content docType, Content htmlTree) { |
bpatel@766 | 70 | docContent = new ArrayList<Content>(); |
bpatel@766 | 71 | addContent(nullCheck(docType)); |
bpatel@766 | 72 | addContent(nullCheck(htmlTree)); |
bpatel@766 | 73 | } |
bpatel@766 | 74 | |
bpatel@766 | 75 | /** |
bpatel@766 | 76 | * Adds content for the HTML document. |
bpatel@766 | 77 | * |
bpatel@766 | 78 | * @param htmlContent html content to be added |
bpatel@766 | 79 | */ |
jjg@1364 | 80 | public final void addContent(Content htmlContent) { |
bpatel@766 | 81 | if (htmlContent.isValid()) |
bpatel@766 | 82 | docContent.add(htmlContent); |
bpatel@766 | 83 | } |
bpatel@766 | 84 | |
bpatel@766 | 85 | /** |
bpatel@766 | 86 | * This method is not supported by the class. |
bpatel@766 | 87 | * |
bpatel@766 | 88 | * @param stringContent string content that needs to be added |
bpatel@766 | 89 | * @throws DocletAbortException this method will always throw a |
bpatel@766 | 90 | * DocletAbortException because it |
bpatel@766 | 91 | * is not supported. |
bpatel@766 | 92 | */ |
bpatel@766 | 93 | public void addContent(String stringContent) { |
bpatel@766 | 94 | throw new DocletAbortException(); |
bpatel@766 | 95 | } |
bpatel@766 | 96 | |
bpatel@766 | 97 | /** |
bpatel@766 | 98 | * {@inheritDoc} |
bpatel@766 | 99 | */ |
bpatel@766 | 100 | public boolean isEmpty() { |
bpatel@766 | 101 | return (docContent.isEmpty()); |
bpatel@766 | 102 | } |
bpatel@766 | 103 | |
bpatel@766 | 104 | /** |
bpatel@766 | 105 | * {@inheritDoc} |
bpatel@766 | 106 | */ |
jjg@1364 | 107 | public boolean write(Writer out, boolean atNewline) throws IOException { |
bpatel@766 | 108 | for (Content c : docContent) |
jjg@1364 | 109 | atNewline = c.write(out, atNewline); |
jjg@1364 | 110 | return atNewline; |
bpatel@766 | 111 | } |
bpatel@766 | 112 | } |