TreeClassAdapterpublic 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);
}
|
Fields Summary |
---|
public ClassNode | classNodeA tree representation of the class that is being visited by this visitor. |
Constructors Summary |
---|
public TreeClassAdapter(ClassVisitor cv)Constructs a new {@link TreeClassAdapter TreeClassAdapter} object.
super(cv);
|
Methods Summary |
---|
public void | visit(int version, int access, java.lang.String name, java.lang.String superName, java.lang.String[] interfaces, java.lang.String sourceFile)
classNode = new ClassNode(version, access, name, superName, interfaces, sourceFile);
| public void | visitAttribute(oracle.toplink.libraries.asm.Attribute attr)
attr.next = classNode.attrs;
classNode.attrs = attr;
| public void | visitEnd()
if( cv!=null) {
classNode.accept(cv);
}
| public void | visitField(int access, java.lang.String name, java.lang.String desc, java.lang.Object value, oracle.toplink.libraries.asm.Attribute attrs)
FieldNode fn = new FieldNode(access, name, desc, value, attrs);
classNode.fields.add(fn);
| public void | visitInnerClass(java.lang.String name, java.lang.String outerName, java.lang.String innerName, int access)
InnerClassNode icn = new InnerClassNode(name, outerName, innerName, access);
classNode.innerClasses.add(icn);
| public oracle.toplink.libraries.asm.CodeVisitor | visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String[] exceptions, oracle.toplink.libraries.asm.Attribute attrs)
MethodNode mn = new MethodNode(access, name, desc, exceptions, attrs);
classNode.methods.add(mn);
return new TreeCodeAdapter(mn);
|
|