001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *   http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     * 
017     */
018    
019    package org.apache.bcel.visitors;
020    
021    import org.apache.bcel.classfile.AnnotationDefault;
022    import org.apache.bcel.classfile.AnnotationEntry;
023    import org.apache.bcel.classfile.Annotations;
024    import org.apache.bcel.classfile.Code;
025    import org.apache.bcel.classfile.CodeException;
026    import org.apache.bcel.classfile.ConstantClass;
027    import org.apache.bcel.classfile.ConstantDouble;
028    import org.apache.bcel.classfile.ConstantFieldref;
029    import org.apache.bcel.classfile.ConstantFloat;
030    import org.apache.bcel.classfile.ConstantInteger;
031    import org.apache.bcel.classfile.ConstantInterfaceMethodref;
032    import org.apache.bcel.classfile.ConstantLong;
033    import org.apache.bcel.classfile.ConstantMethodref;
034    import org.apache.bcel.classfile.ConstantNameAndType;
035    import org.apache.bcel.classfile.ConstantPool;
036    import org.apache.bcel.classfile.ConstantString;
037    import org.apache.bcel.classfile.ConstantUtf8;
038    import org.apache.bcel.classfile.ConstantValue;
039    import org.apache.bcel.classfile.Deprecated;
040    import org.apache.bcel.classfile.EnclosingMethod;
041    import org.apache.bcel.classfile.ExceptionTable;
042    import org.apache.bcel.classfile.Field;
043    import org.apache.bcel.classfile.InnerClass;
044    import org.apache.bcel.classfile.InnerClasses;
045    import org.apache.bcel.classfile.JavaClass;
046    import org.apache.bcel.classfile.LineNumber;
047    import org.apache.bcel.classfile.LineNumberTable;
048    import org.apache.bcel.classfile.LocalVariable;
049    import org.apache.bcel.classfile.LocalVariableTable;
050    import org.apache.bcel.classfile.LocalVariableTypeTable;
051    import org.apache.bcel.classfile.Method;
052    import org.apache.bcel.classfile.ParameterAnnotations;
053    import org.apache.bcel.classfile.Signature;
054    import org.apache.bcel.classfile.SourceFile;
055    import org.apache.bcel.classfile.StackMap;
056    import org.apache.bcel.classfile.StackMapEntry;
057    import org.apache.bcel.classfile.StackMapTable;
058    import org.apache.bcel.classfile.StackMapTableEntry;
059    import org.apache.bcel.classfile.Synthetic;
060    import org.apache.bcel.classfile.Unknown;
061    import org.apache.bcel.classfile.Visitor;
062    
063    public class CounterVisitor implements Visitor
064    {
065            public int unknownCount = 0;
066    
067            public int syntheticCount = 0;
068    
069            public int stackMapEntryCount = 0;
070    
071            public int stackMapCount = 0;
072    
073            public int sourceFileCount = 0;
074    
075            public int signatureAnnotationCount = 0;
076    
077            public int parameterAnnotationCount = 0;
078    
079            public int methodCount = 0;
080    
081            public int localVariableTypeTableCount = 0;
082    
083            public int localVariableTableCount = 0;
084    
085            public int localVariableCount = 0;
086    
087            public int lineNumberTableCount = 0;
088    
089            public int lineNumberCount = 0;
090    
091            public int javaClassCount = 0;
092    
093            public int innerClassesCount = 0;
094    
095            public int innerClassCount = 0;
096    
097            public int fieldCount = 0;
098    
099            public int exceptionTableCount = 0;
100    
101            public int enclosingMethodCount = 0;
102    
103            public int deprecatedCount = 0;
104    
105            public int constantValueCount = 0;
106    
107            public int constantUtf8Count = 0;
108    
109            public int constantStringCount = 0;
110    
111            public int constantNameAndTypeCount = 0;
112    
113            public int constantPoolCount = 0;
114    
115            public int constantMethodrefCount = 0;
116    
117            public int constantLongCount = 0;
118    
119            public int constantIntegerCount = 0;
120    
121            public int constantInterfaceMethodrefCount = 0;
122    
123            public int constantFloatCount = 0;
124    
125            public int constantFieldrefCount = 0;
126    
127            public int constantClassCount = 0;
128    
129            public int constantDoubleCount = 0;
130    
131            public int codeExceptionCount = 0;
132    
133            public int codeCount = 0;
134    
135            public int annotationEntryCount = 0;
136    
137            public int annotationDefaultCount = 0;
138    
139            public int annotationCount = 0;
140    
141            public int stackMapTableCount = 0;
142    
143            public int stackMapTableEntryCount = 0;
144            
145    
146            public void visitAnnotation(Annotations obj)
147            {
148                    annotationCount++;
149            }
150    
151            public void visitAnnotationDefault(AnnotationDefault obj)
152            {
153                    annotationDefaultCount++;
154            }
155    
156            public void visitAnnotationEntry(AnnotationEntry obj)
157            {
158                    annotationEntryCount++;
159            }
160    
161            public void visitCode(Code obj)
162            {
163                    codeCount++;
164            }
165    
166            public void visitCodeException(CodeException obj)
167            {
168                    codeExceptionCount++;
169            }
170    
171            public void visitConstantClass(ConstantClass obj)
172            {
173                    constantClassCount++;
174            }
175    
176            public void visitConstantDouble(ConstantDouble obj)
177            {
178                    constantDoubleCount++;
179            }
180    
181            public void visitConstantFieldref(ConstantFieldref obj)
182            {
183                    constantFieldrefCount++;
184            }
185    
186            public void visitConstantFloat(ConstantFloat obj)
187            {
188                    constantFloatCount++;
189            }
190    
191            public void visitConstantInteger(ConstantInteger obj)
192            {
193                    constantIntegerCount++;
194            }
195    
196            public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj)
197            {
198                    constantInterfaceMethodrefCount++;
199            }
200    
201            public void visitConstantLong(ConstantLong obj)
202            {
203                    constantLongCount++;
204            }
205    
206            public void visitConstantMethodref(ConstantMethodref obj)
207            {
208                    constantMethodrefCount++;
209            }
210    
211            public void visitConstantNameAndType(ConstantNameAndType obj)
212            {
213                    constantNameAndTypeCount++;
214            }
215    
216            public void visitConstantPool(ConstantPool obj)
217            {
218                    constantPoolCount++;
219            }
220    
221            public void visitConstantString(ConstantString obj)
222            {
223                    constantStringCount++;
224            }
225    
226            public void visitConstantUtf8(ConstantUtf8 obj)
227            {
228                    constantUtf8Count++;
229            }
230    
231            public void visitConstantValue(ConstantValue obj)
232            {
233                    constantValueCount++;
234            }
235    
236            public void visitDeprecated(Deprecated obj)
237            {
238                    deprecatedCount++;
239            }
240    
241            public void visitEnclosingMethod(EnclosingMethod obj)
242            {
243                    enclosingMethodCount++;
244            }
245    
246            public void visitExceptionTable(ExceptionTable obj)
247            {
248                    exceptionTableCount++;
249            }
250    
251            public void visitField(Field obj)
252            {
253                    fieldCount++;
254            }
255    
256            public void visitInnerClass(InnerClass obj)
257            {
258                    innerClassCount++;
259            }
260    
261            public void visitInnerClasses(InnerClasses obj)
262            {
263                    innerClassesCount++;
264            }
265    
266            public void visitJavaClass(JavaClass obj)
267            {
268                    javaClassCount++;
269            }
270    
271            public void visitLineNumber(LineNumber obj)
272            {
273                    lineNumberCount++;
274            }
275    
276            public void visitLineNumberTable(LineNumberTable obj)
277            {
278                    lineNumberTableCount++;
279            }
280    
281            public void visitLocalVariable(LocalVariable obj)
282            {
283                    localVariableCount++;
284            }
285    
286            public void visitLocalVariableTable(LocalVariableTable obj)
287            {
288                    localVariableTableCount++;
289            }
290    
291            public void visitLocalVariableTypeTable(LocalVariableTypeTable obj)
292            {
293                    localVariableTypeTableCount++;
294            }
295    
296            public void visitMethod(Method obj)
297            {
298                    methodCount++;
299            }
300    
301            public void visitParameterAnnotation(ParameterAnnotations obj)
302            {
303                    parameterAnnotationCount++;
304            }
305    
306            public void visitSignature(Signature obj)
307            {
308                    signatureAnnotationCount++;
309            }
310    
311            public void visitSourceFile(SourceFile obj)
312            {
313                    sourceFileCount++;
314            }
315    
316            public void visitStackMap(StackMap obj)
317            {
318                    stackMapCount++;
319            }
320    
321            public void visitStackMapEntry(StackMapEntry obj)
322            {
323                    stackMapEntryCount++;
324            }
325    
326            public void visitSynthetic(Synthetic obj)
327            {
328                    syntheticCount++;
329            }
330    
331            public void visitUnknown(Unknown obj)
332            {
333                    unknownCount++;
334            }
335    
336            public void visitStackMapTable(StackMapTable obj) {
337                    stackMapTableCount++;
338            }
339    
340            public void visitStackMapTableEntry(StackMapTableEntry obj) {
341                    stackMapTableEntryCount++;
342            }
343    }