FileDocCategorySizeDatePackage
Main.javaAPI DocAndroid 1.5 API3118Wed May 06 22:41:02 BST 2009com.android.hit

Main

public class Main extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

        FileInputStream fis;
        BufferedInputStream bis;
        DataInputStream dis;
        
        try {
            fis = new FileInputStream(argv[0]);
            bis = new BufferedInputStream(fis);
            dis = new DataInputStream(bis);
            
            State state = (new HprofParser(dis)).parse();

            dis.close();
            
            testClassesQuery(state);
            testAllClassesQuery(state);
            testFindInstancesOf(state);
            testFindAllInstancesOf(state);
        } catch (Exception e) {
            e.printStackTrace();
        }
    
private static voidtestAllClassesQuery(State state)

        Map<String, Set<ClassObj>> allClasses = Queries.allClasses(state);
        
        for (String thePackage: allClasses.keySet()) {
            System.out.println("------------------- " + thePackage);
            
            Set<ClassObj> classes = allClasses.get(thePackage);
            
            for (ClassObj theClass: classes) {
                System.out.println("     " + theClass.mClassName);
            }
        }
    
private static voidtestClassesQuery(State state)

        String[] x = new String[] {
            "char[",
            "javax.",
            "org.xml.sax"
        };
        
        Map<String, Set<ClassObj>> someClasses = Queries.classes(state, x);
        
        for (String thePackage: someClasses.keySet()) {
            System.out.println("------------------- " + thePackage);
            
            Set<ClassObj> classes = someClasses.get(thePackage);
            
            for (ClassObj theClass: classes) {
                System.out.println("     " + theClass.mClassName);
            }
        }
    
private static voidtestFindAllInstancesOf(State state)

        Instance[] instances = Queries.allInstancesOf(state, 
            "android.graphics.drawable.Drawable");
        
        System.out.println("There are " + instances.length
            + " instances of Drawables and its subclasses.");
    
private static voidtestFindInstancesOf(State state)

        Instance[] instances = Queries.instancesOf(state, "java.lang.String");
        
        System.out.println("There are " + instances.length + " Strings.");