1 /* 2 * Copyright (c) 2011, 2013, 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 com.sun.source.doctree; 27 28 /** 29 * Common interface for all nodes in a documentation syntax tree. 30 * 31 * @since 1.8 32 */ 33 @jdk.Supported 34 public interface DocTree { 35 @jdk.Supported 36 enum Kind { 37 /** 38 * Used for instances of {@link AttributeTree} 39 * representing an HTML attribute. 40 */ 41 ATTRIBUTE, 42 43 /** 44 * Used for instances of {@link AuthorTree} 45 * representing an @author tag. 46 */ 47 AUTHOR("author"), 48 49 /** 50 * Used for instances of {@link LiteralTree} 51 * representing an @code tag. 52 */ 53 CODE("code"), 54 55 /** 56 * Used for instances of {@link CommentTree} 57 * representing an HTML comment. 58 */ 59 COMMENT, 60 61 /** 62 * Used for instances of {@link DeprecatedTree} 63 * representing an @deprecated tag. 64 */ 65 DEPRECATED("deprecated"), 66 67 /** 68 * Used for instances of {@link DocCommentTree} 69 * representing a complete doc comment. 70 */ 71 DOC_COMMENT, 72 73 /** 74 * Used for instances of {@link DocRootTree} 75 * representing an @docRoot tag. 76 */ 77 DOC_ROOT("docRoot"), 78 79 /** 80 * Used for instances of {@link EndElementTree} 81 * representing the end of an HTML element. 82 */ 83 END_ELEMENT, 84 85 /** 86 * Used for instances of {@link EntityTree} 87 * representing an HTML entity. 88 */ 89 ENTITY, 90 91 /** 92 * Used for instances of {@link ErroneousTree} 93 * representing some invalid text. 94 */ 95 ERRONEOUS, 96 97 /** 98 * Used for instances of {@link ThrowsTree} 99 * representing an @exception tag. 100 */ 101 EXCEPTION("exception"), 102 103 /** 104 * Used for instances of {@link IdentifierTree} 105 * representing an identifier. 106 */ 107 IDENTIFIER, 108 109 /** 110 * Used for instances of {@link InheritDocTree} 111 * representing an @inheritDoc tag. 112 */ 113 INHERIT_DOC("inheritDoc"), 114 115 /** 116 * Used for instances of {@link LinkTree} 117 * representing an @link tag. 118 */ 119 LINK("link"), 120 121 /** 122 * Used for instances of {@link LinkTree} 123 * representing an @linkplain tag. 124 */ 125 LINK_PLAIN("linkplain"), 126 127 /** 128 * Used for instances of {@link LiteralTree} 129 * representing an @literal tag. 130 */ 131 LITERAL("literal"), 132 133 /** 134 * Used for instances of {@link ParamTree} 135 * representing an @param tag. 136 */ 137 PARAM("param"), 138 139 /** 140 * Used for instances of {@link ReferenceTree} 141 * representing a reference to a element in the 142 * Java programming language. 143 */ 144 REFERENCE, 145 146 /** 147 * Used for instances of {@link ReturnTree} 148 * representing an @return tag. 149 */ 150 RETURN("return"), 151 152 /** 153 * Used for instances of {@link SeeTree} 154 * representing an @see tag. 155 */ 156 SEE("see"), 157 158 /** 159 * Used for instances of {@link SerialTree} 160 * representing an @serial tag. 161 */ 162 SERIAL("serial"), 163 164 /** 165 * Used for instances of {@link SerialDataTree} 166 * representing an @serialData tag. 167 */ 168 SERIAL_DATA("serialData"), 169 170 /** 171 * Used for instances of {@link SerialFieldTree} 172 * representing an @serialField tag. 173 */ 174 SERIAL_FIELD("serialField"), 175 176 /** 177 * Used for instances of {@link SinceTree} 178 * representing an @since tag. 179 */ 180 SINCE("since"), 181 182 /** 183 * Used for instances of {@link EndElementTree} 184 * representing the start of an HTML element. 185 */ 186 START_ELEMENT, 187 188 /** 189 * Used for instances of {@link TextTree} 190 * representing some documentation text. 191 */ 192 TEXT, 193 194 /** 195 * Used for instances of {@link ThrowsTree} 196 * representing an @throws tag. 197 */ 198 THROWS("throws"), 199 200 /** 201 * Used for instances of {@link UnknownBlockTagTree} 202 * representing an unknown block tag. 203 */ 204 UNKNOWN_BLOCK_TAG, 205 206 /** 207 * Used for instances of {@link UnknownInlineTagTree} 208 * representing an unknown inline tag. 209 */ 210 UNKNOWN_INLINE_TAG, 211 212 /** 213 * Used for instances of {@link ValueTree} 214 * representing an @value tag. 215 */ 216 VALUE("value"), 217 218 /** 219 * Used for instances of {@link VersionTree} 220 * representing an @version tag. 221 */ 222 VERSION("version"), 223 224 /** 225 * An implementation-reserved node. This is the not the node 226 * you are looking for. 227 */ 228 OTHER; 229 230 public final String tagName; 231 232 Kind() { 233 tagName = null; 234 } 235 236 Kind(String tagName) { 237 this.tagName = tagName; 238 } 239 }; 240 241 /** 242 * Gets the kind of this tree. 243 * 244 * @return the kind of this tree. 245 */ 246 Kind getKind(); 247 248 /** 249 * Accept method used to implement the visitor pattern. The 250 * visitor pattern is used to implement operations on trees. 251 * 252 * @param <R> result type of this operation. 253 * @param <D> type of additional data. 254 */ 255 <R, D> R accept(DocTreeVisitor<R,D> visitor, D data); 256 }