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