You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by er...@locus.apache.org on 2000/09/27 03:08:52 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/framework XMLErrorReporter.java
ericye 00/09/26 18:08:52
Modified: java/src/org/apache/xerces/framework Tag: xerces_j_2
XMLErrorReporter.java
Log:
flesh out the methods.
Revision Changes Path
No revision
No revision
1.2.4.6 +45 -3 xml-xerces/java/src/org/apache/xerces/framework/XMLErrorReporter.java
Index: XMLErrorReporter.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/framework/XMLErrorReporter.java,v
retrieving revision 1.2.4.5
retrieving revision 1.2.4.6
diff -u -r1.2.4.5 -r1.2.4.6
--- XMLErrorReporter.java 2000/09/11 21:56:11 1.2.4.5
+++ XMLErrorReporter.java 2000/09/27 01:08:51 1.2.4.6
@@ -61,13 +61,16 @@
import java.util.Locale;
import org.apache.xerces.utils.MessageFormatter;
import org.xml.sax.ErrorHandler;
+import org.xml.sax.Locator;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
/**
* @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
- * @version $Id: XMLErrorReporter.java,v 1.2.4.5 2000/09/11 21:56:11 andyc Exp $
+ * @author Eric Ye, IBM
+ * @version $Id: XMLErrorReporter.java,v 1.2.4.6 2000/09/27 01:08:51 ericye Exp $
*/
public class XMLErrorReporter
implements XMLComponent {
@@ -98,6 +101,9 @@
/** fErrorHandler */
protected ErrorHandler fErrorHandler;
+ /** fLocator */
+ protected Locator fLocator;
+
/** fContinueAfterFatalError */
protected boolean fContinueAfterFatalError;
@@ -109,6 +115,7 @@
*
*/
public XMLErrorReporter() {
+ fMessageFormatters = new Hashtable();
}
//
@@ -121,6 +128,7 @@
* @param locale
*/
public void setLocale(Locale locale) {
+ fLocale = locale;
} // setLocale
/**
@@ -130,6 +138,7 @@
* @param messageFormatter
*/
public void putMessageFormatter(String domain, MessageFormatter messageFormatter) {
+ fMessageFormatters.put(domain, messageFormatter);
} // putMessageFormatter
/**
@@ -140,7 +149,7 @@
* @return
*/
public MessageFormatter getMessageFormatter(String domain) {
- return null;
+ return (MessageFormatter) fMessageFormatters.get(domain);
} // getMessageFormatter
/**
@@ -151,7 +160,7 @@
* @return
*/
public MessageFormatter removeMessageFormatter(String domain) {
- return null;
+ return (MessageFormatter) fMessageFormatters.remove(domain);
} // removeMessageFormatter
/**
@@ -164,6 +173,39 @@
*/
public void reportError(String domain, String key, Object[] arguments, short severity)
throws SAXException {
+
+ SAXParseException spe;
+
+ MessageFormatter msgFormatter = (MessageFormatter) fMessageFormatters.get(domain);
+
+ spe = new SAXParseException(msgFormatter.formatMessage(fLocale, key, arguments), fLocator);
+
+ // default error handling
+ if (fErrorHandler == null) {
+ if ( severity == SEVERITY_FATAL_ERROR
+ && !fContinueAfterFatalError) {
+ throw spe;
+ }
+ return;
+ }
+
+ // call ErrorHandler callbacks
+ if (severity == SEVERITY_WARNING ) {
+ fErrorHandler.warning(spe);
+ }
+ else if (severity == SEVERITY_FATAL_ERROR) {
+ fErrorHandler.fatalError(spe);
+ if (!fContinueAfterFatalError) {
+ //
+ // !! in Xerces 1, spe was wrapped again.
+ //
+ throw spe;
+ }
+ }
+ else {
+ fErrorHandler.error(spe);
+ }
+
} // reportError
//