Android Open Source - andro_auto_framework Convertor






From Project

Back to project page andro_auto_framework.

License

The source code is released under:

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...

If you think the Android project andro_auto_framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.imaginea.botbot;
/*from   w w  w.  j a  va2s.  co  m*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.util.TraceClassVisitor;

public class Convertor {

  /**
   * @param args
   * @throws IOException
   *             Use /opt/github/bot-bot/recorder/robo-bin/code-bin
   *             /opt/github/AppsList/bin/classes
   */
  public static void main(String[] args) throws IOException {
    Convertor con = new Convertor();
    con.rewriteCode(args[0],args[1]);
    con.showFile(args[1]);
  }

  public void rewriteCode(String dirPath,String outPath) throws FileNotFoundException,
      IOException {
    File dir = new File(dirPath);
    ArrayList<File> fileList = new ArrayList<File>();
    this.listDirectory(dir, fileList);
    String filePath = outPath;
    if (new File(filePath).exists()) {
      this.deleteDir(new File(filePath));
      new File(filePath).mkdirs();
    }
    for (File f : fileList) {
      ClassWriter cw = new ClassWriter(0);
      CustomVisitor cv = new CustomVisitor(cw);
      ClassReader cr = new ClassReader(new FileInputStream(f));
      cr.accept(cv, 0);
      //cr.accept(new TraceClassVisitor(new PrintWriter(System.out)), 0);
      filePath = outPath;
      filePath = f.getAbsolutePath().replace(dirPath, filePath);
      //System.out.println("Out filepath is: "+filePath);
      new File(filePath).getParentFile().mkdirs();
      FileOutputStream fo = new FileOutputStream(filePath);
      fo.write(cw.toByteArray());
      fo.close();
    }

  }

  public void showFile(String outPath) throws FileNotFoundException, IOException {
    ArrayList<File> afterList = new ArrayList<File>();
    File afterDir = new File(outPath);
    this.listDirectory(afterDir, afterList);
    for (File f : afterList) {
      //System.out.println(f.getAbsolutePath());
      ClassWriter cw = new ClassWriter(0);
      CustomVisitor cv = new CustomVisitor(cw);
      ClassReader cr = new ClassReader(new FileInputStream(f));
      cr.accept(cv, 0);
    }
  }

  private boolean deleteDir(File dir) {
    if (dir.isDirectory()) {
      String[] children = dir.list();
      for (int i = 0; i < children.length; i++) {
        boolean success = deleteDir(new File(dir, children[i]));
        if (!success) {
          return false;
        }
      }
    }

    // The directory is now empty so delete it
    return dir.delete();
  }

  public void listDirectory(File f, ArrayList<File> fileList) {
    File[] listOfFiles = f.listFiles();
    for (int i = 0; i < listOfFiles.length; i++) {
      if (listOfFiles[i].isFile()) {
        fileList.add(listOfFiles[i]);
      } else if (listOfFiles[i].isDirectory()) {
        listDirectory(listOfFiles[i], fileList);
      }
    }
  }

}




Java Source Code List

com.imaginea.botbot.server.converter.RecordEntriesConverter.java
com.imaginea.botbot.server.converter.RecordEntryConverter.java
com.imaginea.botbot.server.converter.RecordSessionConverter.java
com.imaginea.botbot.server.converter.RecordSessionsConverter.java
com.imaginea.botbot.server.converter.UriResolver.java
com.imaginea.botbot.server.jpa.RecordEntry.java
com.imaginea.botbot.server.jpa.RecordSession.java
com.imaginea.botbot.server.service.PersistenceService.java
com.imaginea.botbot.server.service.RecordEntriesResource.java
com.imaginea.botbot.server.service.RecordEntryResource.java
com.imaginea.botbot.server.service.RecordSessionResource.java
com.imaginea.botbot.server.service.RecordSessionsResource.java
com.imaginea.botbot.server.servlet.DownloadCsv.java
com.zutubi.android.junitreport.JUnitReportListener.java
com.zutubi.android.junitreport.JUnitReportTestRunner.java
com.zutubi.android.junitreport.TestKeeper.java
com.zutubi.android.junitreport.TestngReportListener.java
org.imaginea.botbot.CommandTransmitter.java
org.imaginea.botbot.Command.java
org.imaginea.botbot.Convertor.java
org.imaginea.botbot.CustomVisitor.java
org.imaginea.botbot.ListenerAdder.java
org.imaginea.botbot.OnClickListenerTest.java
org.imaginea.botbot.OnItemClickListenerTest.java
org.imaginea.botbot.OnItemSelectedListenerTest.java
org.imaginea.botbot.OnTouchListenerTest.java
org.imaginea.botbot.Recorder.java
org.imaginea.botbot.ServerProperties.java
org.imaginea.botbot.TextListner.java
org.imaginea.botbot.ViewClasses.java
org.imaginea.botbot.api.DefaultProperties.java
org.imaginea.botbot.api.IdentifyByType.java
org.imaginea.botbot.api.TestCSVReader.java
org.imaginea.botbot.api.UsefulFunctions.java
org.imaginea.botbot.common.AndroFrameworkExecutorDataDriven.java
org.imaginea.botbot.common.AndroFrameworkExecutor.java
org.imaginea.botbot.common.BaseClass.java
org.imaginea.botbot.common.BotBotTestRunner.java
org.imaginea.botbot.common.CommandExecutor.java
org.imaginea.botbot.common.Command.java
org.imaginea.botbot.common.DataDrivenTestCase.java
org.imaginea.botbot.common.Prefrences.java
org.imaginea.botbot.common.RobotiumBaseClass.java
org.imaginea.botbot.common.TestCaseGenerator.java
org.imaginea.botbot.filereader.BaseReader.java
org.imaginea.botbot.filereader.FileTypeReader.java
org.imaginea.botbot.filereader.PropertiesReader.java
org.imaginea.botbot.keywords.BaseKeywordDefinitions.java
org.imaginea.botbot.keywords.DynamicExecution.java
org.imaginea.botbot.keywords.IKeywords.java
org.imaginea.botbot.keywords.KeywordCaller.java
org.imaginea.botbot.keywords.NativeDriverKeywordDefinitions.java
org.imaginea.botbot.keywords.RobotiumKeywordDefinition.java
org.imaginea.botbot.utility.DataDrivenDataGenerator.java
org.imaginea.botbot.utility.WebViewHandler.java