KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > transform > inlining > AsmNullAdapter


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.aspectwerkz.transform.inlining;
5
6 import com.tc.asm.*;
7
8 /**
9  * Visitors that are not writing any bytecode and using a Null ClassVisitor / Code Visitor as a target instead.
10  *
11  * @author <a HREF="mailto:alex@gnilux.com">Alexandre Vasseur</a>
12  */

13 public class AsmNullAdapter {
14
15   /**
16    * A NullClassAdapter that does nothing.
17    * Can be used to speed up ASM and avoid unecessary bytecode writing thru a regular ClassWriter when this is not
18    * needed (read only purpose).
19    */

20   public static class NullClassAdapter implements ClassVisitor {
21
22     public final static ClassVisitor NULL_CLASS_ADAPTER = new NullClassAdapter();
23
24     public void visit(int version, int access, String JavaDoc name, String JavaDoc signature, String JavaDoc superName, String JavaDoc[] interfaces) {
25     }
26
27     public void visitInnerClass(String JavaDoc name, String JavaDoc outerName, String JavaDoc innerName, int access) {
28     }
29
30     public FieldVisitor visitField(int access, String JavaDoc name, String JavaDoc desc, String JavaDoc signature, Object JavaDoc value) {
31       return NullFieldAdapter.NULL_FIELD_ADAPTER;
32     }
33
34     public MethodVisitor visitMethod(int access, String JavaDoc name, String JavaDoc desc, String JavaDoc signature, String JavaDoc[] exceptions) {
35       return NullMethodAdapter.NULL_METHOD_ADAPTER;
36     }
37
38     public void visitSource(String JavaDoc source, String JavaDoc debug) {
39     }
40
41     public void visitOuterClass(String JavaDoc owner, String JavaDoc name, String JavaDoc desc) {
42     }
43
44     public AnnotationVisitor visitAnnotation(String JavaDoc desc, boolean visible) {
45       return NullAnnotationVisitor.NULL_ANNOTATION_ADAPTER;
46     }
47
48     public void visitAttribute(Attribute attribute) {
49     }
50
51     public void visitEnd() {
52     }
53   }
54
55   /**
56    * A NullMethodAdapter that does nothing.
57    * Can be used to speed up ASM and avoid unecessary bytecode writing thru a regular CodeWriter when this is not
58    * needed (read only purpose)
59    */

60   public static class NullMethodAdapter implements MethodVisitor {
61
62     public final static MethodVisitor NULL_METHOD_ADAPTER = new NullMethodAdapter();
63
64     public void visitInsn(int opcode) {
65     }
66
67     public void visitIntInsn(int opcode, int operand) {
68     }
69
70     public void visitVarInsn(int opcode, int var) {
71     }
72
73     public void visitTypeInsn(int opcode, String JavaDoc desc) {
74     }
75
76     public void visitFieldInsn(int opcode, String JavaDoc owner, String JavaDoc name, String JavaDoc desc) {
77     }
78
79     public void visitMethodInsn(int opcode, String JavaDoc owner, String JavaDoc name, String JavaDoc desc) {
80     }
81
82     public void visitJumpInsn(int opcode, Label label) {
83     }
84
85     public void visitLabel(Label label) {
86     }
87
88     public void visitLdcInsn(Object JavaDoc cst) {
89     }
90
91     public void visitIincInsn(int var, int increment) {
92     }
93
94     public void visitTableSwitchInsn(int min, int max, Label dflt, Label labels[]) {
95     }
96
97     public void visitLookupSwitchInsn(Label dflt, int keys[], Label labels[]) {
98     }
99
100     public void visitMultiANewArrayInsn(String JavaDoc desc, int dims) {
101     }
102
103     public void visitTryCatchBlock(Label start, Label end, Label handler, String JavaDoc type) {
104     }
105
106     public void visitMaxs(int maxStack, int maxLocals) {
107     }
108
109     public void visitLocalVariable(String JavaDoc name, String JavaDoc desc, String JavaDoc sig, Label start, Label end, int index) {
110     }
111
112     public void visitLineNumber(int line, Label start) {
113     }
114
115     public void visitAttribute(Attribute attr) {
116     }
117
118     public AnnotationVisitor visitAnnotationDefault() {
119       return NullAnnotationVisitor.NULL_ANNOTATION_ADAPTER;
120     }
121
122     public AnnotationVisitor visitAnnotation(String JavaDoc desc, boolean visible) {
123       return NullAnnotationVisitor.NULL_ANNOTATION_ADAPTER;
124     }
125
126     public AnnotationVisitor visitParameterAnnotation(int parameter, String JavaDoc desc, boolean visible) {
127       return NullAnnotationVisitor.NULL_ANNOTATION_ADAPTER;
128     }
129
130     public void visitCode() {
131     }
132
133     public void visitEnd() {
134     }
135   }
136
137   /**
138    * A NullFieldAdapter
139    */

140   public static class NullFieldAdapter implements FieldVisitor {
141
142     public final static FieldVisitor NULL_FIELD_ADAPTER = new NullFieldAdapter();
143
144     public AnnotationVisitor visitAnnotation(String JavaDoc desc, boolean visible) {
145       return NullAnnotationVisitor.NULL_ANNOTATION_ADAPTER;
146     }
147
148     public void visitAttribute(Attribute attr) {
149     }
150
151     public void visitEnd() {
152     }
153   }
154
155   /**
156    * A NullAnnotationVisitor
157    */

158   public static class NullAnnotationVisitor implements AnnotationVisitor {
159
160     public final static AnnotationVisitor NULL_ANNOTATION_ADAPTER = new NullAnnotationVisitor();
161
162     public void visit(String JavaDoc name, Object JavaDoc value) {
163     }
164
165     public void visitEnum(String JavaDoc name, String JavaDoc desc, String JavaDoc value) {
166     }
167
168     public AnnotationVisitor visitAnnotation(String JavaDoc name, String JavaDoc desc) {
169       return NULL_ANNOTATION_ADAPTER;
170     }
171
172     public AnnotationVisitor visitArray(String JavaDoc name) {
173       return NULL_ANNOTATION_ADAPTER;
174     }
175
176     public void visitEnd() {
177     }
178   }
179 }
180
Popular Tags