KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > xml > ProblemCollector


1 package org.jbpm.bpel.xml;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import org.apache.commons.logging.Log;
7 import org.apache.commons.logging.LogFactory;
8
9 import org.jbpm.jpdl.xml.Problem;
10
11 public class ProblemCollector implements ProblemHandler {
12   
13   private List JavaDoc problems;
14   private String JavaDoc resource;
15   private boolean hasErrors;
16   
17   private static final Log log = LogFactory.getLog(ProblemCollector.class);
18   
19   public ProblemCollector() {
20     problems = new ArrayList JavaDoc();
21     hasErrors = false;
22   }
23   
24   public ProblemCollector(String JavaDoc resource) {
25     this();
26     this.resource = resource;
27   }
28
29   public void add(Problem problem) {
30     problem.setResource(resource);
31     String JavaDoc problemDetails = problem.toString();
32     problemDetails = problemDetails.substring(problemDetails.indexOf(']') + 2);
33     
34     if(problem.getLevel() <= Problem.LEVEL_ERROR) {
35       hasErrors = true;
36       log.error(problemDetails, problem.getException());
37     }
38     else {
39       log.warn(problemDetails, problem.getException());
40     }
41     
42     problems.add(problem);
43   }
44   
45   public List JavaDoc getProblems() {
46     return problems;
47   }
48
49   public boolean hasErrors() {
50     return hasErrors;
51   }
52 }
Popular Tags