01: /*
02: * Copyright 2003,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: public class ClassTransformerChain extends AbstractClassTransformer {
21: private ClassTransformer[] chain;
22:
23: public ClassTransformerChain(ClassTransformer[] chain) {
24: this .chain = (ClassTransformer[]) chain.clone();
25: }
26:
27: public void setTarget(ClassVisitor v) {
28: super .setTarget(chain[0]);
29: ClassVisitor next = v;
30: for (int i = chain.length - 1; i >= 0; i--) {
31: chain[i].setTarget(next);
32: next = chain[i];
33: }
34: }
35:
36: public MethodVisitor visitMethod(int access, String name,
37: String desc, String signature, String[] exceptions) {
38: return cv
39: .visitMethod(access, name, desc, signature, exceptions);
40: }
41:
42: public String toString() {
43: StringBuffer sb = new StringBuffer();
44: sb.append("ClassTransformerChain{");
45: for (int i = 0; i < chain.length; i++) {
46: if (i > 0) {
47: sb.append(", ");
48: }
49: sb.append(chain[i].toString());
50: }
51: sb.append("}");
52: return sb.toString();
53: }
54: }
|