org.logicalcobwebs.asm.util
Class PrintClassVisitor

java.lang.Object
  extended by org.logicalcobwebs.asm.util.PrintClassVisitor
All Implemented Interfaces:
ClassVisitor
Direct Known Subclasses:
DumpClassVisitor, TraceClassVisitor

public abstract class PrintClassVisitor
extends java.lang.Object
implements ClassVisitor

An abstract class visitor that prints the classes it visits.


Field Summary
protected  java.lang.StringBuffer buf
          A buffer that can be used to create strings.
protected  java.io.PrintWriter pw
          The print writer to be used to print the class.
protected  java.util.List text
          The text to be printed.
 
Constructor Summary
PrintClassVisitor(java.io.PrintWriter pw)
          Constructs a new PrintClassVisitor object.
 
Method Summary
private  void printList(java.util.List l)
          Prints the given string tree to pw.
 void visitEnd()
          Visits the end of the class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.logicalcobwebs.asm.ClassVisitor
visit, visitAttribute, visitField, visitInnerClass, visitMethod
 

Field Detail

text

protected final java.util.List text
The text to be printed. Since the code of methods is not necessarily visited in sequential order, one method after the other, but can be interlaced (some instructions from method one, then some instructions from method two, then some instructions from method one again...), it is not possible to print the visited instructions directly to a sequential stream. A class is therefore printed in a two steps process: a string tree is constructed during the visit, and printed to a sequential stream at the end of the visit. This string tree is stored in this field, as a string list that can contain other string lists, which can themselves contain other string lists, and so on.


buf

protected final java.lang.StringBuffer buf
A buffer that can be used to create strings.


pw

protected final java.io.PrintWriter pw
The print writer to be used to print the class.

Constructor Detail

PrintClassVisitor

public PrintClassVisitor(java.io.PrintWriter pw)
Constructs a new PrintClassVisitor object.

Parameters:
pw - the print writer to be used to print the class.
Method Detail

visitEnd

public void visitEnd()
Description copied from interface: ClassVisitor
Visits the end of the class. This method, which is the last one to be called, is used to inform the visitor that all the fields and methods of the class have been visited.

Specified by:
visitEnd in interface ClassVisitor

printList

private void printList(java.util.List l)
Prints the given string tree to pw.

Parameters:
l - a string tree, i.e., a string list that can contain other string lists, and so on recursively.