FileDocCategorySizeDatePackage
PrintClassVisitor.javaAPI DocGlassfish v2 API5259Thu Mar 02 11:51:18 GMT 2006oracle.toplink.libraries.asm.util

PrintClassVisitor

public abstract class PrintClassVisitor extends Object implements ClassVisitor
An abstract class visitor that prints the classes it visits.
author
Eric Bruneton, Eugene Kuleshov

Fields Summary
protected final 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.
protected final StringBuffer
buf
A buffer that can be used to create strings.
protected final PrintWriter
pw
The print writer to be used to print the class.
Constructors Summary
protected PrintClassVisitor(PrintWriter pw)
Constructs a new {@link PrintClassVisitor PrintClassVisitor} object.

param
pw the print writer to be used to print the class.

    this.text = new ArrayList();
    this.buf = new StringBuffer();
    this.pw = pw;
  
Methods Summary
public static oracle.toplink.libraries.asm.Attribute[]getDefaultAttributes()

    try {
      return new Attribute[] {
        new ASMAnnotationDefaultAttribute(),
        new ASMRuntimeInvisibleAnnotations(),
        new ASMRuntimeInvisibleParameterAnnotations(),
        new ASMRuntimeVisibleAnnotations(),
        new ASMRuntimeVisibleParameterAnnotations(),
        new ASMStackMapAttribute(),
        new ASMSourceDebugExtensionAttribute(),
        new ASMSignatureAttribute(),
        new ASMEnclosingMethodAttribute(),
        new ASMLocalVariableTypeTableAttribute()
      };
    } catch (Exception e) {
      return new Attribute[0];
    }
  
private voidprintList(java.util.List l)
Prints the given string tree to {@link #pw pw}.

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

    for (int i = 0; i < l.size(); ++i) {
      Object o = l.get(i);
      if (o instanceof List) {
        printList((List)o);
      } else {
        pw.print(o.toString());
      }
    }
  
public voidvisitEnd()

    printList(text);
    pw.flush();