src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java

Wed, 01 Dec 2010 11:02:38 -0800

author
bpatel
date
Wed, 01 Dec 2010 11:02:38 -0800
changeset 766
90af8d87741f
child 1359
25e14ad23cef
permissions
-rw-r--r--

6851834: Javadoc doclet needs a structured approach to generate the output HTML.
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2010, 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  */
    26 package com.sun.tools.doclets.formats.html.markup;
    28 /**
    29  * Enum representing HTML tags.
    30  *
    31  * @author Bhavesh Patel
    32  */
    33 public enum HtmlTag {
    34     A(BlockType.INLINE, EndTag.END),
    35     BLOCKQUOTE,
    36     BODY(BlockType.OTHER, EndTag.END),
    37     BR(BlockType.INLINE, EndTag.NOEND),
    38     CAPTION,
    39     CENTER,
    40     CODE(BlockType.INLINE, EndTag.END),
    41     DD,
    42     DIV,
    43     DL,
    44     DT,
    45     EM(BlockType.INLINE, EndTag.END),
    46     FONT(BlockType.INLINE, EndTag.END),
    47     FRAME(BlockType.OTHER, EndTag.NOEND),
    48     FRAMESET(BlockType.OTHER, EndTag.END),
    49     H1,
    50     H2,
    51     H3,
    52     H4,
    53     H5,
    54     H6,
    55     HEAD(BlockType.OTHER, EndTag.END),
    56     HR(BlockType.BLOCK, EndTag.NOEND),
    57     HTML(BlockType.OTHER, EndTag.END),
    58     I(BlockType.INLINE, EndTag.END),
    59     IMG(BlockType.INLINE, EndTag.NOEND),
    60     LI,
    61     LINK(BlockType.OTHER, EndTag.NOEND),
    62     MENU,
    63     META(BlockType.OTHER, EndTag.NOEND),
    64     NOFRAMES(BlockType.OTHER, EndTag.END),
    65     NOSCRIPT(BlockType.OTHER, EndTag.END),
    66     OL,
    67     P,
    68     PRE,
    69     SCRIPT(BlockType.OTHER, EndTag.END),
    70     SMALL(BlockType.INLINE, EndTag.END),
    71     SPAN(BlockType.INLINE, EndTag.END),
    72     STRONG(BlockType.INLINE, EndTag.END),
    73     TABLE,
    74     TBODY,
    75     TD,
    76     TH,
    77     TITLE(BlockType.OTHER, EndTag.END),
    78     TR,
    79     TT(BlockType.INLINE, EndTag.END),
    80     UL;
    82     protected final BlockType blockType;
    83     protected final EndTag endTag;
    84     private final String value;
    86     /**
    87      * Enum representing the type of HTML element.
    88      */
    89     protected static enum BlockType {
    90         BLOCK,
    91         INLINE,
    92         OTHER;
    93     }
    95     /**
    96      * Enum representing HTML end tag requirement.
    97      */
    98     protected static enum EndTag {
    99         END,
   100         NOEND;
   101     }
   103     HtmlTag() {
   104         this(BlockType.BLOCK, EndTag.END);
   105     }
   107     HtmlTag(BlockType blockType, EndTag endTag ) {
   108         this.blockType = blockType;
   109         this.endTag = endTag;
   110         this.value = name().toLowerCase();
   111     }
   113     /**
   114      * Returns true if the end tag is required. This is specific to the standard
   115      * doclet and does not exactly resemble the W3C specifications.
   116      *
   117      * @return true if end tag needs to be displayed else return false
   118      */
   119     public boolean endTagRequired() {
   120         return (endTag == EndTag.END);
   121     }
   123     public String toString() {
   124         return value;
   125     }
   126 }

mercurial