10
|
1 |
/*
|
44180
|
2 |
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
10
|
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.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
5520
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
10
|
22 |
*/
|
|
23 |
|
35426
|
24 |
import java.util.EnumSet;
|
|
25 |
import java.util.List;
|
|
26 |
import java.util.Set;
|
44388
|
27 |
import javax.lang.model.element.Element;
|
35426
|
28 |
|
|
29 |
import com.sun.source.doctree.DocTree;
|
44189
|
30 |
import jdk.javadoc.doclet.Taglet;
|
|
31 |
import static jdk.javadoc.doclet.Taglet.Location.*;
|
10
|
32 |
|
|
33 |
/**
|
35426
|
34 |
* A sample Inline Taglet representing {@underline ...}. The text
|
|
35 |
* is simple underlined. For example, "@underline UNDERLINE ME" would
|
|
36 |
* be shown as: <u>UNDERLINE ME</u>.
|
10
|
37 |
*
|
|
38 |
* @author Jamie Ho
|
|
39 |
* @since 1.4
|
|
40 |
*/
|
|
41 |
|
|
42 |
public class UnderlineTaglet implements Taglet {
|
|
43 |
|
35426
|
44 |
private final String NAME = "underline";
|
10
|
45 |
|
|
46 |
/**
|
|
47 |
* Return the name of this custom tag.
|
|
48 |
*/
|
35426
|
49 |
@Override
|
10
|
50 |
public String getName() {
|
|
51 |
return NAME;
|
|
52 |
}
|
35426
|
53 |
private final EnumSet<Location> allowedSet = EnumSet.of(CONSTRUCTOR);
|
10
|
54 |
|
35426
|
55 |
@Override
|
|
56 |
public Set<Taglet.Location> getAllowedLocations() {
|
|
57 |
return allowedSet;
|
10
|
58 |
}
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Will return true since this is an inline tag.
|
|
62 |
* @return true since this is an inline tag.
|
|
63 |
*/
|
|
64 |
|
35426
|
65 |
@Override
|
10
|
66 |
public boolean isInlineTag() {
|
|
67 |
return true;
|
|
68 |
}
|
|
69 |
|
|
70 |
/**
|
35426
|
71 |
* Given the <code>DocTree</code> representation of this custom
|
|
72 |
* tag, return its string representation.
|
44180
|
73 |
* @param tags the <code>DocTree</code> representation of this custom tag.
|
44388
|
74 |
* @param element the declaration to which the enclosing comment belongs
|
10
|
75 |
*/
|
35426
|
76 |
@Override
|
44388
|
77 |
public String toString(List<? extends DocTree> tags, Element element) {
|
44180
|
78 |
return "<u>" + ToDoTaglet.getText(tags.get(0)) + "</u>";
|
10
|
79 |
}
|
|
80 |
}
|