langtools/test/jdk/javadoc/doclet/testLegacyTaglet/UnderlineTaglet.java
author jjg
Thu, 23 Mar 2017 10:58:16 -0700
changeset 44388 4d0903f1f311
parent 44189 dd311cfb920b
permissions -rw-r--r--
8176836: Provide Taglet with context Reviewed-by: ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 35426
diff changeset
     2
 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    24
import java.util.EnumSet;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    25
import java.util.List;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    26
import java.util.Set;
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    27
import javax.lang.model.element.Element;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    28
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    29
import com.sun.source.doctree.DocTree;
44189
dd311cfb920b 8176331: Simplify new doclet packages
jjg
parents: 44180
diff changeset
    30
import jdk.javadoc.doclet.Taglet;
dd311cfb920b 8176331: Simplify new doclet packages
jjg
parents: 44180
diff changeset
    31
import static jdk.javadoc.doclet.Taglet.Location.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
/**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    34
 * A sample Inline Taglet representing {@underline ...}.  The text
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    35
 * is simple underlined.  For example, "@underline UNDERLINE ME" would
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    36
 * be shown as: <u>UNDERLINE ME</u>.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @since 1.4
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
public class UnderlineTaglet implements Taglet {
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    44
    private final String NAME = "underline";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
     * Return the name of this custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    49
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    public String getName() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        return NAME;
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    53
    private final EnumSet<Location> allowedSet = EnumSet.of(CONSTRUCTOR);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    55
    @Override
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    56
    public Set<Taglet.Location> getAllowedLocations() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    57
        return allowedSet;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * Will return true since this is an inline tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * @return true since this is an inline tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    65
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    public boolean isInlineTag() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    71
     * Given the <code>DocTree</code> representation of this custom
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    72
     * tag, return its string representation.
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 35426
diff changeset
    73
     * @param tags the <code>DocTree</code> representation of this custom tag.
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    74
     * @param element the declaration to which the enclosing comment belongs
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 5520
diff changeset
    76
    @Override
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    77
    public String toString(List<? extends DocTree> tags, Element element) {
44180
207e05e0d9ad 8176131: Simplify new Taglet API
jjg
parents: 35426
diff changeset
    78
        return "<u>" + ToDoTaglet.getText(tags.get(0)) + "</u>";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
}