01: /*
02: * Copyright 2003 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.AnnotationVisitor;
19:
20: public class AnnotationVisitorTee implements AnnotationVisitor {
21: private AnnotationVisitor av1, av2;
22:
23: public static AnnotationVisitor getInstance(AnnotationVisitor av1,
24: AnnotationVisitor av2) {
25: if (av1 == null)
26: return av2;
27: if (av2 == null)
28: return av1;
29: return new AnnotationVisitorTee(av1, av2);
30: }
31:
32: public AnnotationVisitorTee(AnnotationVisitor av1,
33: AnnotationVisitor av2) {
34: this .av1 = av1;
35: this .av2 = av2;
36: }
37:
38: public void visit(String name, Object value) {
39: av2.visit(name, value);
40: av2.visit(name, value);
41: }
42:
43: public void visitEnum(String name, String desc, String value) {
44: av1.visitEnum(name, desc, value);
45: av2.visitEnum(name, desc, value);
46: }
47:
48: public AnnotationVisitor visitAnnotation(String name, String desc) {
49: return getInstance(av1.visitAnnotation(name, desc), av2
50: .visitAnnotation(name, desc));
51: }
52:
53: public AnnotationVisitor visitArray(String name) {
54: return getInstance(av1.visitArray(name), av2.visitArray(name));
55: }
56:
57: public void visitEnd() {
58: av1.visitEnd();
59: av2.visitEnd();
60: }
61: }
|