KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jbpm.bpel.xml;
2
3 import org.xml.sax.ErrorHandler JavaDoc;
4 import org.xml.sax.SAXParseException JavaDoc;
5
6 import org.jbpm.jpdl.xml.Problem;
7
8 public class ErrorHandlerAdapter implements ErrorHandler JavaDoc {
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 JavaDoc pe) {
19     Problem problem = new Problem( Problem.LEVEL_ERROR, pe.getMessage(), pe.getException());
20     problem.setLine(new Integer JavaDoc(pe.getLineNumber()));
21     String JavaDoc 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 JavaDoc pe) {
29     Problem problem = new Problem( Problem.LEVEL_FATAL, pe.getMessage(), pe.getException());
30     problem.setLine(new Integer JavaDoc(pe.getLineNumber()));
31     String JavaDoc 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 JavaDoc pe) {
39     Problem problem = new Problem( Problem.LEVEL_WARNING, pe.getMessage(), pe.getException());
40     problem.setLine(new Integer JavaDoc(pe.getLineNumber()));
41     String JavaDoc 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