1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.scxml2.env;
18
19 import java.io.Serializable;
20
21 import javax.xml.stream.Location;
22 import javax.xml.stream.XMLReporter;
23 import javax.xml.stream.XMLStreamException;
24
25 import org.apache.commons.scxml2.ErrorReporter;
26 import org.apache.commons.scxml2.SCXMLListener;
27 import org.apache.commons.scxml2.model.EnterableState;
28 import org.apache.commons.scxml2.model.Transition;
29 import org.apache.commons.scxml2.model.TransitionTarget;
30 import org.xml.sax.ErrorHandler;
31 import org.xml.sax.SAXException;
32 import org.xml.sax.SAXParseException;
33
34
35
36
37
38 public class Tracer implements ErrorHandler, ErrorReporter,
39 SCXMLListener, Serializable, XMLReporter {
40
41
42 private static final long serialVersionUID = 1L;
43
44 private ErrorHandler errHandler;
45
46 private ErrorReporter errReporter;
47
48 private SCXMLListener scxmlListener;
49
50 private XMLReporter xmlReporter;
51
52
53
54
55 public Tracer() {
56 super();
57 errHandler = new SimpleErrorHandler();
58 errReporter = new SimpleErrorReporter();
59 scxmlListener = new SimpleSCXMLListener();
60 xmlReporter = new SimpleXMLReporter();
61 }
62
63
64
65
66 public void warning(final SAXParseException exception)
67 throws SAXException {
68 errHandler.warning(exception);
69 }
70
71
72
73
74 public void error(final SAXParseException exception)
75 throws SAXException {
76 errHandler.error(exception);
77 }
78
79
80
81
82 public void fatalError(final SAXParseException exception)
83 throws SAXException {
84 errHandler.fatalError(exception);
85 }
86
87
88
89
90 public void onError(final String errCode, final String errDetail,
91 final Object errCtx) {
92 errReporter.onError(errCode, errDetail, errCtx);
93 }
94
95
96
97
98 public void onEntry(final EnterableState state) {
99 scxmlListener.onEntry(state);
100 }
101
102
103
104
105 public void onExit(final EnterableState state) {
106 scxmlListener.onExit(state);
107 }
108
109
110
111
112 public void onTransition(final TransitionTarget from,
113 final TransitionTarget to, final Transition transition, final String event) {
114 scxmlListener.onTransition(from, to, transition, event);
115 }
116
117
118
119
120 public void report(final String message, final String errorType, final Object relatedInformation,
121 final Location location)
122 throws XMLStreamException {
123 xmlReporter.report(message, errorType, relatedInformation, location);
124 }
125
126 }
127