src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
equal deleted inserted replaced
-1:000000000000 0:959103a6100f
1 /*
2 * Copyright (c) 2005, 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.util;
27
28 import com.sun.source.doctree.*;
29
30 /**
31 * A simple visitor for tree nodes.
32 *
33 * @since 1.8
34 */
35 @jdk.Exported
36 public class SimpleDocTreeVisitor<R,P> implements DocTreeVisitor<R, P> {
37 protected final R DEFAULT_VALUE;
38
39 protected SimpleDocTreeVisitor() {
40 DEFAULT_VALUE = null;
41 }
42
43 protected SimpleDocTreeVisitor(R defaultValue) {
44 DEFAULT_VALUE = defaultValue;
45 }
46
47 protected R defaultAction(DocTree node, P p) {
48 return DEFAULT_VALUE;
49 }
50
51 public final R visit(DocTree node, P p) {
52 return (node == null) ? null : node.accept(this, p);
53 }
54
55 public final R visit(Iterable<? extends DocTree> nodes, P p) {
56 R r = null;
57 if (nodes != null) {
58 for (DocTree node : nodes)
59 r = visit(node, p);
60 }
61 return r;
62 }
63
64 public R visitAttribute(AttributeTree node, P p) {
65 return defaultAction(node, p);
66 }
67
68 public R visitAuthor(AuthorTree node, P p) {
69 return defaultAction(node, p);
70 }
71
72 public R visitComment(CommentTree node, P p) {
73 return defaultAction(node, p);
74 }
75
76 public R visitDeprecated(DeprecatedTree node, P p) {
77 return defaultAction(node, p);
78 }
79
80 public R visitDocComment(DocCommentTree node, P p) {
81 return defaultAction(node, p);
82 }
83
84 public R visitDocRoot(DocRootTree node, P p) {
85 return defaultAction(node, p);
86 }
87
88 public R visitEndElement(EndElementTree node, P p) {
89 return defaultAction(node, p);
90 }
91
92 public R visitEntity(EntityTree node, P p) {
93 return defaultAction(node, p);
94 }
95
96 public R visitErroneous(ErroneousTree node, P p) {
97 return defaultAction(node, p);
98 }
99
100 public R visitIdentifier(IdentifierTree node, P p) {
101 return defaultAction(node, p);
102 }
103
104 public R visitInheritDoc(InheritDocTree node, P p) {
105 return defaultAction(node, p);
106 }
107
108 public R visitLink(LinkTree node, P p) {
109 return defaultAction(node, p);
110 }
111
112 public R visitLiteral(LiteralTree node, P p) {
113 return defaultAction(node, p);
114 }
115
116 public R visitParam(ParamTree node, P p) {
117 return defaultAction(node, p);
118 }
119
120 public R visitReference(ReferenceTree node, P p) {
121 return defaultAction(node, p);
122 }
123
124 public R visitReturn(ReturnTree node, P p) {
125 return defaultAction(node, p);
126 }
127
128 public R visitSee(SeeTree node, P p) {
129 return defaultAction(node, p);
130 }
131
132 public R visitSerial(SerialTree node, P p) {
133 return defaultAction(node, p);
134 }
135
136 public R visitSerialData(SerialDataTree node, P p) {
137 return defaultAction(node, p);
138 }
139
140 public R visitSerialField(SerialFieldTree node, P p) {
141 return defaultAction(node, p);
142 }
143
144 public R visitSince(SinceTree node, P p) {
145 return defaultAction(node, p);
146 }
147
148 public R visitStartElement(StartElementTree node, P p) {
149 return defaultAction(node, p);
150 }
151
152 public R visitText(TextTree node, P p) {
153 return defaultAction(node, p);
154 }
155
156 public R visitThrows(ThrowsTree node, P p) {
157 return defaultAction(node, p);
158 }
159
160 public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
161 return defaultAction(node, p);
162 }
163
164 public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) {
165 return defaultAction(node, p);
166 }
167
168 public R visitValue(ValueTree node, P p) {
169 return defaultAction(node, p);
170 }
171
172 public R visitVersion(VersionTree node, P p) {
173 return defaultAction(node, p);
174 }
175
176 public R visitOther(DocTree node, P p) {
177 return defaultAction(node, p);
178 }
179
180 }

mercurial