/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package buzzerproxy; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Enger */ public class GoogleResultParser { public String parseResults(String rawResults) { if ( rawResults == null || !(rawResults instanceof String) ){ Exception e = new Exception(); Logger.getLogger(GoogleResultParser.class.getName()).log(Level.SEVERE, null, e); System.exit(1); } // if ( str == null || !(str instanceof String)){ StringBuilder sb = new StringBuilder(); String[] arr = rawResults.split("\""); sb.append(""); sb.append(""); sb.append("Results"); for (int i = 0; i < arr.length; i++) { int pos = i + 2; // System.out.println("array"+i+" :"+arr[i]); //titleNoFormatting unescapedUrl if (arr[i].equalsIgnoreCase("titleNoFormatting")) { sb.append(""); sb.append(arr[pos]); sb.append(""); } if (arr[i].equalsIgnoreCase("unescapedUrl")) { sb.append(""); sb.append(arr[pos]); sb.append(""); // System.out.println("REAL POSITION: '" + arr[i] + "'"); // System.out.println("ARRAY PèOSTITION: " + arr[pos]); } } // for (int i = 0; i < arr.length; i++) { sb.append(""); sb.append(""); return sb.toString(); } // public String parseResults(String rawResults) { //// public static void main(String[] args) { //// //// String file = new String("G:\\results.txt"); //// String fileContent = ""; //// try { //// fileContent = Gzip.readFileAsString(file); //// } catch (IOException ex) { //// Logger.getLogger(GoogleResultParser.class.getName()).log(Level.SEVERE, null, ex); //// } //// System.out.println(parseResults(fileContent)); //// //// //// } } // public class GoogleResultParser {