KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jbpm.bpel.xml;
2
3 import javax.xml.transform.ErrorListener JavaDoc;
4 import javax.xml.transform.SourceLocator JavaDoc;
5 import javax.xml.transform.TransformerException JavaDoc;
6
7 import org.jbpm.jpdl.xml.Problem;
8
9 public class ErrorListenerAdapter implements ErrorListener JavaDoc {
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 JavaDoc te) {
20     Problem problem = new Problem( Problem.LEVEL_ERROR, te.getMessage(), te.getException());
21     SourceLocator JavaDoc locator = te.getLocator();
22     problem.setLine(new Integer JavaDoc(locator.getLineNumber()));
23     String JavaDoc 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 JavaDoc te) {
31     Problem problem = new Problem( Problem.LEVEL_FATAL, te.getMessage(), te.getException());
32     SourceLocator JavaDoc locator = te.getLocator();
33     problem.setLine(new Integer JavaDoc(locator.getLineNumber()));
34     String JavaDoc 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 JavaDoc te) {
42     Problem problem = new Problem( Problem.LEVEL_WARNING, te.getMessage(), te.getException());
43     SourceLocator JavaDoc locator = te.getLocator();
44     problem.setLine(new Integer JavaDoc(locator.getLineNumber()));
45     String JavaDoc 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