src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java

Tue, 14 May 2013 10:14:57 -0700

author
jjg
date
Tue, 14 May 2013 10:14:57 -0700
changeset 1751
ca8808c88f94
parent 1743
6a5288a298fd
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8012308: Remove TagletOutput in favor of direct use of Content
Reviewed-by: darcy

duke@1 1 /*
jjg@1743 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.internal.toolkit.taglets;
duke@1 27
duke@1 28 import com.sun.javadoc.*;
jjg@1751 29 import com.sun.tools.doclets.internal.toolkit.Content;
duke@1 30
duke@1 31 /**
duke@1 32 * The interface for a custom tag used by Doclets. A custom
duke@1 33 * tag must implement this interface. To be loaded and used by
duke@1 34 * doclets at run-time, the taglet must have a static method called
duke@1 35 * <code>register</code> that accepts a {@link java.util.Map} as an
duke@1 36 * argument with the following signature:
duke@1 37 * <pre>
duke@1 38 * public void register(Map map)
duke@1 39 * </pre>
duke@1 40 * This method should add an instance of the custom taglet to the map
duke@1 41 * with the name of the taglet as the key. If overriding a taglet,
duke@1 42 * to avoid a name conflict, the overridden taglet must be deleted from
duke@1 43 * the map before an instance of the new taglet is added to the map.
duke@1 44 * <p>
duke@1 45 * It is recommended that the taglet throw an exception when it fails
duke@1 46 * to register itself. The exception that it throws is up to the user.
duke@1 47 * <p>
duke@1 48 * Here are two sample taglets: <br>
duke@1 49 * <ul>
duke@1 50 * <li><a href="{@docRoot}/ToDoTaglet.java">ToDoTaglet.java</a>
duke@1 51 * - Standalone taglet</li>
duke@1 52 * <li><a href="{@docRoot}/UnderlineTaglet.java">UnderlineTaglet.java</a>
duke@1 53 * - Inline taglet</li>
duke@1 54 * </ul>
duke@1 55 * <p>
duke@1 56 * For more information on how to create your own Taglets, please see the
duke@1 57 * <a href="{@docRoot}/overview.html">Taglet Overview</a>.
duke@1 58 *
duke@1 59 * @since 1.4
duke@1 60 * @author Jamie Ho
duke@1 61 */
duke@1 62
duke@1 63 public interface Taglet {
duke@1 64
duke@1 65 /**
duke@1 66 * Return true if this <code>Taglet</code>
duke@1 67 * is used in field documentation.
duke@1 68 * @return true if this <code>Taglet</code>
duke@1 69 * is used in field documentation and false
duke@1 70 * otherwise.
duke@1 71 */
duke@1 72 public abstract boolean inField();
duke@1 73
duke@1 74 /**
duke@1 75 * Return true if this <code>Taglet</code>
duke@1 76 * is used in constructor documentation.
duke@1 77 * @return true if this <code>Taglet</code>
duke@1 78 * is used in constructor documentation and false
duke@1 79 * otherwise.
duke@1 80 */
duke@1 81 public abstract boolean inConstructor();
duke@1 82
duke@1 83 /**
duke@1 84 * Return true if this <code>Taglet</code>
duke@1 85 * is used in method documentation.
duke@1 86 * @return true if this <code>Taglet</code>
duke@1 87 * is used in method documentation and false
duke@1 88 * otherwise.
duke@1 89 */
duke@1 90 public abstract boolean inMethod();
duke@1 91
duke@1 92 /**
duke@1 93 * Return true if this <code>Taglet</code>
duke@1 94 * is used in overview documentation.
duke@1 95 * @return true if this <code>Taglet</code>
duke@1 96 * is used in method documentation and false
duke@1 97 * otherwise.
duke@1 98 */
duke@1 99 public abstract boolean inOverview();
duke@1 100
duke@1 101 /**
duke@1 102 * Return true if this <code>Taglet</code>
duke@1 103 * is used in package documentation.
duke@1 104 * @return true if this <code>Taglet</code>
duke@1 105 * is used in package documentation and false
duke@1 106 * otherwise.
duke@1 107 */
duke@1 108 public abstract boolean inPackage();
duke@1 109
duke@1 110 /**
duke@1 111 * Return true if this <code>Taglet</code>
duke@1 112 * is used in type documentation (classes or
duke@1 113 * interfaces).
duke@1 114 * @return true if this <code>Taglet</code>
duke@1 115 * is used in type documentation and false
duke@1 116 * otherwise.
duke@1 117 */
duke@1 118 public abstract boolean inType();
duke@1 119
duke@1 120 /**
duke@1 121 * Return true if this <code>Taglet</code>
duke@1 122 * is an inline tag. Return false otherwise.
duke@1 123 * @return true if this <code>Taglet</code>
duke@1 124 * is an inline tag and false otherwise.
duke@1 125 */
duke@1 126 public abstract boolean isInlineTag();
duke@1 127
duke@1 128 /**
duke@1 129 * Return the name of this custom tag.
duke@1 130 * @return the name of this custom tag.
duke@1 131 */
duke@1 132 public abstract String getName();
duke@1 133
duke@1 134 /**
duke@1 135 * Given the <code>Tag</code> representation of this custom
jjg@1751 136 * tag, return its Content representation, which is output
duke@1 137 * to the generated page.
duke@1 138 * @param tag the <code>Tag</code> representation of this custom tag.
duke@1 139 * @param writer a {@link TagletWriter} Taglet writer.
duke@1 140 * @throws IllegalArgumentException thrown when the method is not supported by the taglet.
jjg@1751 141 * @return the Content representation of this <code>Tag</code>.
duke@1 142 */
jjg@1751 143 public abstract Content getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException;
duke@1 144
duke@1 145 /**
duke@1 146 * Given a <code>Doc</code> object, check if it holds any tags of
duke@1 147 * this type. If it does, return the string representing the output.
duke@1 148 * If it does not, return null.
duke@1 149 * @param holder a {@link Doc} object holding the custom tag.
duke@1 150 * @param writer a {@link TagletWriter} Taglet writer.
duke@1 151 * @throws IllegalArgumentException thrown when the method is not supported by the taglet.
duke@1 152 * @return the TagletOutput representation of this <code>Tag</code>.
duke@1 153 */
jjg@1751 154 public abstract Content getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException;
duke@1 155
jjg@1743 156 @Override
jjg@1743 157 public abstract String toString();
duke@1 158 }

mercurial