FileDocCategorySizeDatePackage
SourceGenerator.javaAPI DocAndroid 1.5 API3008Wed May 06 22:41:10 BST 2009com.android.mkstubs

SourceGenerator

public class SourceGenerator extends Object
Given a set of already filtered classes, this filters out all private members and then generates the Java source for the remaining classes.

This is an helper extracted for convenience. Callers just need to use {@link #generateSource(File, Map, Filter)}.

Fields Summary
Constructors Summary
Methods Summary
java.lang.StringclassNameToJavaPath(java.lang.String className)
Utility method that converts a fully qualified java name into a JAR entry path e.g. for the input "android.view.View" it returns "android/view/View.java"

        return className.replace('.", '/").concat(".java");
    
java.io.FileWritercreateWriter(java.io.File baseDir, java.lang.String name)

        File f = new File(baseDir, name);
        f.getParentFile().mkdirs();
        
        System.out.println("Writing " + f.getPath());
        
        return new FileWriter(f);
    
public voidgenerateSource(java.io.File baseDir, java.util.Map classes, Filter filter)
Generate source for the stubbed classes, mostly for debug purposes.

throws
IOException

        
        for (Entry<String, ClassReader> entry : classes.entrySet()) {
            ClassReader cr = entry.getValue();
            
            String name = classNameToJavaPath(cr.getClassName());

            FileWriter fw = null;
            try {
                fw = createWriter(baseDir, name);
                visitClassSource(fw, cr, filter);
            } finally {
                fw.close();
            }
        }
    
voidvisitClassSource(java.io.Writer fw, org.objectweb.asm.ClassReader cr, Filter filter)
Generate a source equivalent to the stubbed version of the class reader, minus all exclusions

        System.out.println("Dump " + cr.getClassName());
        
        ClassVisitor javaWriter = new ClassSourcer(new Output(fw));
        ClassVisitor classFilter = new FilterClassAdapter(javaWriter, filter);
        cr.accept(classFilter, 0 /*flags*/);