org.objectweb.asm.tree

Class TreeClassAdapter

Implemented Interfaces:
ClassVisitor

public class TreeClassAdapter
extends ClassAdapter

A 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 classNode node (except the visitEnd method, which just makes the 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 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

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

Fields inherited from class org.objectweb.asm.ClassAdapter

cv

Constructor Summary

TreeClassAdapter(ClassVisitor cv)
Constructs a new TreeClassAdapter object.

Method Summary

void
visit(int version, int access, String name, String superName, String[] interfaces, String sourceFile)
void
visitAttribute(Attribute attr)
void
visitEnd()
void
visitField(int access, String name, String desc, Object value, Attribute attrs)
void
visitInnerClass(String name, String outerName, String innerName, int access)
CodeVisitor
visitMethod(int access, String name, String desc, String[] exceptions, Attribute attrs)

Methods inherited from class org.objectweb.asm.ClassAdapter

visit, visitAttribute, visitEnd, visitField, visitInnerClass, visitMethod

Field Details

classNode

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

Constructor Details

TreeClassAdapter

public TreeClassAdapter(ClassVisitor cv)
Constructs a new TreeClassAdapter object.
Parameters:
cv - the class visitor to which this adapter must delegate calls.

Method Details

visit

public void visit(int version,
                  int access,
                  String name,
                  String superName,
                  String[] interfaces,
                  String sourceFile)
Specified by:
visit in interface ClassVisitor
Overrides:
visit in interface ClassAdapter

visitAttribute

public void visitAttribute(Attribute attr)
Specified by:
visitAttribute in interface ClassVisitor
Overrides:
visitAttribute in interface ClassAdapter

visitEnd

public void visitEnd()
Specified by:
visitEnd in interface ClassVisitor
Overrides:
visitEnd in interface ClassAdapter

visitField

public void visitField(int access,
                       String name,
                       String desc,
                       Object value,
                       Attribute attrs)
Specified by:
visitField in interface ClassVisitor
Overrides:
visitField in interface ClassAdapter

visitInnerClass

public void visitInnerClass(String name,
                            String outerName,
                            String innerName,
                            int access)
Specified by:
visitInnerClass in interface ClassVisitor
Overrides:
visitInnerClass in interface ClassAdapter

visitMethod

public CodeVisitor visitMethod(int access,
                               String name,
                               String desc,
                               String[] exceptions,
                               Attribute attrs)
Specified by:
visitMethod in interface ClassVisitor
Overrides:
visitMethod in interface ClassAdapter