1 package org.jbpm.bpel.xml; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 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 problems; 14 private String resource; 15 private boolean hasErrors; 16 17 private static final Log log = LogFactory.getLog(ProblemCollector.class); 18 19 public ProblemCollector() { 20 problems = new ArrayList (); 21 hasErrors = false; 22 } 23 24 public ProblemCollector(String resource) { 25 this(); 26 this.resource = resource; 27 } 28 29 public void add(Problem problem) { 30 problem.setResource(resource); 31 String 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 getProblems() { 46 return problems; 47 } 48 49 public boolean hasErrors() { 50 return hasErrors; 51 } 52 } | Popular Tags |