1 /* 2 * Copyright (c) 2003, 2016, 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. Oracle designates this 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 * This is the Taglet interface used internally within the doclet. 35 * 36 * @since 1.4 37 * @author Jamie Ho 38 */ 39 40 public interface Taglet { 41 42 /** 43 * Return true if this <code>Taglet</code> 44 * is used in field documentation. 45 * @return true if this <code>Taglet</code> 46 * is used in field documentation and false 47 * otherwise. 48 */ 49 public abstract boolean inField(); 50 51 /** 52 * Return true if this <code>Taglet</code> 53 * is used in constructor documentation. 54 * @return true if this <code>Taglet</code> 55 * is used in constructor documentation and false 56 * otherwise. 57 */ 58 public abstract boolean inConstructor(); 59 60 /** 61 * Return true if this <code>Taglet</code> 62 * is used in method documentation. 63 * @return true if this <code>Taglet</code> 64 * is used in method documentation and false 65 * otherwise. 66 */ 67 public abstract boolean inMethod(); 68 69 /** 70 * Return true if this <code>Taglet</code> 71 * is used in overview documentation. 72 * @return true if this <code>Taglet</code> 73 * is used in method documentation and false 74 * otherwise. 75 */ 76 public abstract boolean inOverview(); 77 78 /** 79 * Return true if this <code>Taglet</code> 80 * is used in package documentation. 81 * @return true if this <code>Taglet</code> 82 * is used in package documentation and false 83 * otherwise. 84 */ 85 public abstract boolean inPackage(); 86 87 /** 88 * Return true if this <code>Taglet</code> 89 * is used in type documentation (classes or 90 * interfaces). 91 * @return true if this <code>Taglet</code> 92 * is used in type documentation and false 93 * otherwise. 94 */ 95 public abstract boolean inType(); 96 97 /** 98 * Return true if this <code>Taglet</code> 99 * is an inline tag. Return false otherwise. 100 * @return true if this <code>Taglet</code> 101 * is an inline tag and false otherwise. 102 */ 103 public abstract boolean isInlineTag(); 104 105 /** 106 * Return the name of this custom tag. 107 * @return the name of this custom tag. 108 */ 109 public abstract String getName(); 110 111 /** 112 * Given the <code>Tag</code> representation of this custom 113 * tag, return its Content representation, which is output 114 * to the generated page. 115 * @param holder the element holding the tag 116 * @param tag the <code>Tag</code> representation of this custom tag. 117 * @param writer a {@link TagletWriter} Taglet writer. 118 * @throws UnsupportedOperationException thrown when the method is not supported by the taglet. 119 * @return the Content representation of this <code>Tag</code>. 120 */ 121 public abstract Content getTagletOutput(Element holder, DocTree tag, TagletWriter writer) throws 122 UnsupportedOperationException; 123 124 /** 125 * Given a <code>Doc</code> object, check if it holds any tags of 126 * this type. If it does, return the string representing the output. 127 * If it does not, return null. 128 * @param holder a {@link Doc} object holding the custom tag. 129 * @param writer a {@link TagletWriter} Taglet writer. 130 * @throws UnsupportedTagletOperationException thrown when the method is not 131 * supported by the taglet. 132 * @return the TagletOutput representation of this <code>Tag</code>. 133 */ 134 public abstract Content getTagletOutput(Element holder, TagletWriter writer) throws 135 UnsupportedTagletOperationException; 136 137 @Override 138 public abstract String toString(); 139 140 static class UnsupportedTagletOperationException extends UnsupportedOperationException { 141 private static final long serialVersionUID = -3530273193380250271L; 142 public UnsupportedTagletOperationException(String message) { 143 super(message); 144 } 145 }; 146 }