01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object.bytecode;
05:
06: import com.tc.asm.AnnotationVisitor;
07:
08: /**
09: * AnnotationVisitor that is able to delegate all the calls to an array of
10: * other annotation visitors.
11: */
12: public class MulticastAnnotationVisitor implements AnnotationVisitor {
13:
14: private final AnnotationVisitor[] visitors;
15:
16: public MulticastAnnotationVisitor(AnnotationVisitor[] visitors) {
17: this .visitors = visitors;
18: }
19:
20: public void visit(String name, Object value) {
21: for (int i = 0; i < visitors.length; i++) {
22: visitors[i].visit(name, value);
23: }
24: }
25:
26: public AnnotationVisitor visitAnnotation(String name, String desc) {
27: AnnotationVisitor[] annotationVisitors = new AnnotationVisitor[visitors.length];
28: for (int i = 0; i < visitors.length; i++) {
29: annotationVisitors[i] = visitors[i].visitAnnotation(name,
30: desc);
31: }
32:
33: return new MulticastAnnotationVisitor(annotationVisitors);
34: }
35:
36: public AnnotationVisitor visitArray(String name) {
37: AnnotationVisitor[] annotationVisitors = new AnnotationVisitor[visitors.length];
38: for (int i = 0; i < visitors.length; i++) {
39: annotationVisitors[i] = visitors[i].visitArray(name);
40: }
41:
42: return new MulticastAnnotationVisitor(annotationVisitors);
43: }
44:
45: public void visitEnd() {
46: for (int i = 0; i < visitors.length; i++) {
47: visitors[i].visitEnd();
48: }
49: }
50:
51: public void visitEnum(String name, String desc, String value) {
52: for (int i = 0; i < visitors.length; i++) {
53: visitors[i].visitEnum(name, desc, value);
54: }
55: }
56: }
|