DocTreeVisitor.java revision 4150:fff0714129d8
1151912Sphk/* 2151912Sphk * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. 3151912Sphk * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4151912Sphk * 5151912Sphk * This code is free software; you can redistribute it and/or modify it 6151912Sphk * under the terms of the GNU General Public License version 2 only, as 7151912Sphk * published by the Free Software Foundation. Oracle designates this 8151912Sphk * particular file as subject to the "Classpath" exception as provided 9151912Sphk * by Oracle in the LICENSE file that accompanied this code. 10151912Sphk * 11151912Sphk * This code is distributed in the hope that it will be useful, but WITHOUT 12151912Sphk * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13151912Sphk * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14151912Sphk * version 2 for more details (a copy is included in the LICENSE file that 15151912Sphk * accompanied this code). 16151912Sphk * 17151912Sphk * You should have received a copy of the GNU General Public License version 18151912Sphk * 2 along with this work; if not, write to the Free Software Foundation, 19151912Sphk * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20151912Sphk * 21151912Sphk * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22151912Sphk * or visit www.oracle.com if you need additional information or have any 23151912Sphk * questions. 24151912Sphk */ 25151912Sphk 26151912Sphkpackage com.sun.source.doctree; 27151912Sphk 28151912Sphk 29151912Sphk/** 30151912Sphk * A visitor of trees, in the style of the visitor design pattern. 31151912Sphk * Classes implementing this interface are used to operate 32151912Sphk * on a tree when the kind of tree is unknown at compile time. 33151912Sphk * When a visitor is passed to an tree's {@link DocTree#accept 34151912Sphk * accept} method, the <code>visit<i>Xyz</i></code> method most applicable 35151912Sphk * to that tree is invoked. 36151912Sphk * 37151912Sphk * <p> Classes implementing this interface may or may not throw a 38151912Sphk * {@code NullPointerException} if the additional parameter {@code p} 39151912Sphk * is {@code null}; see documentation of the implementing class for 40151912Sphk * details. 41151912Sphk * 42151912Sphk * <p> <b>WARNING:</b> It is possible that methods will be added to 43151912Sphk * this interface to accommodate new, currently unknown, doc comment 44151931Sscottl * structures added to future versions of the Java™ programming 45151935Sscottl * language. Therefore, visitor classes directly implementing this 46151931Sscottl * interface may be source incompatible with future versions of the 47151931Sscottl * platform. 48151912Sphk * 49151912Sphk * @param <R> the return type of this visitor's methods. Use {@link 50151912Sphk * Void} for visitors that do not need to return results. 51151912Sphk * @param <P> the type of the additional parameter to this visitor's 52151912Sphk * methods. Use {@code Void} for visitors that do not need an 53151912Sphk * additional parameter. 54151912Sphk * 55151912Sphk * @since 1.8 56151912Sphk */ 57151912Sphkpublic interface DocTreeVisitor<R,P> { 58151912Sphk 59151912Sphk /** 60151912Sphk * Visits an AttributeTree node. 61151912Sphk * @param node the node being visited 62151912Sphk * @param p a parameter value 63151912Sphk * @return a result value 64151912Sphk */ 65151912Sphk R visitAttribute(AttributeTree node, P p); 66151912Sphk 67151912Sphk /** 68151912Sphk * Visits an AuthorTree node. 69151912Sphk * @param node the node being visited 70151912Sphk * @param p a parameter value 71151912Sphk * @return a result value 72151912Sphk */ 73151912Sphk R visitAuthor(AuthorTree node, P p); 74151912Sphk 75151912Sphk /** 76151912Sphk * Visits a CommentTree node. 77151912Sphk * @param node the node being visited 78151912Sphk * @param p a parameter value 79151912Sphk * @return a result value 80151912Sphk */ 81151912Sphk R visitComment(CommentTree node, P p); 82151912Sphk 83151912Sphk /** 84151912Sphk * Visits a DeprecatedTree node. 85151912Sphk * @param node the node being visited 86151912Sphk * @param p a parameter value 87151912Sphk * @return a result value 88151912Sphk */ 89151912Sphk R visitDeprecated(DeprecatedTree node, P p); 90151912Sphk 91151912Sphk /** 92151912Sphk * Visits a DocCommentTree node. 93151912Sphk * @param node the node being visited 94151912Sphk * @param p a parameter value 95151912Sphk * @return a result value 96151912Sphk */ 97151912Sphk R visitDocComment(DocCommentTree node, P p); 98151912Sphk 99151912Sphk /** 100151912Sphk * Visits a DocRootTree node. 101151912Sphk * @param node the node being visited 102151912Sphk * @param p a parameter value 103151912Sphk * @return a result value 104151912Sphk */ 105151912Sphk R visitDocRoot(DocRootTree node, P p); 106151912Sphk 107151912Sphk /** 108151912Sphk * Visits an EndElementTree node. 109151912Sphk * @param node the node being visited 110151912Sphk * @param p a parameter value 111151912Sphk * @return a result value 112151912Sphk */ 113151912Sphk R visitEndElement(EndElementTree node, P p); 114151912Sphk 115151912Sphk /** 116151912Sphk * Visits an EntityTree node. 117151912Sphk * @param node the node being visited 118151912Sphk * @param p a parameter value 119151912Sphk * @return a result value 120151912Sphk */ 121151912Sphk R visitEntity(EntityTree node, P p); 122151912Sphk 123151912Sphk /** 124151912Sphk * Visits an ErroneousTree node. 125151912Sphk * @param node the node being visited 126151912Sphk * @param p a parameter value 127151912Sphk * @return a result value 128151912Sphk */ 129151912Sphk R visitErroneous(ErroneousTree node, P p); 130151912Sphk 131151912Sphk /** 132151912Sphk * Visits a HiddenTree node. 133151912Sphk * @param node the node being visited 134151912Sphk * @param p a parameter value 135151912Sphk * @return a result value 136151912Sphk */ 137151912Sphk R visitHidden(HiddenTree node, P p); 138151912Sphk 139151912Sphk /** 140151912Sphk * Visits an IdentifierTree node. 141151912Sphk * @param node the node being visited 142151912Sphk * @param p a parameter value 143151912Sphk * @return a result value 144151912Sphk */ 145151912Sphk R visitIdentifier(IdentifierTree node, P p); 146151912Sphk 147151912Sphk /** 148151912Sphk * Visits an IndexTree node. 149151912Sphk * @param node the node being visited 150151912Sphk * @param p a parameter value 151151912Sphk * @return a result value 152151912Sphk */ 153151912Sphk R visitIndex(IndexTree node, P p); 154151912Sphk 155151912Sphk /** 156151912Sphk * Visits an InheritDocTree node. 157151912Sphk * @param node the node being visited 158151912Sphk * @param p a parameter value 159151912Sphk * @return a result value 160151912Sphk */ 161151912Sphk R visitInheritDoc(InheritDocTree node, P p); 162151912Sphk 163151912Sphk /** 164151912Sphk * Visits a LinkTree node. 165151912Sphk * @param node the node being visited 166151912Sphk * @param p a parameter value 167151912Sphk * @return a result value 168151912Sphk */ 169151912Sphk R visitLink(LinkTree node, P p); 170151912Sphk 171151912Sphk /** 172151912Sphk * Visits an LiteralTree node. 173151912Sphk * @param node the node being visited 174151912Sphk * @param p a parameter value 175151912Sphk * @return a result value 176151912Sphk */ 177151912Sphk R visitLiteral(LiteralTree node, P p); 178151912Sphk 179151912Sphk /** 180151912Sphk * Visits a ParamTree node. 181151912Sphk * @param node the node being visited 182151912Sphk * @param p a parameter value 183151912Sphk * @return a result value 184151912Sphk */ 185151912Sphk R visitParam(ParamTree node, P p); 186151912Sphk 187151912Sphk /** 188151912Sphk * Visits a ProvidesTree node. 189151912Sphk * @param node the node being visited 190151912Sphk * @param p a parameter value 191151912Sphk * @return a result value 192151912Sphk */ 193151912Sphk R visitProvides(ProvidesTree node, P p); 194151912Sphk 195 /** 196 * Visits a ReferenceTree node. 197 * @param node the node being visited 198 * @param p a parameter value 199 * @return a result value 200 */ 201 R visitReference(ReferenceTree node, P p); 202 203 /** 204 * Visits a ReturnTree node. 205 * @param node the node being visited 206 * @param p a parameter value 207 * @return a result value 208 */ 209 R visitReturn(ReturnTree node, P p); 210 211 /** 212 * Visits a SeeTree node. 213 * @param node the node being visited 214 * @param p a parameter value 215 * @return a result value 216 */ 217 R visitSee(SeeTree node, P p); 218 219 /** 220 * Visits a SerialTree node. 221 * @param node the node being visited 222 * @param p a parameter value 223 * @return a result value 224 */ 225 R visitSerial(SerialTree node, P p); 226 227 /** 228 * Visits a SerialDataTree node. 229 * @param node the node being visited 230 * @param p a parameter value 231 * @return a result value 232 */ 233 R visitSerialData(SerialDataTree node, P p); 234 235 /** 236 * Visits a SerialFieldTree node. 237 * @param node the node being visited 238 * @param p a parameter value 239 * @return a result value 240 */ 241 R visitSerialField(SerialFieldTree node, P p); 242 243 /** 244 * Visits a SinceTree node. 245 * @param node the node being visited 246 * @param p a parameter value 247 * @return a result value 248 */ 249 R visitSince(SinceTree node, P p); 250 251 /** 252 * Visits a StartElementTree node. 253 * @param node the node being visited 254 * @param p a parameter value 255 * @return a result value 256 */ 257 R visitStartElement(StartElementTree node, P p); 258 259 /** 260 * Visits a TextTree node. 261 * @param node the node being visited 262 * @param p a parameter value 263 * @return a result value 264 */ 265 R visitText(TextTree node, P p); 266 267 /** 268 * Visits a ThrowsTree node. 269 * @param node the node being visited 270 * @param p a parameter value 271 * @return a result value 272 */ 273 R visitThrows(ThrowsTree node, P p); 274 275 /** 276 * Visits an UnknownBlockTagTree node. 277 * @param node the node being visited 278 * @param p a parameter value 279 * @return a result value 280 */ 281 R visitUnknownBlockTag(UnknownBlockTagTree node, P p); 282 283 /** 284 * Visits an UnknownInlineTagTree node. 285 * @param node the node being visited 286 * @param p a parameter value 287 * @return a result value 288 */ 289 R visitUnknownInlineTag(UnknownInlineTagTree node, P p); 290 291 /** 292 * Visits a UsesTree node. 293 * @param node the node being visited 294 * @param p a parameter value 295 * @return a result value 296 */ 297 R visitUses(UsesTree node, P p); 298 299 /** 300 * Visits a ValueTree node. 301 * @param node the node being visited 302 * @param p a parameter value 303 * @return a result value 304 */ 305 R visitValue(ValueTree node, P p); 306 307 /** 308 * Visits a VersionTreeTree node. 309 * @param node the node being visited 310 * @param p a parameter value 311 * @return a result value 312 */ 313 R visitVersion(VersionTree node, P p); 314 315 /** 316 * Visits an unknown type of DocTree node. 317 * This can occur if the set of tags evolves and new kinds 318 * of nodes are added to the {@code DocTree} hierarchy. 319 * @param node the node being visited 320 * @param p a parameter value 321 * @return a result value 322 */ 323 R visitOther(DocTree node, P p); 324} 325