org.objectweb.asm.tree

Class TreeClassAdapter

public class TreeClassAdapter extends ClassAdapter

A {@link ClassAdapter ClassAdapter} that constructs a tree representation of the classes it vists. Each visitXXX method of this class constructs an XXXNode and adds it to the {@link #classNode classNode} node (except the {@link #visitEnd visitEnd} method, which just makes the {@link #cv cv} class visitor visit the tree that has just been constructed).

In order to implement a usefull class adapter based on a tree representation of classes, one just need to override the {@link #visitEnd visitEnd} method with a method of the following form:

 public void visitEnd () {
   // ...
   // code to modify the classNode tree, can be arbitrary complex
   // ...
   // makes the cv visitor visit this modified class:
   classNode.accept(cv);
 }
 

Author: Eric Bruneton

Field Summary
ClassNodeclassNode
A tree representation of the class that is being visited by this visitor.
Constructor Summary
TreeClassAdapter(ClassVisitor cv)
Constructs a new {@link TreeClassAdapter TreeClassAdapter} object.
Method Summary
voidvisit(int version, int access, String name, String superName, String[] interfaces, String sourceFile)
voidvisitAttribute(Attribute attr)
voidvisitEnd()
voidvisitField(int access, String name, String desc, Object value, Attribute attrs)
voidvisitInnerClass(String name, String outerName, String innerName, int access)
CodeVisitorvisitMethod(int access, String name, String desc, String[] exceptions, Attribute attrs)

Field Detail

classNode

public ClassNode classNode
A tree representation of the class that is being visited by this visitor.

Constructor Detail

TreeClassAdapter

public TreeClassAdapter(ClassVisitor cv)
Constructs a new {@link TreeClassAdapter TreeClassAdapter} object.

Parameters: cv the class visitor to which this adapter must delegate calls.

Method Detail

visit

public void visit(int version, int access, String name, String superName, String[] interfaces, String sourceFile)

visitAttribute

public void visitAttribute(Attribute attr)

visitEnd

public void visitEnd()

visitField

public void visitField(int access, String name, String desc, Object value, Attribute attrs)

visitInnerClass

public void visitInnerClass(String name, String outerName, String innerName, int access)

visitMethod

public CodeVisitor visitMethod(int access, String name, String desc, String[] exceptions, Attribute attrs)