AllAnnotationVisitor.java revision 8a6199f0c36a778f22394364347a301b0b28e94b
1/*
2 * ProGuard -- shrinking, optimization, obfuscation, and preverification
3 *             of Java bytecode.
4 *
5 * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21package proguard.classfile.attribute.annotation.visitor;
22
23import proguard.classfile.*;
24import proguard.classfile.attribute.Attribute;
25import proguard.classfile.attribute.annotation.*;
26import proguard.classfile.attribute.visitor.AttributeVisitor;
27import proguard.classfile.util.SimplifiedVisitor;
28
29/**
30 * This AttributeVisitor lets a given AnnotationVisitor visit all Annotation
31 * objects of the attributes it visits.
32 *
33 * @author Eric Lafortune
34 */
35public class AllAnnotationVisitor
36extends      SimplifiedVisitor
37implements   AttributeVisitor
38{
39    private final AnnotationVisitor annotationVisitor;
40
41
42    /**
43     * Creates a new AllAnnotationVisitor.
44     * @param annotationVisitor the AnnotationVisitor to which visits will be
45     *                          delegated.
46     */
47    public AllAnnotationVisitor(AnnotationVisitor annotationVisitor)
48    {
49        this.annotationVisitor = annotationVisitor;
50    }
51
52
53    // Implementations for AttributeVisitor.
54
55    public void visitAnyAttribute(Clazz clazz, Attribute attribute) {}
56
57
58    public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute)
59    {
60        // Visit the annotations.
61        runtimeVisibleAnnotationsAttribute.annotationsAccept(clazz, annotationVisitor);
62    }
63
64
65    public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute)
66    {
67        // Visit the annotations.
68        runtimeVisibleAnnotationsAttribute.annotationsAccept(clazz, field, annotationVisitor);
69    }
70
71
72    public void visitRuntimeVisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleAnnotationsAttribute runtimeVisibleAnnotationsAttribute)
73    {
74        // Visit the annotations.
75        runtimeVisibleAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor);
76    }
77
78
79    public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute)
80    {
81        // Visit the annotations.
82        runtimeInvisibleAnnotationsAttribute.annotationsAccept(clazz, annotationVisitor);
83    }
84
85
86    public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute)
87    {
88        // Visit the annotations.
89        runtimeInvisibleAnnotationsAttribute.annotationsAccept(clazz, field, annotationVisitor);
90    }
91
92
93    public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute)
94    {
95        // Visit the annotations.
96        runtimeInvisibleAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor);
97    }
98
99
100    public void visitAnyParameterAnnotationsAttribute(Clazz clazz, Method method, ParameterAnnotationsAttribute parameterAnnotationsAttribute)
101    {
102        // Visit the annotations.
103        parameterAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor);
104    }
105}
106