01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: MetaDataMethodCollector.java 3678 2007-03-01 10:40:23Z gbevin $
07: */
08: package com.uwyn.rife.site.instrument;
09:
10: import java.util.*;
11:
12: import com.uwyn.rife.asm.*;
13:
14: class MetaDataMethodCollector implements ClassVisitor {
15: private Map<String, List<String>> mMethods = null;
16: private AnnotationVisitor mAnnotationVisitor = new MetaDataNoOpAnnotationVisitor();
17:
18: MetaDataMethodCollector() {
19: }
20:
21: public MethodVisitor visitMethod(int access, String name,
22: String desc, String signature, String[] exceptions) {
23: if (null == mMethods) {
24: mMethods = new HashMap<String, List<String>>();
25: }
26: List<String> descriptions = mMethods.get(name);
27: if (null == descriptions) {
28: descriptions = new ArrayList<String>();
29: mMethods.put(name, descriptions);
30: }
31: descriptions.add(desc);
32:
33: return null;
34: }
35:
36: public Map<String, List<String>> getMethods() {
37: if (null == mMethods) {
38: return Collections.EMPTY_MAP;
39: }
40:
41: return mMethods;
42: }
43:
44: public void visit(int version, int access, String name,
45: String signature, String super Name, String[] interfaces) {
46: }
47:
48: public void visitSource(String source, String debug) {
49: }
50:
51: public void visitOuterClass(String owner, String name, String desc) {
52: }
53:
54: public AnnotationVisitor visitAnnotation(String desc,
55: boolean visible) {
56: return mAnnotationVisitor;
57: }
58:
59: public void visitAttribute(Attribute attr) {
60: }
61:
62: public void visitInnerClass(String name, String outerName,
63: String innerName, int access) {
64: }
65:
66: public FieldVisitor visitField(int access, String name,
67: String desc, String signature, Object value) {
68: return null;
69: }
70:
71: public void visitEnd() {
72: }
73:
74: private class MetaDataNoOpAnnotationVisitor implements
75: AnnotationVisitor {
76: public void visit(String name, Object value) {
77: }
78:
79: public void visitEnum(String name, String desc, String value) {
80: }
81:
82: public AnnotationVisitor visitAnnotation(String name,
83: String desc) {
84: return this ;
85: }
86:
87: public AnnotationVisitor visitArray(String name) {
88: return this ;
89: }
90:
91: public void visitEnd() {
92: }
93: }
94: }
|