HtmlTag.java revision 3233:b5d08bc0d224
1219019Sgabor/* 2219019Sgabor * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. 3219019Sgabor * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4219019Sgabor * 5219019Sgabor * This code is free software; you can redistribute it and/or modify it 6219019Sgabor * under the terms of the GNU General Public License version 2 only, as 7219019Sgabor * published by the Free Software Foundation. Oracle designates this 8219019Sgabor * particular file as subject to the "Classpath" exception as provided 9219019Sgabor * by Oracle in the LICENSE file that accompanied this code. 10219019Sgabor * 11219019Sgabor * This code is distributed in the hope that it will be useful, but WITHOUT 12219019Sgabor * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13219019Sgabor * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14219019Sgabor * version 2 for more details (a copy is included in the LICENSE file that 15219019Sgabor * accompanied this code). 16219019Sgabor * 17219019Sgabor * You should have received a copy of the GNU General Public License version 18219019Sgabor * 2 along with this work; if not, write to the Free Software Foundation, 19219019Sgabor * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20219019Sgabor * 21219019Sgabor * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22219019Sgabor * or visit www.oracle.com if you need additional information or have any 23219019Sgabor * questions. 24219019Sgabor */ 25219019Sgabor 26219019Sgaborpackage jdk.javadoc.internal.doclets.formats.html.markup; 27219019Sgabor 28219019Sgaborimport jdk.javadoc.internal.doclets.toolkit.util.Utils; 29219019Sgabor 30219019Sgabor/** 31219019Sgabor * Enum representing HTML tags. 32219019Sgabor * 33219019Sgabor * <p><b>This is NOT part of any supported API. 34219019Sgabor * If you write code that depends on this, you do so at your own risk. 35219019Sgabor * This code and its internal interfaces are subject to change or 36219019Sgabor * deletion without notice.</b> 37219019Sgabor * 38219019Sgabor * @author Bhavesh Patel 39219019Sgabor */ 40219019Sgaborpublic enum HtmlTag { 41219019Sgabor A(BlockType.INLINE, EndTag.END), 42219019Sgabor BLOCKQUOTE, 43219019Sgabor BODY(BlockType.OTHER, EndTag.END), 44219019Sgabor BR(BlockType.INLINE, EndTag.NOEND), 45219019Sgabor CAPTION, 46219019Sgabor CENTER(HtmlVersion.HTML4), 47219019Sgabor CODE(BlockType.INLINE, EndTag.END), 48219019Sgabor DD, 49219019Sgabor DIR(HtmlVersion.HTML4), 50219019Sgabor DIV, 51219019Sgabor DL, 52219019Sgabor DT, 53219019Sgabor EM(BlockType.INLINE, EndTag.END), 54219019Sgabor FONT(HtmlVersion.HTML4, BlockType.INLINE, EndTag.END), 55219019Sgabor FOOTER(HtmlVersion.HTML5), 56219019Sgabor H1, 57219019Sgabor H2, 58219019Sgabor H3, 59219019Sgabor H4, 60219019Sgabor H5, 61219019Sgabor H6, 62219019Sgabor HEAD(BlockType.OTHER, EndTag.END), 63219019Sgabor HEADER(HtmlVersion.HTML5), 64219019Sgabor HR(BlockType.BLOCK, EndTag.NOEND), 65219019Sgabor HTML(BlockType.OTHER, EndTag.END), 66219019Sgabor I(BlockType.INLINE, EndTag.END), 67219019Sgabor IFRAME(BlockType.OTHER, EndTag.END), 68219019Sgabor IMG(BlockType.INLINE, EndTag.NOEND), 69219019Sgabor INPUT(BlockType.BLOCK, EndTag.NOEND), 70219019Sgabor LI, 71219019Sgabor LISTING, 72219019Sgabor LINK(BlockType.OTHER, EndTag.NOEND), 73219019Sgabor MAIN(HtmlVersion.HTML5), 74219019Sgabor MENU, 75219019Sgabor META(BlockType.OTHER, EndTag.NOEND), 76219019Sgabor NAV(HtmlVersion.HTML5), 77219019Sgabor NOSCRIPT(BlockType.OTHER, EndTag.END), 78219019Sgabor OL, 79219019Sgabor P, 80219019Sgabor PRE, 81219019Sgabor SCRIPT(BlockType.OTHER, EndTag.END), 82219019Sgabor SECTION(HtmlVersion.HTML5), 83219019Sgabor SMALL(BlockType.INLINE, EndTag.END), 84219019Sgabor SPAN(BlockType.INLINE, EndTag.END), 85219019Sgabor STRONG(BlockType.INLINE, EndTag.END), 86219019Sgabor SUB(BlockType.INLINE, EndTag.END), 87219019Sgabor TABLE, 88219019Sgabor TBODY, 89219019Sgabor TD, 90219019Sgabor TH, 91219019Sgabor TITLE(BlockType.OTHER, EndTag.END), 92219019Sgabor TR, 93219019Sgabor TT(HtmlVersion.HTML4, BlockType.INLINE, EndTag.END), 94219019Sgabor UL; 95219019Sgabor 96219019Sgabor public final BlockType blockType; 97219019Sgabor public final EndTag endTag; 98219019Sgabor public final String value; 99219019Sgabor public final HtmlVersion htmlVersion; 100219019Sgabor 101219019Sgabor /** 102219019Sgabor * Enum representing the type of HTML element. 103219019Sgabor */ 104219019Sgabor public static enum BlockType { 105219019Sgabor BLOCK, 106219019Sgabor INLINE, 107219019Sgabor OTHER 108219019Sgabor } 109219019Sgabor 110219019Sgabor /** 111219019Sgabor * Enum representing HTML end tag requirement. 112219019Sgabor */ 113219019Sgabor public static enum EndTag { 114219019Sgabor END, 115219019Sgabor NOEND 116219019Sgabor } 117219019Sgabor 118219019Sgabor HtmlTag() { 119219019Sgabor this(HtmlVersion.ALL, BlockType.BLOCK, EndTag.END); 120219019Sgabor } 121219019Sgabor 122219019Sgabor HtmlTag(HtmlVersion htmlVersion) { 123219019Sgabor this(htmlVersion, BlockType.BLOCK, EndTag.END); 124219019Sgabor } 125219019Sgabor 126219019Sgabor HtmlTag(BlockType blockType, EndTag endTag ) { 127219019Sgabor this(HtmlVersion.ALL, blockType, endTag); 128219019Sgabor } 129219019Sgabor 130219019Sgabor HtmlTag(HtmlVersion htmlVersion, BlockType blockType, EndTag endTag ) { 131219019Sgabor this.htmlVersion = htmlVersion; 132219019Sgabor this.blockType = blockType; 133219019Sgabor this.endTag = endTag; 134219019Sgabor this.value = Utils.toLowerCase(name()); 135219019Sgabor } 136219019Sgabor 137219019Sgabor /** 138219019Sgabor * Returns true if the end tag is required. This is specific to the standard 139219019Sgabor * doclet and does not exactly resemble the W3C specifications. 140219019Sgabor * 141219019Sgabor * @return true if end tag needs to be displayed else return false 142219019Sgabor */ 143219019Sgabor public boolean endTagRequired() { 144219019Sgabor return (endTag == EndTag.END); 145219019Sgabor } 146219019Sgabor 147219019Sgabor /** 148219019Sgabor * Returns true if the tag is allowed in the output HTML version of this javadoc run. 149219019Sgabor * 150219019Sgabor * @param htmlVer the output HTML version for this javadoc run 151219019Sgabor * @return true if the tag is allowed 152219019Sgabor */ 153219019Sgabor public boolean allowTag(HtmlVersion htmlVer) { 154219019Sgabor return (this.htmlVersion == HtmlVersion.ALL || this.htmlVersion == htmlVer); 155219019Sgabor } 156219019Sgabor 157219019Sgabor public String toString() { 158219019Sgabor return value; 159219019Sgabor } 160219019Sgabor} 161219019Sgabor