1 /***
2  * ASM: a very small and fast Java bytecode manipulation framework
3  * Copyright (c) 2000-2005 INRIA, France Telecom
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holders nor the names of its
15  *    contributors may be used to endorse or promote products derived from
16  *    this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28  * THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 package org.objectweb.asm;
31 
32 /**
33  * An empty {@link MethodVisitor} that delegates to another
34  * {@link MethodVisitor}. This class can be used as a super class to quickly
35  * implement usefull method adapter classes, just by overriding the necessary
36  * methods.
37  *
38  * @author Eric Bruneton
39  */
40 public class MethodAdapter implements MethodVisitor {
41 
42     /**
43      * The {@link MethodVisitor} to which this adapter delegates calls.
44      */
45     protected MethodVisitor mv;
46 
47     /**
48      * Constructs a new {@link MethodAdapter} object.
49      *
50      * @param mv the code visitor to which this adapter must delegate calls.
51      */
MethodAdapter(final MethodVisitor mv)52     public MethodAdapter(final MethodVisitor mv) {
53         this.mv = mv;
54     }
55 
visitAnnotationDefault()56     public AnnotationVisitor visitAnnotationDefault() {
57         return mv.visitAnnotationDefault();
58     }
59 
visitAnnotation( final String desc, final boolean visible)60     public AnnotationVisitor visitAnnotation(
61         final String desc,
62         final boolean visible)
63     {
64         return mv.visitAnnotation(desc, visible);
65     }
66 
visitParameterAnnotation( final int parameter, final String desc, final boolean visible)67     public AnnotationVisitor visitParameterAnnotation(
68         final int parameter,
69         final String desc,
70         final boolean visible)
71     {
72         return mv.visitParameterAnnotation(parameter, desc, visible);
73     }
74 
visitAttribute(final Attribute attr)75     public void visitAttribute(final Attribute attr) {
76         mv.visitAttribute(attr);
77     }
78 
visitCode()79     public void visitCode() {
80         mv.visitCode();
81     }
82 
visitInsn(final int opcode)83     public void visitInsn(final int opcode) {
84         mv.visitInsn(opcode);
85     }
86 
visitIntInsn(final int opcode, final int operand)87     public void visitIntInsn(final int opcode, final int operand) {
88         mv.visitIntInsn(opcode, operand);
89     }
90 
visitVarInsn(final int opcode, final int var)91     public void visitVarInsn(final int opcode, final int var) {
92         mv.visitVarInsn(opcode, var);
93     }
94 
visitTypeInsn(final int opcode, final String desc)95     public void visitTypeInsn(final int opcode, final String desc) {
96         mv.visitTypeInsn(opcode, desc);
97     }
98 
visitFieldInsn( final int opcode, final String owner, final String name, final String desc)99     public void visitFieldInsn(
100         final int opcode,
101         final String owner,
102         final String name,
103         final String desc)
104     {
105         mv.visitFieldInsn(opcode, owner, name, desc);
106     }
107 
visitMethodInsn( final int opcode, final String owner, final String name, final String desc)108     public void visitMethodInsn(
109         final int opcode,
110         final String owner,
111         final String name,
112         final String desc)
113     {
114         mv.visitMethodInsn(opcode, owner, name, desc);
115     }
116 
visitJumpInsn(final int opcode, final Label label)117     public void visitJumpInsn(final int opcode, final Label label) {
118         mv.visitJumpInsn(opcode, label);
119     }
120 
visitLabel(final Label label)121     public void visitLabel(final Label label) {
122         mv.visitLabel(label);
123     }
124 
visitLdcInsn(final Object cst)125     public void visitLdcInsn(final Object cst) {
126         mv.visitLdcInsn(cst);
127     }
128 
visitIincInsn(final int var, final int increment)129     public void visitIincInsn(final int var, final int increment) {
130         mv.visitIincInsn(var, increment);
131     }
132 
visitTableSwitchInsn( final int min, final int max, final Label dflt, final Label labels[])133     public void visitTableSwitchInsn(
134         final int min,
135         final int max,
136         final Label dflt,
137         final Label labels[])
138     {
139         mv.visitTableSwitchInsn(min, max, dflt, labels);
140     }
141 
visitLookupSwitchInsn( final Label dflt, final int keys[], final Label labels[])142     public void visitLookupSwitchInsn(
143         final Label dflt,
144         final int keys[],
145         final Label labels[])
146     {
147         mv.visitLookupSwitchInsn(dflt, keys, labels);
148     }
149 
visitMultiANewArrayInsn(final String desc, final int dims)150     public void visitMultiANewArrayInsn(final String desc, final int dims) {
151         mv.visitMultiANewArrayInsn(desc, dims);
152     }
153 
visitTryCatchBlock( final Label start, final Label end, final Label handler, final String type)154     public void visitTryCatchBlock(
155         final Label start,
156         final Label end,
157         final Label handler,
158         final String type)
159     {
160         mv.visitTryCatchBlock(start, end, handler, type);
161     }
162 
visitLocalVariable( final String name, final String desc, final String signature, final Label start, final Label end, final int index)163     public void visitLocalVariable(
164         final String name,
165         final String desc,
166         final String signature,
167         final Label start,
168         final Label end,
169         final int index)
170     {
171         mv.visitLocalVariable(name, desc, signature, start, end, index);
172     }
173 
visitLineNumber(final int line, final Label start)174     public void visitLineNumber(final int line, final Label start) {
175         mv.visitLineNumber(line, start);
176     }
177 
visitMaxs(final int maxStack, final int maxLocals)178     public void visitMaxs(final int maxStack, final int maxLocals) {
179         mv.visitMaxs(maxStack, maxLocals);
180     }
181 
visitEnd()182     public void visitEnd() {
183         mv.visitEnd();
184     }
185 }
186