View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   *
17   */
18  
19  package org.apache.bcel.visitors;
20  
21  import org.apache.bcel.classfile.AnnotationDefault;
22  import org.apache.bcel.classfile.AnnotationEntry;
23  import org.apache.bcel.classfile.Annotations;
24  import org.apache.bcel.classfile.BootstrapMethods;
25  import org.apache.bcel.classfile.Code;
26  import org.apache.bcel.classfile.CodeException;
27  import org.apache.bcel.classfile.ConstantClass;
28  import org.apache.bcel.classfile.ConstantDouble;
29  import org.apache.bcel.classfile.ConstantFieldref;
30  import org.apache.bcel.classfile.ConstantFloat;
31  import org.apache.bcel.classfile.ConstantInteger;
32  import org.apache.bcel.classfile.ConstantInterfaceMethodref;
33  import org.apache.bcel.classfile.ConstantInvokeDynamic;
34  import org.apache.bcel.classfile.ConstantLong;
35  import org.apache.bcel.classfile.ConstantMethodHandle;
36  import org.apache.bcel.classfile.ConstantMethodType;
37  import org.apache.bcel.classfile.ConstantMethodref;
38  import org.apache.bcel.classfile.ConstantModule;
39  import org.apache.bcel.classfile.ConstantNameAndType;
40  import org.apache.bcel.classfile.ConstantPackage;
41  import org.apache.bcel.classfile.ConstantPool;
42  import org.apache.bcel.classfile.ConstantString;
43  import org.apache.bcel.classfile.ConstantUtf8;
44  import org.apache.bcel.classfile.ConstantValue;
45  import org.apache.bcel.classfile.Deprecated;
46  import org.apache.bcel.classfile.EnclosingMethod;
47  import org.apache.bcel.classfile.ExceptionTable;
48  import org.apache.bcel.classfile.Field;
49  import org.apache.bcel.classfile.InnerClass;
50  import org.apache.bcel.classfile.InnerClasses;
51  import org.apache.bcel.classfile.JavaClass;
52  import org.apache.bcel.classfile.LineNumber;
53  import org.apache.bcel.classfile.LineNumberTable;
54  import org.apache.bcel.classfile.LocalVariable;
55  import org.apache.bcel.classfile.LocalVariableTable;
56  import org.apache.bcel.classfile.LocalVariableTypeTable;
57  import org.apache.bcel.classfile.Method;
58  import org.apache.bcel.classfile.MethodParameters;
59  import org.apache.bcel.classfile.ParameterAnnotationEntry;
60  import org.apache.bcel.classfile.ParameterAnnotations;
61  import org.apache.bcel.classfile.Signature;
62  import org.apache.bcel.classfile.SourceFile;
63  import org.apache.bcel.classfile.StackMap;
64  import org.apache.bcel.classfile.StackMapEntry;
65  import org.apache.bcel.classfile.Synthetic;
66  import org.apache.bcel.classfile.Unknown;
67  import org.apache.bcel.classfile.Visitor;
68  
69  public class CounterVisitor implements Visitor
70  {
71      // CHECKSTYLE:OFF (public mutable fields in test code)
72      public int unknownCount = 0;
73  
74      public int syntheticCount = 0;
75  
76      public int stackMapEntryCount = 0;
77  
78      public int stackMapCount = 0;
79  
80      public int sourceFileCount = 0;
81  
82      public int signatureAnnotationCount = 0;
83  
84      public int parameterAnnotationCount = 0;
85  
86      public int methodCount = 0;
87  
88      public int localVariableTypeTableCount = 0;
89  
90      public int localVariableTableCount = 0;
91  
92      public int localVariableCount = 0;
93  
94      public int lineNumberTableCount = 0;
95  
96      public int lineNumberCount = 0;
97  
98      public int javaClassCount = 0;
99  
100     public int innerClassesCount = 0;
101 
102     public int innerClassCount = 0;
103 
104     public int fieldCount = 0;
105 
106     public int exceptionTableCount = 0;
107 
108     public int enclosingMethodCount = 0;
109 
110     public int deprecatedCount = 0;
111 
112     public int constantValueCount = 0;
113 
114     public int constantUtf8Count = 0;
115 
116     public int constantStringCount = 0;
117 
118     public int constantNameAndTypeCount = 0;
119 
120     public int constantPoolCount = 0;
121 
122     public int constantMethodrefCount = 0;
123 
124     public int constantLongCount = 0;
125 
126     public int constantIntegerCount = 0;
127 
128     public int constantInterfaceMethodrefCount = 0;
129 
130     public int constantFloatCount = 0;
131 
132     public int constantFieldrefCount = 0;
133 
134     public int constantClassCount = 0;
135 
136     public int constantDoubleCount = 0;
137 
138     public int codeExceptionCount = 0;
139 
140     public int codeCount = 0;
141 
142     public int annotationEntryCount = 0;
143 
144     public int annotationDefaultCount = 0;
145 
146     public int annotationCount = 0;
147 
148     /** @since 6.0 */
149     public int bootstrapMethodsCount = 0;
150 
151     /** @since 6.0 */
152     public int methodParametersCount = 0;
153 
154     /** @since 6.0 */
155     public int constantInvokeDynamic = 0;
156 
157     /** @since 6.1 */
158     public int constantModuleCount = 0;
159 
160     /** @since 6.1 */
161     public int constantPackageCount = 0;
162     // CHECKSTYLE:ON
163 
164 
165     @Override
166     public void visitAnnotation(final Annotations obj)
167     {
168         annotationCount++;
169     }
170 
171     @Override
172     public void visitAnnotationDefault(final AnnotationDefault obj)
173     {
174         annotationDefaultCount++;
175     }
176 
177     @Override
178     public void visitAnnotationEntry(final AnnotationEntry obj)
179     {
180         annotationEntryCount++;
181     }
182 
183     @Override
184     public void visitCode(final Code obj)
185     {
186         codeCount++;
187     }
188 
189     @Override
190     public void visitCodeException(final CodeException obj)
191     {
192         codeExceptionCount++;
193     }
194 
195     @Override
196     public void visitConstantClass(final ConstantClass obj)
197     {
198         constantClassCount++;
199     }
200 
201     @Override
202     public void visitConstantDouble(final ConstantDouble obj)
203     {
204         constantDoubleCount++;
205     }
206 
207     @Override
208     public void visitConstantFieldref(final ConstantFieldref obj)
209     {
210         constantFieldrefCount++;
211     }
212 
213     @Override
214     public void visitConstantFloat(final ConstantFloat obj)
215     {
216         constantFloatCount++;
217     }
218 
219     @Override
220     public void visitConstantInteger(final ConstantInteger obj)
221     {
222         constantIntegerCount++;
223     }
224 
225     @Override
226     public void visitConstantInterfaceMethodref(final ConstantInterfaceMethodref obj)
227     {
228         constantInterfaceMethodrefCount++;
229     }
230 
231     @Override
232     public void visitConstantLong(final ConstantLong obj)
233     {
234         constantLongCount++;
235     }
236 
237     @Override
238     public void visitConstantMethodref(final ConstantMethodref obj)
239     {
240         constantMethodrefCount++;
241     }
242 
243     @Override
244     public void visitConstantNameAndType(final ConstantNameAndType obj)
245     {
246         constantNameAndTypeCount++;
247     }
248 
249     @Override
250     public void visitConstantPool(final ConstantPool obj)
251     {
252         constantPoolCount++;
253     }
254 
255     @Override
256     public void visitConstantString(final ConstantString obj)
257     {
258         constantStringCount++;
259     }
260 
261     @Override
262     public void visitConstantUtf8(final ConstantUtf8 obj)
263     {
264         constantUtf8Count++;
265     }
266 
267     @Override
268     public void visitConstantValue(final ConstantValue obj)
269     {
270         constantValueCount++;
271     }
272 
273     @Override
274     public void visitDeprecated(final Deprecated obj)
275     {
276         deprecatedCount++;
277     }
278 
279     @Override
280     public void visitEnclosingMethod(final EnclosingMethod obj)
281     {
282         enclosingMethodCount++;
283     }
284 
285     @Override
286     public void visitExceptionTable(final ExceptionTable obj)
287     {
288         exceptionTableCount++;
289     }
290 
291     @Override
292     public void visitField(final Field obj)
293     {
294         fieldCount++;
295     }
296 
297     @Override
298     public void visitInnerClass(final InnerClass obj)
299     {
300         innerClassCount++;
301     }
302 
303     @Override
304     public void visitInnerClasses(final InnerClasses obj)
305     {
306         innerClassesCount++;
307     }
308 
309     @Override
310     public void visitJavaClass(final JavaClass obj)
311     {
312         javaClassCount++;
313     }
314 
315     @Override
316     public void visitLineNumber(final LineNumber obj)
317     {
318         lineNumberCount++;
319     }
320 
321     @Override
322     public void visitLineNumberTable(final LineNumberTable obj)
323     {
324         lineNumberTableCount++;
325     }
326 
327     @Override
328     public void visitLocalVariable(final LocalVariable obj)
329     {
330         localVariableCount++;
331     }
332 
333     @Override
334     public void visitLocalVariableTable(final LocalVariableTable obj)
335     {
336         localVariableTableCount++;
337     }
338 
339     @Override
340     public void visitLocalVariableTypeTable(final LocalVariableTypeTable obj)
341     {
342         localVariableTypeTableCount++;
343     }
344 
345     @Override
346     public void visitMethod(final Method obj)
347     {
348         methodCount++;
349     }
350 
351     @Override
352     public void visitParameterAnnotation(final ParameterAnnotations obj)
353     {
354         parameterAnnotationCount++;
355     }
356 
357     @Override
358     public void visitSignature(final Signature obj)
359     {
360         signatureAnnotationCount++;
361     }
362 
363     @Override
364     public void visitSourceFile(final SourceFile obj)
365     {
366         sourceFileCount++;
367     }
368 
369     @Override
370     public void visitStackMap(final StackMap obj)
371     {
372         stackMapCount++;
373     }
374 
375     @Override
376     public void visitStackMapEntry(final StackMapEntry obj)
377     {
378         stackMapEntryCount++;
379     }
380 
381     @Override
382     public void visitSynthetic(final Synthetic obj)
383     {
384         syntheticCount++;
385     }
386 
387     @Override
388     public void visitUnknown(final Unknown obj)
389     {
390         unknownCount++;
391     }
392 
393     /** @since 6.0 */
394     @Override
395     public void visitBootstrapMethods(final BootstrapMethods obj)
396     {
397         bootstrapMethodsCount++;
398     }
399 
400     /** @since 6.0 */
401     @Override
402     public void visitMethodParameters(final MethodParameters obj)
403     {
404         methodParametersCount++;
405     }
406 
407     /** @since 6.0 */
408     @Override
409     public void visitConstantInvokeDynamic(final ConstantInvokeDynamic obj)
410     {
411         constantInvokeDynamic++;
412     }
413 
414     /** @since 6.0 */
415     @Override
416     public void visitConstantMethodType(final ConstantMethodType obj) {
417         // TODO Auto-generated method stub
418     }
419 
420     /** @since 6.0 */
421     @Override
422     public void visitConstantMethodHandle(final ConstantMethodHandle constantMethodHandle) {
423         // TODO Auto-generated method stub
424     }
425 
426     /** @since 6.0 */
427     @Override
428     public void visitParameterAnnotationEntry(final ParameterAnnotationEntry parameterAnnotationEntry) {
429         // TODO Auto-generated method stub
430     }
431 
432     /** @since 6.1 */
433     @Override
434     public void visitConstantPackage(final ConstantPackage constantPackage) {
435         constantPackageCount++;
436     }
437 
438     /** @since 6.1 */
439     @Override
440     public void visitConstantModule(final ConstantModule constantModule) {
441         constantModuleCount++;
442     }
443 }