1/* 2 * Copyright (c) 2010, 2015, 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 26package jdk.javadoc.internal.doclets.formats.html.markup; 27 28import jdk.javadoc.internal.doclets.toolkit.util.Utils; 29 30/** 31 * Enum representing HTML tags. 32 * 33 * <p><b>This is NOT part of any supported API. 34 * If you write code that depends on this, you do so at your own risk. 35 * This code and its internal interfaces are subject to change or 36 * deletion without notice.</b> 37 * 38 * @author Bhavesh Patel 39 */ 40public enum HtmlTag { 41 A(BlockType.INLINE, EndTag.END), 42 BLOCKQUOTE, 43 BODY(BlockType.OTHER, EndTag.END), 44 BR(BlockType.INLINE, EndTag.NOEND), 45 CAPTION, 46 CENTER(HtmlVersion.HTML4), 47 CODE(BlockType.INLINE, EndTag.END), 48 DD, 49 DIR(HtmlVersion.HTML4), 50 DIV, 51 DL, 52 DT, 53 EM(BlockType.INLINE, EndTag.END), 54 FONT(HtmlVersion.HTML4, BlockType.INLINE, EndTag.END), 55 FOOTER(HtmlVersion.HTML5), 56 H1, 57 H2, 58 H3, 59 H4, 60 H5, 61 H6, 62 HEAD(BlockType.OTHER, EndTag.END), 63 HEADER(HtmlVersion.HTML5), 64 HR(BlockType.BLOCK, EndTag.NOEND), 65 HTML(BlockType.OTHER, EndTag.END), 66 I(BlockType.INLINE, EndTag.END), 67 IFRAME(BlockType.OTHER, EndTag.END), 68 IMG(BlockType.INLINE, EndTag.NOEND), 69 INPUT(BlockType.BLOCK, EndTag.NOEND), 70 LI, 71 LISTING, 72 LINK(BlockType.OTHER, EndTag.NOEND), 73 MAIN(HtmlVersion.HTML5), 74 MENU, 75 META(BlockType.OTHER, EndTag.NOEND), 76 NAV(HtmlVersion.HTML5), 77 NOSCRIPT(BlockType.OTHER, EndTag.END), 78 OL, 79 P, 80 PRE, 81 SCRIPT(BlockType.OTHER, EndTag.END), 82 SECTION(HtmlVersion.HTML5), 83 SMALL(BlockType.INLINE, EndTag.END), 84 SPAN(BlockType.INLINE, EndTag.END), 85 STRONG(BlockType.INLINE, EndTag.END), 86 SUB(BlockType.INLINE, EndTag.END), 87 TABLE, 88 TBODY, 89 TD, 90 TH, 91 TITLE(BlockType.OTHER, EndTag.END), 92 TR, 93 TT(HtmlVersion.HTML4, BlockType.INLINE, EndTag.END), 94 UL; 95 96 public final BlockType blockType; 97 public final EndTag endTag; 98 public final String value; 99 public final HtmlVersion htmlVersion; 100 101 /** 102 * Enum representing the type of HTML element. 103 */ 104 public static enum BlockType { 105 BLOCK, 106 INLINE, 107 OTHER 108 } 109 110 /** 111 * Enum representing HTML end tag requirement. 112 */ 113 public static enum EndTag { 114 END, 115 NOEND 116 } 117 118 HtmlTag() { 119 this(HtmlVersion.ALL, BlockType.BLOCK, EndTag.END); 120 } 121 122 HtmlTag(HtmlVersion htmlVersion) { 123 this(htmlVersion, BlockType.BLOCK, EndTag.END); 124 } 125 126 HtmlTag(BlockType blockType, EndTag endTag ) { 127 this(HtmlVersion.ALL, blockType, endTag); 128 } 129 130 HtmlTag(HtmlVersion htmlVersion, BlockType blockType, EndTag endTag ) { 131 this.htmlVersion = htmlVersion; 132 this.blockType = blockType; 133 this.endTag = endTag; 134 this.value = Utils.toLowerCase(name()); 135 } 136 137 /** 138 * Returns true if the end tag is required. This is specific to the standard 139 * doclet and does not exactly resemble the W3C specifications. 140 * 141 * @return true if end tag needs to be displayed else return false 142 */ 143 public boolean endTagRequired() { 144 return (endTag == EndTag.END); 145 } 146 147 /** 148 * Returns true if the tag is allowed in the output HTML version of this javadoc run. 149 * 150 * @param htmlVer the output HTML version for this javadoc run 151 * @return true if the tag is allowed 152 */ 153 public boolean allowTag(HtmlVersion htmlVer) { 154 return (this.htmlVersion == HtmlVersion.ALL || this.htmlVersion == htmlVer); 155 } 156 157 public String toString() { 158 return value; 159 } 160} 161