1 | /* |
2 | * Copyright (c) 2001-2009, Jean Tessier |
3 | * All rights reserved. |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
8 | * |
9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * |
12 | * * Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. |
15 | * |
16 | * * Neither the name of Jean Tessier nor the names of his contributors |
17 | * may be used to endorse or promote products derived from this software |
18 | * without specific prior written permission. |
19 | * |
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR |
24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | */ |
32 | |
33 | package com.jeantessier.classreader; |
34 | |
35 | import java.util.*; |
36 | |
37 | public class MockVisitor extends VisitorBase { |
38 | private List<Classfile> visitedClassfiles = new LinkedList<Classfile>(); |
39 | private List<ConstantValue_attribute> visitedConstantValue_attributes = new LinkedList<ConstantValue_attribute>(); |
40 | private List<Code_attribute> visitedCode_attributes = new LinkedList<Code_attribute>(); |
41 | private List<Exceptions_attribute> visitedExceptions_attributes = new LinkedList<Exceptions_attribute>(); |
42 | private List<InnerClasses_attribute> visitedInnerClasses_attributes = new LinkedList<InnerClasses_attribute>(); |
43 | private List<EnclosingMethod_attribute> visitedEnclosingMethod_attributes = new LinkedList<EnclosingMethod_attribute>(); |
44 | private List<Synthetic_attribute> visitedSynthetic_attributes = new LinkedList<Synthetic_attribute>(); |
45 | private List<Signature_attribute> visitedSignature_attributes = new LinkedList<Signature_attribute>(); |
46 | private List<SourceFile_attribute> visitedSourceFile_attributes = new LinkedList<SourceFile_attribute>(); |
47 | private List<SourceDebugExtension_attribute> visitedSourceDebugExtension_attributes = new LinkedList<SourceDebugExtension_attribute>(); |
48 | private List<LineNumberTable_attribute> visitedLineNumberTable_attributes = new LinkedList<LineNumberTable_attribute>(); |
49 | private List<LocalVariableTable_attribute> visitedLocalVariableTable_attributes = new LinkedList<LocalVariableTable_attribute>(); |
50 | private List<LocalVariableTypeTable_attribute> visitedLocalVariableTypeTable_attributes = new LinkedList<LocalVariableTypeTable_attribute>(); |
51 | private List<Deprecated_attribute> visitedDeprecated_attributes = new LinkedList<Deprecated_attribute>(); |
52 | private List<Custom_attribute> visitedCustom_attributes = new LinkedList<Custom_attribute>(); |
53 | private List<Instruction> visitedInstructions = new LinkedList<Instruction>(); |
54 | private List<ExceptionHandler> visitedExceptionHandlers = new LinkedList<ExceptionHandler>(); |
55 | private List<InnerClass> visitedInnerClasses = new LinkedList<InnerClass>(); |
56 | private List<LineNumber> visitedLineNumbers = new LinkedList<LineNumber>(); |
57 | private List<LocalVariable> visitedLocalVariables = new LinkedList<LocalVariable>(); |
58 | private List<LocalVariableType> visitedLocalVariableTypes = new LinkedList<LocalVariableType>(); |
59 | |
60 | public List<Classfile> getVisitedClassfiles() { |
61 | return visitedClassfiles; |
62 | } |
63 | |
64 | public List<ConstantValue_attribute> getVisitedConstantValue_attributes() { |
65 | return visitedConstantValue_attributes; |
66 | } |
67 | |
68 | public List<Code_attribute> getVisitedCode_attributes() { |
69 | return visitedCode_attributes; |
70 | } |
71 | |
72 | public List<Exceptions_attribute> getVisitedExceptions_attributes() { |
73 | return visitedExceptions_attributes; |
74 | } |
75 | |
76 | public List<InnerClasses_attribute> getVisitedInnerClasses_attributes() { |
77 | return visitedInnerClasses_attributes; |
78 | } |
79 | |
80 | |
81 | public List<EnclosingMethod_attribute> getVisitedEnclosingMethod_attributes() { |
82 | return visitedEnclosingMethod_attributes; |
83 | } |
84 | |
85 | public List<Synthetic_attribute> getVisitedSynthetic_attributes() { |
86 | return visitedSynthetic_attributes; |
87 | } |
88 | |
89 | public List<Signature_attribute> getVisitedSignature_attributes() { |
90 | return visitedSignature_attributes; |
91 | } |
92 | |
93 | public List<SourceFile_attribute> getVisitedSourceFile_attributes() { |
94 | return visitedSourceFile_attributes; |
95 | } |
96 | |
97 | public List<SourceDebugExtension_attribute> getVisitedSourceDebugExtension_attribute() { |
98 | return visitedSourceDebugExtension_attributes; |
99 | } |
100 | |
101 | public List<LineNumberTable_attribute> getVisitedLineNumberTable_attributes() { |
102 | return visitedLineNumberTable_attributes; |
103 | } |
104 | |
105 | public List<LocalVariableTable_attribute> getVisitedLocalVariableTable_attributes() { |
106 | return visitedLocalVariableTable_attributes; |
107 | } |
108 | |
109 | public List<LocalVariableTypeTable_attribute> getVisitedLocalVariableTypeTable_attributes() { |
110 | return visitedLocalVariableTypeTable_attributes; |
111 | } |
112 | |
113 | public List<Deprecated_attribute> getVisitedDeprecated_attributes() { |
114 | return visitedDeprecated_attributes; |
115 | } |
116 | |
117 | public List<Custom_attribute> getVisitedCustom_attributes() { |
118 | return visitedCustom_attributes; |
119 | } |
120 | |
121 | public List<Instruction> getVisitedInstructions() { |
122 | return visitedInstructions; |
123 | } |
124 | |
125 | public List<ExceptionHandler> getVisitedExceptionHandlers() { |
126 | return visitedExceptionHandlers; |
127 | } |
128 | |
129 | public List<InnerClass> getVisitedInnerClasses() { |
130 | return visitedInnerClasses; |
131 | } |
132 | |
133 | public List<LineNumber> getVisitedLineNumbers() { |
134 | return visitedLineNumbers; |
135 | } |
136 | |
137 | public List<LocalVariable> getVisitedLocalVariables() { |
138 | return visitedLocalVariables; |
139 | } |
140 | |
141 | public List<LocalVariableType> getVisitedLocalVariableTypes() { |
142 | return visitedLocalVariableTypes; |
143 | } |
144 | |
145 | public void visitClassfile(Classfile classfile) { |
146 | visitedClassfiles.add(classfile); |
147 | |
148 | super.visitClassfile(classfile); |
149 | } |
150 | |
151 | public void visitConstantValue_attribute(ConstantValue_attribute attribute) { |
152 | visitedConstantValue_attributes.add(attribute); |
153 | |
154 | super.visitConstantValue_attribute(attribute); |
155 | } |
156 | |
157 | public void visitCode_attribute(Code_attribute attribute) { |
158 | visitedCode_attributes.add(attribute); |
159 | |
160 | super.visitCode_attribute(attribute); |
161 | } |
162 | |
163 | public void visitExceptions_attribute(Exceptions_attribute attribute) { |
164 | visitedExceptions_attributes.add(attribute); |
165 | |
166 | super.visitExceptions_attribute(attribute); |
167 | } |
168 | |
169 | public void visitInnerClasses_attribute(InnerClasses_attribute attribute) { |
170 | visitedInnerClasses_attributes.add(attribute); |
171 | |
172 | super.visitInnerClasses_attribute(attribute); |
173 | } |
174 | |
175 | public void visitEnclosingMethod_attribute(EnclosingMethod_attribute attribute) { |
176 | visitedEnclosingMethod_attributes.add(attribute); |
177 | |
178 | super.visitEnclosingMethod_attribute(attribute); |
179 | } |
180 | |
181 | public void visitSynthetic_attribute(Synthetic_attribute attribute) { |
182 | visitedSynthetic_attributes.add(attribute); |
183 | |
184 | super.visitSynthetic_attribute(attribute); |
185 | } |
186 | |
187 | public void visitSignature_attribute(Signature_attribute attribute) { |
188 | visitedSignature_attributes.add(attribute); |
189 | |
190 | super.visitSignature_attribute(attribute); |
191 | } |
192 | |
193 | public void visitSourceFile_attribute(SourceFile_attribute attribute) { |
194 | visitedSourceFile_attributes.add(attribute); |
195 | |
196 | super.visitSourceFile_attribute(attribute); |
197 | } |
198 | |
199 | public void visitSourceDebugExtension_attribute(SourceDebugExtension_attribute attribute) { |
200 | visitedSourceDebugExtension_attributes.add(attribute); |
201 | |
202 | super.visitSourceDebugExtension_attribute(attribute); |
203 | } |
204 | |
205 | public void visitLineNumberTable_attribute(LineNumberTable_attribute attribute) { |
206 | visitedLineNumberTable_attributes.add(attribute); |
207 | |
208 | super.visitLineNumberTable_attribute(attribute); |
209 | } |
210 | |
211 | public void visitLocalVariableTable_attribute(LocalVariableTable_attribute attribute) { |
212 | visitedLocalVariableTable_attributes.add(attribute); |
213 | |
214 | super.visitLocalVariableTable_attribute(attribute); |
215 | } |
216 | |
217 | public void visitLocalVariableTypeTable_attribute(LocalVariableTypeTable_attribute attribute) { |
218 | visitedLocalVariableTypeTable_attributes.add(attribute); |
219 | |
220 | super.visitLocalVariableTypeTable_attribute(attribute); |
221 | } |
222 | |
223 | public void visitDeprecated_attribute(Deprecated_attribute attribute) { |
224 | visitedDeprecated_attributes.add(attribute); |
225 | |
226 | super.visitDeprecated_attribute(attribute); |
227 | } |
228 | |
229 | public void visitCustom_attribute(Custom_attribute attribute) { |
230 | visitedCustom_attributes.add(attribute); |
231 | |
232 | super.visitCustom_attribute(attribute); |
233 | } |
234 | |
235 | public void visitInstruction(Instruction helper) { |
236 | visitedInstructions.add(helper); |
237 | |
238 | super.visitInstruction(helper); |
239 | } |
240 | |
241 | public void visitExceptionHandler(ExceptionHandler helper) { |
242 | visitedExceptionHandlers.add(helper); |
243 | |
244 | super.visitExceptionHandler(helper); |
245 | } |
246 | |
247 | public void visitInnerClass(InnerClass helper) { |
248 | visitedInnerClasses.add(helper); |
249 | |
250 | super.visitInnerClass(helper); |
251 | } |
252 | |
253 | public void visitLineNumber(LineNumber helper) { |
254 | visitedLineNumbers.add(helper); |
255 | |
256 | super.visitLineNumber(helper); |
257 | } |
258 | |
259 | public void visitLocalVariable(LocalVariable helper) { |
260 | visitedLocalVariables.add(helper); |
261 | |
262 | super.visitLocalVariable(helper); |
263 | } |
264 | |
265 | public void visitLocalVariableType(LocalVariableType helper) { |
266 | visitedLocalVariableTypes.add(helper); |
267 | |
268 | super.visitLocalVariableType(helper); |
269 | } |
270 | |
271 | public void reset() { |
272 | visitedClassfiles.clear(); |
273 | visitedConstantValue_attributes.clear(); |
274 | visitedCode_attributes.clear(); |
275 | visitedExceptions_attributes.clear(); |
276 | visitedInnerClasses_attributes.clear(); |
277 | visitedSynthetic_attributes.clear(); |
278 | visitedSourceFile_attributes.clear(); |
279 | visitedLineNumberTable_attributes.clear(); |
280 | visitedLocalVariableTable_attributes.clear(); |
281 | visitedDeprecated_attributes.clear(); |
282 | visitedCustom_attributes.clear(); |
283 | visitedInstructions.clear(); |
284 | visitedExceptionHandlers.clear(); |
285 | visitedInnerClasses.clear(); |
286 | visitedLineNumbers.clear(); |
287 | visitedLocalVariables.clear(); |
288 | } |
289 | } |