test/com/sun/javadoc/testLegacyTaglet/Check.java

Fri, 30 Aug 2013 16:16:28 -0700

author
bpatel
date
Fri, 30 Aug 2013 16:16:28 -0700
changeset 1996
7a2fe98cb0e6
child 2147
130b8c0e570e
permissions
-rw-r--r--

8015882: Javadoc prints NPE when using Taglet
Reviewed-by: jjg

bpatel@1996 1 /*
bpatel@1996 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
bpatel@1996 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bpatel@1996 4 *
bpatel@1996 5 * This code is free software; you can redistribute it and/or modify it
bpatel@1996 6 * under the terms of the GNU General Public License version 2 only, as
bpatel@1996 7 * published by the Free Software Foundation.
bpatel@1996 8 *
bpatel@1996 9 * This code is distributed in the hope that it will be useful, but WITHOUT
bpatel@1996 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bpatel@1996 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bpatel@1996 12 * version 2 for more details (a copy is included in the LICENSE file that
bpatel@1996 13 * accompanied this code).
bpatel@1996 14 *
bpatel@1996 15 * You should have received a copy of the GNU General Public License version
bpatel@1996 16 * 2 along with this work; if not, write to the Free Software Foundation,
bpatel@1996 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bpatel@1996 18 *
bpatel@1996 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bpatel@1996 20 * or visit www.oracle.com if you need additional information or have any
bpatel@1996 21 * questions.
bpatel@1996 22 */
bpatel@1996 23
bpatel@1996 24 import com.sun.tools.doclets.Taglet;
bpatel@1996 25 import com.sun.javadoc.*;
bpatel@1996 26 import java.util.Map;
bpatel@1996 27
bpatel@1996 28 public class Check implements Taglet {
bpatel@1996 29
bpatel@1996 30 private static final String TAG_NAME = "check";
bpatel@1996 31 private static final String TAG_HEADER = "Check:";
bpatel@1996 32
bpatel@1996 33 /**
bpatel@1996 34 * Return true since the tag can be used in package documentation.
bpatel@1996 35 *
bpatel@1996 36 * @return true since the tag can be used in package documentation.
bpatel@1996 37 */
bpatel@1996 38 public boolean inPackage() {
bpatel@1996 39 return true;
bpatel@1996 40 }
bpatel@1996 41
bpatel@1996 42 /**
bpatel@1996 43 * Return true since the tag can be used in overview documentation.
bpatel@1996 44 *
bpatel@1996 45 * @return true since the tag can be used in overview documentation.
bpatel@1996 46 */
bpatel@1996 47 public boolean inOverview() {
bpatel@1996 48 return true;
bpatel@1996 49 }
bpatel@1996 50
bpatel@1996 51 /**
bpatel@1996 52 * Return true since the tag can be used in type (class/interface)
bpatel@1996 53 * documentation.
bpatel@1996 54 *
bpatel@1996 55 * @return true since the tag can be used in type (class/interface)
bpatel@1996 56 * documentation.
bpatel@1996 57 */
bpatel@1996 58 public boolean inType() {
bpatel@1996 59 return true;
bpatel@1996 60 }
bpatel@1996 61
bpatel@1996 62 /**
bpatel@1996 63 * Return true since the tag can be used in constructor documentation.
bpatel@1996 64 *
bpatel@1996 65 * @return true since the tag can be used in constructor documentation.
bpatel@1996 66 */
bpatel@1996 67 public boolean inConstructor() {
bpatel@1996 68 return true;
bpatel@1996 69 }
bpatel@1996 70
bpatel@1996 71 /**
bpatel@1996 72 * Return true since the tag can be used in field documentation.
bpatel@1996 73 *
bpatel@1996 74 * @return true since the tag can be used in field documentation.
bpatel@1996 75 */
bpatel@1996 76 public boolean inField() {
bpatel@1996 77 return true;
bpatel@1996 78 }
bpatel@1996 79
bpatel@1996 80 /**
bpatel@1996 81 * Return true since the tag can be used in method documentation.
bpatel@1996 82 *
bpatel@1996 83 * @return true since the tag can be used in method documentation.
bpatel@1996 84 */
bpatel@1996 85 public boolean inMethod() {
bpatel@1996 86 return true;
bpatel@1996 87 }
bpatel@1996 88
bpatel@1996 89 /**
bpatel@1996 90 * Return false since the tag is not an inline tag.
bpatel@1996 91 *
bpatel@1996 92 * @return false since the tag is not an inline tag.
bpatel@1996 93 */
bpatel@1996 94 public boolean isInlineTag() {
bpatel@1996 95 return false;
bpatel@1996 96 }
bpatel@1996 97
bpatel@1996 98 /**
bpatel@1996 99 * Register this taglet.
bpatel@1996 100 *
bpatel@1996 101 * @param tagletMap the map to register this tag to.
bpatel@1996 102 */
bpatel@1996 103 @SuppressWarnings("unchecked")
bpatel@1996 104 public static void register(Map tagletMap) {
bpatel@1996 105 Check tag = new Check();
bpatel@1996 106 Taglet t = (Taglet) tagletMap.get(tag.getName());
bpatel@1996 107 if (t != null) {
bpatel@1996 108 tagletMap.remove(tag.getName());
bpatel@1996 109 }
bpatel@1996 110 tagletMap.put(tag.getName(), tag);
bpatel@1996 111 }
bpatel@1996 112
bpatel@1996 113 /**
bpatel@1996 114 * Return the name of this custom tag.
bpatel@1996 115 *
bpatel@1996 116 * @return the name of this tag.
bpatel@1996 117 */
bpatel@1996 118 public String getName() {
bpatel@1996 119 return TAG_NAME;
bpatel@1996 120 }
bpatel@1996 121
bpatel@1996 122 /**
bpatel@1996 123 * Given the tag representation of this custom tag, return its string
bpatel@1996 124 * representation.
bpatel@1996 125 *
bpatel@1996 126 * @param tag the tag representation of this custom tag.
bpatel@1996 127 */
bpatel@1996 128 public String toString(Tag tag) {
bpatel@1996 129 return "<dt><span class=\"strong\">" + TAG_HEADER + ":</span></dt><dd>" + tag.text() +
bpatel@1996 130 "</dd>\n";
bpatel@1996 131 }
bpatel@1996 132
bpatel@1996 133 /**
bpatel@1996 134 * Given an array of tags representing this custom tag, return its string
bpatel@1996 135 * representation.
bpatel@1996 136 *
bpatel@1996 137 * @param tags the array of tags representing of this custom tag.
bpatel@1996 138 * @return null to test if the javadoc throws an exception or not.
bpatel@1996 139 */
bpatel@1996 140 public String toString(Tag[] tags) {
bpatel@1996 141 return null;
bpatel@1996 142 }
bpatel@1996 143 }

mercurial