1 package org.jbpm.bpel.xml; 2 3 import javax.xml.transform.ErrorListener ; 4 import javax.xml.transform.SourceLocator ; 5 import javax.xml.transform.TransformerException ; 6 7 import org.jbpm.jpdl.xml.Problem; 8 9 public class ErrorListenerAdapter implements ErrorListener { 10 11 private ProblemHandler handler; 12 private boolean hasErrors; 13 14 public ErrorListenerAdapter(ProblemHandler handler) { 15 this.handler = handler; 16 hasErrors = false; 17 } 18 19 public void error(TransformerException te) { 20 Problem problem = new Problem( Problem.LEVEL_ERROR, te.getMessage(), te.getException()); 21 SourceLocator locator = te.getLocator(); 22 problem.setLine(new Integer (locator.getLineNumber())); 23 String resource = locator.getPublicId(); 24 if(resource == null) resource = locator.getSystemId(); 25 problem.setResource(resource); 26 handler.add(problem); 27 hasErrors = true; 28 } 29 30 public void fatalError(TransformerException te) { 31 Problem problem = new Problem( Problem.LEVEL_FATAL, te.getMessage(), te.getException()); 32 SourceLocator locator = te.getLocator(); 33 problem.setLine(new Integer (locator.getLineNumber())); 34 String resource = locator.getPublicId(); 35 if(resource == null) resource = locator.getSystemId(); 36 problem.setResource(resource); 37 handler.add(problem); 38 hasErrors = true; 39 } 40 41 public void warning(TransformerException te) { 42 Problem problem = new Problem( Problem.LEVEL_WARNING, te.getMessage(), te.getException()); 43 SourceLocator locator = te.getLocator(); 44 problem.setLine(new Integer (locator.getLineNumber())); 45 String resource = locator.getPublicId(); 46 if(resource == null) resource = locator.getSystemId(); 47 problem.setResource(resource); 48 handler.add(problem); 49 } 50 51 public boolean hasErrors() { 52 return hasErrors; 53 } 54 } | Popular Tags |