1/* 2 * Copyright (c) 2003, 2017, 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. 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 * 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. 22 */ 23 24import java.util.EnumSet; 25import java.util.List; 26import java.util.Set; 27import javax.lang.model.element.Element; 28 29import com.sun.source.doctree.DocTree; 30import jdk.javadoc.doclet.Taglet; 31import static jdk.javadoc.doclet.Taglet.Location.*; 32 33/** 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>. 37 * 38 * @author Jamie Ho 39 * @since 1.4 40 */ 41 42public class UnderlineTaglet implements Taglet { 43 44 private final String NAME = "underline"; 45 46 /** 47 * Return the name of this custom tag. 48 */ 49 @Override 50 public String getName() { 51 return NAME; 52 } 53 private final EnumSet<Location> allowedSet = EnumSet.of(CONSTRUCTOR); 54 55 @Override 56 public Set<Taglet.Location> getAllowedLocations() { 57 return allowedSet; 58 } 59 60 /** 61 * Will return true since this is an inline tag. 62 * @return true since this is an inline tag. 63 */ 64 65 @Override 66 public boolean isInlineTag() { 67 return true; 68 } 69 70 /** 71 * Given the <code>DocTree</code> representation of this custom 72 * tag, return its string representation. 73 * @param tags the <code>DocTree</code> representation of this custom tag. 74 * @param element the declaration to which the enclosing comment belongs 75 */ 76 @Override 77 public String toString(List<? extends DocTree> tags, Element element) { 78 return "<u>" + ToDoTaglet.getText(tags.get(0)) + "</u>"; 79 } 80} 81