1 10 11 package com.sun.source.util; 12 13 import com.sun.source.tree.*; 14 15 21 public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> { 22 protected final R DEFAULT_VALUE; 23 24 protected SimpleTreeVisitor() { 25 DEFAULT_VALUE = null; 26 } 27 28 protected SimpleTreeVisitor(R defaultValue) { 29 DEFAULT_VALUE = defaultValue; 30 } 31 32 protected R defaultAction(Tree node, P p) { 33 return DEFAULT_VALUE; 34 } 35 36 public final R visit(Tree node, P p) { 37 return (node == null) ? null : node.accept(this, p); 38 } 39 40 public final R visit(Iterable <? extends Tree> nodes, P p) { 41 R r = null; 42 if (nodes != null) 43 for (Tree node : nodes) 44 r = visit(node, p); 45 return r; 46 } 47 48 public R visitCompilationUnit(CompilationUnitTree node, P p) { 49 return defaultAction(node, p); 50 } 51 52 public R visitImport(ImportTree node, P p) { 53 return defaultAction(node, p); 54 } 55 56 public R visitClass(ClassTree node, P p) { 57 return defaultAction(node, p); 58 } 59 60 public R visitMethod(MethodTree node, P p) { 61 return defaultAction(node, p); 62 } 63 64 public R visitVariable(VariableTree node, P p) { 65 return defaultAction(node, p); 66 } 67 68 public R visitEmptyStatement(EmptyStatementTree node, P p) { 69 return defaultAction(node, p); 70 } 71 72 public R visitBlock(BlockTree node, P p) { 73 return defaultAction(node, p); 74 } 75 76 public R visitDoWhileLoop(DoWhileLoopTree node, P p) { 77 return defaultAction(node, p); 78 } 79 80 public R visitWhileLoop(WhileLoopTree node, P p) { 81 return defaultAction(node, p); 82 } 83 84 public R visitForLoop(ForLoopTree node, P p) { 85 return defaultAction(node, p); 86 } 87 88 public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) { 89 return defaultAction(node, p); 90 } 91 92 public R visitLabeledStatement(LabeledStatementTree node, P p) { 93 return defaultAction(node, p); 94 } 95 96 public R visitSwitch(SwitchTree node, P p) { 97 return defaultAction(node, p); 98 } 99 100 public R visitCase(CaseTree node, P p) { 101 return defaultAction(node, p); 102 } 103 104 public R visitSynchronized(SynchronizedTree node, P p) { 105 return defaultAction(node, p); 106 } 107 108 public R visitTry(TryTree node, P p) { 109 return defaultAction(node, p); 110 } 111 112 public R visitCatch(CatchTree node, P p) { 113 return defaultAction(node, p); 114 } 115 116 public R visitConditionalExpression(ConditionalExpressionTree node, P p) { 117 return defaultAction(node, p); 118 } 119 120 public R visitIf(IfTree node, P p) { 121 return defaultAction(node, p); 122 } 123 124 public R visitExpressionStatement(ExpressionStatementTree node, P p) { 125 return defaultAction(node, p); 126 } 127 128 public R visitBreak(BreakTree node, P p) { 129 return defaultAction(node, p); 130 } 131 132 public R visitContinue(ContinueTree node, P p) { 133 return defaultAction(node, p); 134 } 135 136 public R visitReturn(ReturnTree node, P p) { 137 return defaultAction(node, p); 138 } 139 140 public R visitThrow(ThrowTree node, P p) { 141 return defaultAction(node, p); 142 } 143 144 public R visitAssert(AssertTree node, P p) { 145 return defaultAction(node, p); 146 } 147 148 public R visitMethodInvocation(MethodInvocationTree node, P p) { 149 return defaultAction(node, p); 150 } 151 152 public R visitNewClass(NewClassTree node, P p) { 153 return defaultAction(node, p); 154 } 155 156 public R visitNewArray(NewArrayTree node, P p) { 157 return defaultAction(node, p); 158 } 159 160 public R visitParenthesized(ParenthesizedTree node, P p) { 161 return defaultAction(node, p); 162 } 163 164 public R visitAssignment(AssignmentTree node, P p) { 165 return defaultAction(node, p); 166 } 167 168 public R visitCompoundAssignment(CompoundAssignmentTree node, P p) { 169 return defaultAction(node, p); 170 } 171 172 public R visitUnary(UnaryTree node, P p) { 173 return defaultAction(node, p); 174 } 175 176 public R visitBinary(BinaryTree node, P p) { 177 return defaultAction(node, p); 178 } 179 180 public R visitTypeCast(TypeCastTree node, P p) { 181 return defaultAction(node, p); 182 } 183 184 public R visitInstanceOf(InstanceOfTree node, P p) { 185 return defaultAction(node, p); 186 } 187 188 public R visitArrayAccess(ArrayAccessTree node, P p) { 189 return defaultAction(node, p); 190 } 191 192 public R visitMemberSelect(MemberSelectTree node, P p) { 193 return defaultAction(node, p); 194 } 195 196 public R visitIdentifier(IdentifierTree node, P p) { 197 return defaultAction(node, p); 198 } 199 200 public R visitLiteral(LiteralTree node, P p) { 201 return defaultAction(node, p); 202 } 203 204 public R visitPrimitiveType(PrimitiveTypeTree node, P p) { 205 return defaultAction(node, p); 206 } 207 208 public R visitArrayType(ArrayTypeTree node, P p) { 209 return defaultAction(node, p); 210 } 211 212 public R visitParameterizedType(ParameterizedTypeTree node, P p) { 213 return defaultAction(node, p); 214 } 215 216 public R visitTypeParameter(TypeParameterTree node, P p) { 217 return defaultAction(node, p); 218 } 219 220 public R visitWildcard(WildcardTree node, P p) { 221 return defaultAction(node, p); 222 } 223 224 public R visitModifiers(ModifiersTree node, P p) { 225 return defaultAction(node, p); 226 } 227 228 public R visitAnnotation(AnnotationTree node, P p) { 229 return defaultAction(node, p); 230 } 231 232 public R visitErroneous(ErroneousTree node, P p) { 233 return defaultAction(node, p); 234 } 235 236 public R visitOther(Tree node, P p) { 237 return defaultAction(node, p); 238 } 239 } 240 | Popular Tags |