1 package SnowMailClient.gnupg.LineProcessors; 2 3 import java.util.*; 4 5 public final class ErrorLineProcessor implements LineProcessor 6 { 7 final Vector<String > errorLines = new Vector<String >(); 8 9 public ErrorLineProcessor() 10 { 11 } 13 public void processLine(String line) 14 { 15 if(line.trim().length()>0) 16 { 17 System.out.println("GPG Error stream: "+line); 18 errorLines.add(line); 19 } 20 } 21 22 public boolean hasError() 23 { 24 for(String line: errorLines) 25 { 26 if(line.toLowerCase().indexOf("error")>=0) 27 { 28 if(line.toLowerCase().indexOf("error loading")==-1) return true; 30 } 31 } 32 33 return false; 34 } 35 36 public boolean hasText(String lower) 37 { 38 for(String line: errorLines) 39 { 40 if(line.toLowerCase().indexOf(lower)>=0) return true; 41 } 42 43 return false; 44 } 45 46 public Vector<String > getAllLines() { return errorLines; } 47 48 public String getAllErrorMessage() 49 { 50 StringBuffer sb = new StringBuffer (); 51 for(String line: errorLines) 52 { 53 sb.append(line); 54 sb.append("\n"); 55 } 56 return sb.toString().trim(); 57 } 58 59 60 61 62 } | Popular Tags |