KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SnowMailClient > gnupg > LineProcessors > ErrorLineProcessor


1 package SnowMailClient.gnupg.LineProcessors;
2
3 import java.util.*;
4
5 public final class ErrorLineProcessor implements LineProcessor
6 {
7   final Vector<String JavaDoc> errorLines = new Vector<String JavaDoc>();
8
9   public ErrorLineProcessor()
10   {
11   } // Constructor
12

13   public void processLine(String JavaDoc 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 JavaDoc line: errorLines)
25      {
26         if(line.toLowerCase().indexOf("error")>=0)
27         {
28           // ignore loading errors, occur in 1.4 cause an iconv.dll not found
29
if(line.toLowerCase().indexOf("error loading")==-1) return true;
30         }
31      }
32
33      return false;
34   }
35
36   public boolean hasText(String JavaDoc lower)
37   {
38      for(String JavaDoc line: errorLines)
39      {
40         if(line.toLowerCase().indexOf(lower)>=0) return true;
41      }
42
43      return false;
44   }
45
46   public Vector<String JavaDoc> getAllLines() { return errorLines; }
47
48   public String JavaDoc getAllErrorMessage()
49   {
50      StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
51      for(String JavaDoc line: errorLines)
52      {
53         sb.append(line);
54         sb.append("\n");
55      }
56      return sb.toString().trim();
57   }
58
59
60
61
62 } // ErrorLineProcessor
63
Popular Tags