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