01: /*
02: * This file or a portion of this file is licensed under the terms of
03: * the Globus Toolkit Public License, found in file GTPL, or at
04: * http://www.globus.org/toolkit/download/license.html. This notice must
05: * appear in redistributions of this file, with or without modification.
06: *
07: * Redistributions of this Software, with or without modification, must
08: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
09: * some other similar material which is provided with the Software (if
10: * any).
11: *
12: * Copyright 1999-2004 University of Chicago and The University of
13: * Southern California. All rights reserved.
14: */
15: package org.griphyn.cPlanner.parser;
16:
17: import org.griphyn.cPlanner.common.LogManager;
18:
19: import org.xml.sax.ErrorHandler;
20: import org.xml.sax.SAXException;
21: import org.xml.sax.SAXParseException;
22:
23: /**
24: * This class handles the errors which occur while enforcing validation against
25: * the XML Schema. Same as the VDLErrorHandler.
26: *
27: * @author Karan Vahi
28: * @author Gaurang Mehta
29: *
30: * $Revision: 50 $
31: */
32:
33: public class XMLErrorHandler implements ErrorHandler {
34:
35: /**
36: * The handle to the logging object that is used to log the messages.
37: */
38: private LogManager mLogger;
39:
40: /**
41: * The default constructor.
42: * Initializes the logger object.
43: */
44: public XMLErrorHandler() {
45: mLogger = LogManager.getInstance();
46: }
47:
48: /**
49: * Logs the warning messages in the SAX parser generates while
50: * validating the XML file against an XML Schema.
51: *
52: * @param e the execption that is being caught.
53: */
54: public void warning(SAXParseException e) throws SAXException {
55: mLogger.log("**Parsing ** " + " Line: " + e.getLineNumber()
56: + "\n" + "[" + e + "]\n",
57: LogManager.WARNING_MESSAGE_LEVEL);
58: }
59:
60: /**
61: * Logs the error messages which SAX parser generates while
62: * validating the XML file against an XML Schema
63: *
64: * @param e the exception that is being caught.
65: */
66: public void error(SAXParseException e) throws SAXException {
67: mLogger.log("**Parsing ** " + " Line: " + e.getLineNumber()
68: + "\n" + "[" + e + "]\n",
69: LogManager.ERROR_MESSAGE_LEVEL);
70: }
71:
72: /**
73: * Logs the the fatal messages which SAX parser generates while
74: * validating the XML file against an XML Schema
75: *
76: * @param e the exception that is being caught
77: */
78: public void fatalError(SAXParseException e) throws SAXException {
79: mLogger.log("\n** Parsing ** " + " Line: " + e.getLineNumber()
80: + "\n" + "[" + e + "]\n",
81: LogManager.FATAL_MESSAGE_LEVEL);
82: }
83: }
|