8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package jdk.javadoc.internal.doclets.toolkit.taglets; 27 28 import javax.lang.model.element.Element; 29 30 import com.sun.source.doctree.DocTree; 31 import jdk.javadoc.internal.doclets.toolkit.Content; 32 33 /** 34 * An abstract class for that implements the {@link Taglet} interface. 35 * 36 * <p><b>This is NOT part of any supported API. 37 * If you write code that depends on this, you do so at your own risk. 38 * This code and its internal interfaces are subject to change or 39 * deletion without notice.</b> 40 * 41 * @author Jamie Ho 42 */ 43 public abstract class BaseTaglet implements Taglet { 44 45 protected String name = "Default"; 46 47 /** 48 * Return true if this <code>Taglet</code> 49 * is used in constructor documentation. 50 * @return true if this <code>Taglet</code> 51 * is used in constructor documentation and false 52 * otherwise. 53 */ 54 public boolean inConstructor() { 55 return true; 56 } 57 58 /** 59 * Return true if this <code>Taglet</code> 60 * is used in field documentation. 61 * @return true if this <code>Taglet</code> 62 * is used in field documentation and false 63 * otherwise. 64 */ 65 public boolean inField() { 66 return true; 67 } 68 69 /** 70 * Return true if this <code>Taglet</code> 71 * is used in method documentation. 72 * @return true if this <code>Taglet</code> 73 * is used in method documentation and false 74 * otherwise. 75 */ 76 public boolean inMethod() { 77 return true; 78 } 79 80 /** 81 * Return true if this <code>Taglet</code> 82 * is used in overview documentation. 83 * @return true if this <code>Taglet</code> 84 * is used in method documentation and false 85 * otherwise. 86 */ 87 public boolean inOverview() { 88 return true; 89 } 90 91 /** 92 * Return true if this <code>Taglet</code> 93 * is used in module documentation. 94 * @return true if this <code>Taglet</code> 95 * is used in module documentation and false 96 * otherwise. 97 */ 98 public boolean inModule() { 99 return true; 100 } 101 102 /** 103 * Return true if this <code>Taglet</code> 104 * is used in package documentation. 105 * @return true if this <code>Taglet</code> 106 * is used in package documentation and false 107 * otherwise. 108 */ 109 public boolean inPackage() { 110 return true; 111 } 112 113 /** 114 * Return true if this <code>Taglet</code> 115 * is used in type documentation (classes or interfaces). 116 * @return true if this <code>Taglet</code> 117 * is used in type documentation and false 118 * otherwise. 119 */ 120 public boolean inType() { 121 return true; 122 } 123 124 /** 125 * Return true if this <code>Taglet</code> 126 * is an inline tag. 127 * @return true if this <code>Taglet</code> 128 * is an inline tag and false otherwise. 129 */ 130 public boolean isInlineTag() { 131 return false; 132 } 133 134 /** 135 * Return the name of this custom tag. 136 * @return the name of this custom tag. 137 */ 138 public String getName() { 139 return name; 140 } 141 142 /** 143 * {@inheritDoc} 144 * @throws UnsupportedTagletOperationException thrown when the method is 145 * not supported by the taglet. 146 */ 147 public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer) { 148 throw new UnsupportedTagletOperationException("Method not supported in taglet " + getName() + "."); 149 } 150 151 /** 152 * {@inheritDoc} 153 * @throws UnsupportedTagletOperationException thrown when the method is not 154 * supported by the taglet. 155 */ 156 public Content getTagletOutput(Element holder, TagletWriter writer) { | 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package jdk.javadoc.internal.doclets.toolkit.taglets; 27 28 import java.util.Set; 29 import javax.lang.model.element.Element; 30 31 import com.sun.source.doctree.DocTree; 32 import jdk.javadoc.internal.doclets.toolkit.Content; 33 34 /** 35 * A base class that implements the {@link Taglet} interface. 36 * 37 * <p><b>This is NOT part of any supported API. 38 * If you write code that depends on this, you do so at your own risk. 39 * This code and its internal interfaces are subject to change or 40 * deletion without notice.</b> 41 * 42 * @author Jamie Ho 43 */ 44 public class BaseTaglet implements Taglet { 45 /** 46 * The different kinds of place where any given tag may be used. 47 */ 48 enum Site { 49 OVERVIEW, MODULE, PACKAGE, TYPE, CONSTRUCTOR, METHOD, FIELD 50 } 51 52 protected final String name; 53 private final boolean inline; 54 private final Set<Site> sites; 55 56 BaseTaglet(String name, boolean inline, Set<Site> sites) { 57 this.name = name; 58 this.inline = inline; 59 this.sites = sites; 60 } 61 62 /** 63 * Returns true if this {@code Taglet} can be used in constructor documentation. 64 * @return true if this {@code Taglet} can be used in constructor documentation and false 65 * otherwise. 66 */ 67 public final boolean inConstructor() { 68 return sites.contains(Site.CONSTRUCTOR); 69 } 70 71 /** 72 * Returns true if this {@code Taglet} can be used in field documentation. 73 * @return true if this {@code Taglet} can be used in field documentation and false 74 * otherwise. 75 */ 76 public final boolean inField() { 77 return sites.contains(Site.FIELD); 78 } 79 80 /** 81 * Returns true if this {@code Taglet} can be used in method documentation. 82 * @return true if this {@code Taglet} can be used in method documentation and false 83 * otherwise. 84 */ 85 public final boolean inMethod() { 86 return sites.contains(Site.METHOD); 87 } 88 89 /** 90 * Returns true if this {@code Taglet} can be used in overview documentation. 91 * @return true if this {@code Taglet} can be used in method documentation and false 92 * otherwise. 93 */ 94 public final boolean inOverview() { 95 return sites.contains(Site.OVERVIEW); 96 } 97 98 /** 99 * Returns true if this {@code Taglet} can be used in module documentation. 100 * @return true if this {@code Taglet} can be used in module documentation and false 101 * otherwise. 102 */ 103 public final boolean inModule() { 104 return sites.contains(Site.MODULE); 105 } 106 107 /** 108 * Returns true if this {@code Taglet} can be used in package documentation. 109 * @return true if this {@code Taglet} can be used in package documentation and false 110 * otherwise. 111 */ 112 public final boolean inPackage() { 113 return sites.contains(Site.PACKAGE); 114 } 115 116 /** 117 * Returns true if this {@code Taglet} can be used in type documentation (classes or interfaces). 118 * @return true if this {@code Taglet} can be used in type documentation and false 119 * otherwise. 120 */ 121 public final boolean inType() { 122 return sites.contains(Site.TYPE); 123 } 124 125 /** 126 * Returns true if this {@code Taglet} is an inline tag. 127 * @return true if this {@code Taglet} represents an inline tag and false otherwise. 128 */ 129 public final boolean isInlineTag() { 130 return inline; 131 } 132 133 /** 134 * Returns the name of this tag. 135 * @return the name of this tag. 136 */ 137 public String getName() { 138 return name; 139 } 140 141 /** 142 * {@inheritDoc} 143 * @throws UnsupportedTagletOperationException thrown when the method is 144 * not supported by the taglet. 145 */ 146 public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer) { 147 throw new UnsupportedTagletOperationException("Method not supported in taglet " + getName() + "."); 148 } 149 150 /** 151 * {@inheritDoc} 152 * @throws UnsupportedTagletOperationException thrown when the method is not 153 * supported by the taglet. 154 */ 155 public Content getTagletOutput(Element holder, TagletWriter writer) { |