0,0 → 1,120 |
/* |
* This file contains the GrammarErrorHandler class. |
* |
* Coded by: Group 5, software practice summer 2003 |
* University of Bielefeld, Germany |
* |
* @version $Revision: 1.60 $ |
* |
* Last modification: $Date: 2003/07/25 14:56:04 $ |
* $Id: Parser.java,v 1.60 2003/07/25 14:56:04 smcsporr Exp $ |
*/ |
package src.parser; |
|
import org.apache.xerces.xni.parser.XMLErrorHandler; |
import org.apache.xerces.xni.parser.XMLParseException; |
|
import src.gui.LogInterface; |
|
/** |
* The <b><code>GrammarErrorHandler</code></b> class supplies an error handler for the |
* an XML grammar preparser. |
* An error handler retrieves and handles error events sent by a parser. These |
* errors include warnings, errors and fatal errors. |
* |
* @author S. McSporran |
* |
* @version $Revision: 1.60 $ Last modification: $Date: 2003/07/25 14:56:04 $ |
*/ |
public class GrammarErrorHandler implements XMLErrorHandler { |
|
/** A reference to a log panel implementation, used to output logging messages. */ |
private LogInterface logInterfaceReference; |
|
/** Empty Constructor. */ |
GrammarErrorHandler() { |
} |
|
/** |
* A method that catches parsing warnings and sends them to the log panel. |
* Warnings indicate that something might be missing or incorrect in a grammar file, |
* while no wellformedness rule has been broken. |
* |
* @param domain The domain of the warning, suggested to be a valid URI. |
* @param key The warning key; can be any string and is implementation dependent. |
* @param xpe A warning event sent by a parser. |
* |
* author S. McSporran |
* |
* Last revision: 25-Jul-2003 by S. McSporran |
*/ |
public void warning(String domain, String key, XMLParseException xpe){ |
log(LogInterface.TYPE_WARNING, "Grammar parsing warning: " + xpe.getMessage()); |
} |
|
/** |
* A method that catches parsing errors and sends them to the log panel. |
* Errors occur during parsing, if a grammar rule has been broken, but |
* the parser will be able to continue. |
* |
* @param domain The domain of the error, suggested to be a valid URI. |
* @param key The error key; can be any string and is implementation dependent. |
* @param xpe An error event sent by a parser. |
* |
* author S. McSporran |
* |
* Last revision: 25-Jul-2003 by S. McSporran |
*/ |
public void error(String domain, String key, XMLParseException xpe) { |
log(LogInterface.TYPE_ERROR, "Error ! Grammar parsing failure: " + xpe.getMessage()); |
} |
|
/** |
* A method that catches parsing fatal errors and sends them to the log panel. |
* Fatal errors indicate that a grammar rule has been broken that makes continued |
* parsing impossible. |
* |
* @param domain The domain of the fatal error, suggested to be a valid URI. |
* @param key The fatal error key; can be any string and is implementation dependent. |
* @param xpe A fatal error event sent by a parser. |
* |
* author S. McSporran |
* |
* Last revision: 25-Jul-2003 by S. McSporran |
*/ |
public void fatalError(String domain, String key, XMLParseException xpe) { |
log(LogInterface.TYPE_ERROR, "Fatal error ! Grammar parsing failure: " + |
xpe.getMessage()); |
} |
|
/** |
* Sends a text message of a specified type (info, error, warning) to the |
* registered log panel. |
* A reference to an implementation of a log panel can be set with the |
* <code>setLogInterface</code> method. |
* |
* @param i The type of the message as defined in src.gui.LogInterface. |
* 0 or src.gui.LogInterface.TYPE_INFO -> info message (black) |
* 1 or src.gui.LogInterface.TYPE_WARNING -> warning message (orange) |
* 2 or src.gui.LogInterface.TYPE_ERROR -> error message (red) |
* |
* @param message The text message to display in the log panel. |
*/ |
private void log(int i, String message) { |
logInterfaceReference.log(i, message); |
} |
|
/** |
* This method sets an internal reference to the log panel that is used to |
* output logging messages to inform the user about program events. |
* |
* @param log A log panel implementation compliant to src.gui.LogInterface. |
* |
* author S. McSporran |
* |
* Last Revision: 11-Jul-2003 |
*/ |
public void setLogInterface(LogInterface logInt) { |
logInterfaceReference = logInt; |
} |
} |
Property changes: |
Added: svn:keywords |
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id |
\ No newline at end of property |