SourceGeneratorpublic 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)}. |
Methods Summary |
---|
java.lang.String | classNameToJavaPath(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.FileWriter | createWriter(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 void | generateSource(java.io.File baseDir, java.util.Map classes, Filter filter)Generate source for the stubbed classes, mostly for debug purposes.
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();
}
}
| void | visitClassSource(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*/);
|
|