01: //
02: // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.4-b18-fcs
03: // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
04: // Any modifications to this file will be lost upon recompilation of the source schema.
05: // Generated on: 2005.03.04 at 10:20:40 PST
06: //
07:
08: package com.nabhinc.portal.config.impl.runtime;
09:
10: import javax.xml.bind.ValidationEvent;
11: import javax.xml.bind.ValidationEventLocator;
12: import javax.xml.bind.helpers.ValidationEventImpl;
13:
14: import org.xml.sax.ErrorHandler;
15: import org.xml.sax.SAXException;
16: import org.xml.sax.SAXParseException;
17:
18: import com.sun.xml.bind.validator.Locator;
19:
20: /**
21: * Receives errors through {@link ErrorHandler} and reports to the
22: * {@link SAXUnmarshallerHandler}.
23: *
24: * @author
25: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
26: */
27: public class ErrorHandlerAdaptor implements ErrorHandler {
28:
29: /** the client event handler that will receive the validation events */
30: private final SAXUnmarshallerHandler host;
31:
32: /** the locator object responsible for filling in the validation event
33: * location info **/
34: private final Locator locator;
35:
36: public ErrorHandlerAdaptor(SAXUnmarshallerHandler _host,
37: Locator locator) {
38: this .host = _host;
39: this .locator = locator;
40: }
41:
42: public void error(SAXParseException exception) throws SAXException {
43:
44: propagateEvent(ValidationEvent.ERROR, exception);
45: }
46:
47: public void warning(SAXParseException exception)
48: throws SAXException {
49:
50: propagateEvent(ValidationEvent.WARNING, exception);
51: }
52:
53: public void fatalError(SAXParseException exception)
54: throws SAXException {
55:
56: propagateEvent(ValidationEvent.FATAL_ERROR, exception);
57: }
58:
59: private void propagateEvent(int severity,
60: SAXParseException saxException) throws SAXException {
61:
62: // get location info:
63: // sax locators simply use the location info embedded in the
64: // sax exception, dom locators keep a reference to their DOMScanner
65: // and call back to figure out where the error occurred.
66: ValidationEventLocator vel = locator.getLocation(saxException);
67:
68: ValidationEventImpl ve = new ValidationEventImpl(severity,
69: saxException.getMessage(), vel);
70:
71: Exception e = saxException.getException();
72: if (e != null) {
73: ve.setLinkedException(e);
74: } else {
75: ve.setLinkedException(saxException);
76: }
77:
78: // call the client's event handler.
79: host.handleEvent(ve, severity != ValidationEvent.FATAL_ERROR);
80: }
81: }
|