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