src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/DocFileElement.java
author jjg
Thu, 21 Nov 2019 13:41:24 -0800
changeset 59210 78184b74af6e
parent 48029 e9dab2492924
permissions -rw-r--r--
8234051: doclet crashes if HTML files in module doc-files directories Reviewed-by: hannesw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48029
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
     1
/*
59210
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
48029
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
     4
 *
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    10
 *
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    15
 * accompanied this code).
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    16
 *
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    20
 *
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    23
 * questions.
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    24
 */
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    25
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    26
package jdk.javadoc.internal.doclets.toolkit;
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    27
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    28
import javax.lang.model.element.Element;
59210
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    29
import javax.lang.model.element.ModuleElement;
48029
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    30
import javax.lang.model.element.PackageElement;
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    31
import javax.tools.FileObject;
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    32
59210
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    33
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
48029
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    34
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    35
/**
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    36
 * This is a pseudo element wrapper for doc-files html contents, essentially to
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    37
 * associate the doc-file's html documentation's DocCommentTree to an element.
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    38
 *
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    39
 *  <p><b>This is NOT part of any supported API.
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    40
 *  If you write code that depends on this, you do so at your own risk.
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    41
 *  This code and its internal interfaces are subject to change or
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    42
 *  deletion without notice.</b>
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    43
 */
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    44
public class DocFileElement implements DocletElement {
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    45
59210
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    46
    private final PackageElement packageElement;
48029
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    47
    private final FileObject fo;
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    48
59210
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    49
    public DocFileElement(Utils utils, Element element, FileObject fo) {
48029
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    50
        this.fo = fo;
59210
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    51
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    52
        switch(element.getKind()) {
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    53
            case MODULE:
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    54
                ModuleElement moduleElement = (ModuleElement) element;
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    55
                packageElement = utils.elementUtils.getPackageElement(moduleElement, "");
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    56
                break;
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    57
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    58
            case PACKAGE:
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    59
                packageElement = (PackageElement) element;
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    60
                break;
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    61
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    62
            default:
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    63
                throw new AssertionError("unknown kind: " + element.getKind());
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    64
        }
48029
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    65
    }
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    66
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    67
    @Override
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    68
    public PackageElement getPackageElement() {
59210
78184b74af6e 8234051: doclet crashes if HTML files in module doc-files directories
jjg
parents: 48029
diff changeset
    69
        return packageElement;
48029
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    70
    }
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    71
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    72
    @Override
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    73
    public FileObject getFileObject() {
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    74
        return fo;
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    75
    }
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    76
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    77
    @Override
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    78
    public Kind getSubKind() {
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    79
        return Kind.DOCFILE;
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    80
    }
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    81
}
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
diff changeset
    82