xmlerrorhandler.java

来自「考勤管理系统源码」· Java 代码 · 共 57 行

JAVA
57
字号
package com.wiley.compBooks.EJwithUML.BillingSystemInterface;

import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

/**
 * This is SAX ErrorHandler. It logs and ignores warnings and errors. It throws
 * SAXException for fatal errors.
 */
class XMLErrorHandler implements ErrorHandler
{

 /**
  * This will report a warning that has occurred; this indicates
  * that while no XML rules were broken, something appears
  * to be incorrect or missing.
  */
   public void warning(SAXParseException exception)
        throws SAXException
   {
     System.out.println("warning()-**Parsing Warning**\n" + " Line: " +
                     exception.getLineNumber() + "\n" + " URI: " +
                     exception.getSystemId() + "\n" + " Message: " +
                     exception.getMessage());
   }

    /**
     * This will report an error that has occurred; this indicates
     * that a rule was broken, typically in validation, but that
     * parsing can reasonably continue. This is logged and ignored.
     */
    public void error(SAXParseException exception)
        throws SAXException
    {
      System.out.println("error()-**Parsing Error**\n" + " Line: " +
                    exception.getLineNumber() + "\n" + " URI: " +
                    exception.getSystemId() + "\n" + " Message: " +
                    exception.getMessage());
    }

   /**
    * This will report a fatal error that has occurred; this indicates
    * that a rule has been broken that makes continued parsing either
    * impossible or an almost certain waste of time.
    */
    public void fatalError(SAXParseException exception)
        throws SAXException
    {
      System.out.println("fatalError()-**Parsing Fatal Error**\n" + " Line: " +
            exception.getLineNumber() + "\n" + " URI: " +
            exception.getSystemId() + "\n" + " Message: " +
            exception.getMessage());
        throw new SAXException("Fatal Error encountered");
   }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?