1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,155 @@ 1.4 +/* 1.5 + * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Sun designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Sun in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.26 + * have any questions. 1.27 + */ 1.28 + 1.29 +package com.sun.tools.doclets.internal.toolkit.taglets; 1.30 + 1.31 +import com.sun.javadoc.*; 1.32 + 1.33 +/** 1.34 + * The interface for a custom tag used by Doclets. A custom 1.35 + * tag must implement this interface. To be loaded and used by 1.36 + * doclets at run-time, the taglet must have a static method called 1.37 + * <code>register</code> that accepts a {@link java.util.Map} as an 1.38 + * argument with the following signature: 1.39 + * <pre> 1.40 + * public void register(Map map) 1.41 + * </pre> 1.42 + * This method should add an instance of the custom taglet to the map 1.43 + * with the name of the taglet as the key. If overriding a taglet, 1.44 + * to avoid a name conflict, the overridden taglet must be deleted from 1.45 + * the map before an instance of the new taglet is added to the map. 1.46 + * <p> 1.47 + * It is recommended that the taglet throw an exception when it fails 1.48 + * to register itself. The exception that it throws is up to the user. 1.49 + * <p> 1.50 + * Here are two sample taglets: <br> 1.51 + * <ul> 1.52 + * <li><a href="{@docRoot}/ToDoTaglet.java">ToDoTaglet.java</a> 1.53 + * - Standalone taglet</li> 1.54 + * <li><a href="{@docRoot}/UnderlineTaglet.java">UnderlineTaglet.java</a> 1.55 + * - Inline taglet</li> 1.56 + * </ul> 1.57 + * <p> 1.58 + * For more information on how to create your own Taglets, please see the 1.59 + * <a href="{@docRoot}/overview.html">Taglet Overview</a>. 1.60 + * 1.61 + * @since 1.4 1.62 + * @author Jamie Ho 1.63 + */ 1.64 + 1.65 +public interface Taglet { 1.66 + 1.67 + /** 1.68 + * Return true if this <code>Taglet</code> 1.69 + * is used in field documentation. 1.70 + * @return true if this <code>Taglet</code> 1.71 + * is used in field documentation and false 1.72 + * otherwise. 1.73 + */ 1.74 + public abstract boolean inField(); 1.75 + 1.76 + /** 1.77 + * Return true if this <code>Taglet</code> 1.78 + * is used in constructor documentation. 1.79 + * @return true if this <code>Taglet</code> 1.80 + * is used in constructor documentation and false 1.81 + * otherwise. 1.82 + */ 1.83 + public abstract boolean inConstructor(); 1.84 + 1.85 + /** 1.86 + * Return true if this <code>Taglet</code> 1.87 + * is used in method documentation. 1.88 + * @return true if this <code>Taglet</code> 1.89 + * is used in method documentation and false 1.90 + * otherwise. 1.91 + */ 1.92 + public abstract boolean inMethod(); 1.93 + 1.94 + /** 1.95 + * Return true if this <code>Taglet</code> 1.96 + * is used in overview documentation. 1.97 + * @return true if this <code>Taglet</code> 1.98 + * is used in method documentation and false 1.99 + * otherwise. 1.100 + */ 1.101 + public abstract boolean inOverview(); 1.102 + 1.103 + /** 1.104 + * Return true if this <code>Taglet</code> 1.105 + * is used in package documentation. 1.106 + * @return true if this <code>Taglet</code> 1.107 + * is used in package documentation and false 1.108 + * otherwise. 1.109 + */ 1.110 + public abstract boolean inPackage(); 1.111 + 1.112 + /** 1.113 + * Return true if this <code>Taglet</code> 1.114 + * is used in type documentation (classes or 1.115 + * interfaces). 1.116 + * @return true if this <code>Taglet</code> 1.117 + * is used in type documentation and false 1.118 + * otherwise. 1.119 + */ 1.120 + public abstract boolean inType(); 1.121 + 1.122 + /** 1.123 + * Return true if this <code>Taglet</code> 1.124 + * is an inline tag. Return false otherwise. 1.125 + * @return true if this <code>Taglet</code> 1.126 + * is an inline tag and false otherwise. 1.127 + */ 1.128 + public abstract boolean isInlineTag(); 1.129 + 1.130 + /** 1.131 + * Return the name of this custom tag. 1.132 + * @return the name of this custom tag. 1.133 + */ 1.134 + public abstract String getName(); 1.135 + 1.136 + /** 1.137 + * Given the <code>Tag</code> representation of this custom 1.138 + * tag, return its TagletOutput representation, which is output 1.139 + * to the generated page. 1.140 + * @param tag the <code>Tag</code> representation of this custom tag. 1.141 + * @param writer a {@link TagletWriter} Taglet writer. 1.142 + * @throws IllegalArgumentException thrown when the method is not supported by the taglet. 1.143 + * @return the TagletOutput representation of this <code>Tag</code>. 1.144 + */ 1.145 + public abstract TagletOutput getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException; 1.146 + 1.147 + /** 1.148 + * Given a <code>Doc</code> object, check if it holds any tags of 1.149 + * this type. If it does, return the string representing the output. 1.150 + * If it does not, return null. 1.151 + * @param holder a {@link Doc} object holding the custom tag. 1.152 + * @param writer a {@link TagletWriter} Taglet writer. 1.153 + * @throws IllegalArgumentException thrown when the method is not supported by the taglet. 1.154 + * @return the TagletOutput representation of this <code>Tag</code>. 1.155 + */ 1.156 + public abstract TagletOutput getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException; 1.157 + 1.158 +}