01: /*
02: * Copyright 2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package net.sf.cglib.transform;
17:
18: import org.objectweb.asm.*;
19:
20: abstract public class AbstractClassFilterTransformer extends
21: AbstractClassTransformer {
22: private ClassTransformer pass;
23: private ClassVisitor target;
24:
25: public void setTarget(ClassVisitor target) {
26: super .setTarget(target);
27: pass.setTarget(target);
28: }
29:
30: protected AbstractClassFilterTransformer(ClassTransformer pass) {
31: this .pass = pass;
32: }
33:
34: abstract protected boolean accept(int version, int access,
35: String name, String signature, String super Name,
36: String[] interfaces);
37:
38: public void visit(int version, int access, String name,
39: String signature, String super Name, String[] interfaces) {
40: target = accept(version, access, name, signature, super Name,
41: interfaces) ? pass : cv;
42: target.visit(version, access, name, signature, super Name,
43: interfaces);
44: }
45:
46: public void visitSource(String source, String debug) {
47: target.visitSource(source, debug);
48: }
49:
50: public void visitOuterClass(String owner, String name, String desc) {
51: target.visitOuterClass(owner, name, desc);
52: }
53:
54: public AnnotationVisitor visitAnnotation(String desc,
55: boolean visible) {
56: return target.visitAnnotation(desc, visible);
57: }
58:
59: public void visitAttribute(Attribute attr) {
60: target.visitAttribute(attr);
61: }
62:
63: public void visitInnerClass(String name, String outerName,
64: String innerName, int access) {
65: target.visitInnerClass(name, outerName, innerName, access);
66: }
67:
68: public FieldVisitor visitField(int access, String name,
69: String desc, String signature, Object value) {
70: return target.visitField(access, name, desc, signature, value);
71: }
72:
73: public MethodVisitor visitMethod(int access, String name,
74: String desc, String signature, String[] exceptions) {
75: return target.visitMethod(access, name, desc, signature,
76: exceptions);
77: }
78:
79: public void visitEnd() {
80: target.visitEnd();
81: target = null; // just to be safe
82: }
83: }
|