1 6 7 package org.netbeans.modules.piaget.analyze; 8 9 import java.io.File ; 10 import java.io.FileInputStream ; 11 import java.io.FileNotFoundException ; 12 import java.io.FileWriter ; 13 import java.io.IOException ; 14 import java.util.Properties ; 15 16 20 public class Analyzer { 21 22 private static StringBuffer commentBuffer, propertyBuffer; 23 24 public static void writeComment(String s){ 25 commentBuffer.append("# " + s + "\n"); 26 } 27 28 public static void writeProperty(String key, String value){ 29 propertyBuffer.append(key + "=" + value + "\n"); 30 } 31 32 public static void analyze(File userfile) { 33 File sessionFiles [] = userfile.listFiles(); 34 35 for(int i=0; i<sessionFiles.length; i++){ 36 String outFilename = sessionFiles[i].getAbsolutePath(); 37 int index = outFilename.lastIndexOf("session"); 38 39 if(index < 0) continue; 41 42 outFilename = outFilename.substring(0,index) + "parsed"; 43 44 commentBuffer = new StringBuffer (); 45 propertyBuffer = new StringBuffer (); 46 47 session(sessionFiles[i]); 48 49 try{ 50 File outFile = new File (outFilename); 51 String comments = commentBuffer.toString(); 52 String properties = propertyBuffer.toString(); 53 54 FileWriter out = new FileWriter (outFile); 55 out.write(comments); 56 out.write(properties); 57 out.write("\n"); 58 out.flush(); 59 out.close(); 60 } catch(IOException e){ 61 e.printStackTrace(); 62 } 63 } 64 } 65 66 private static void session(File f){ 67 File [] content = f.listFiles(); 68 for(int i=0; i<content.length; i++){ 69 String name = content[i].getName(); 70 if(name.endsWith("COR.log")){ 71 }else if(name.endsWith("DOC.log")){ 73 new DOCAnalyzer(content[i]); 74 }else if(name.endsWith("TCR.log")){ 75 new TCRAnalyzer(content[i]); 76 }else if(name.endsWith("WM.log")){ 77 new WMAnalyzer(content[i]); 78 }else{ 79 System.out.println("UNEXPECTED CASE:"+content[i].getName()); 80 } 81 } 82 } 83 } | Popular Tags |