XML for Java Compatibility API 2.0.11

com.ibm.xml.parser
Interface ErrorListener

All Known Implementing Classes:
SAXDriver, Stderr

public abstract interface ErrorListener

An interface for handling error and warning events that are recognized by the XML4J parser.

An application may implement this interface in order to redirect and alter the presentation of XML4J parser errors and exceptions.

For example, the following code fragment listens for parser errors and suppresses any output:


   class ErrorIgnorer implements ErrorListener {
     public int error(String fileName, int lineNo, int charOffset, 
                       Object key, String msg) {
      // Do nothing..in other words, suppress all notifications.
     return 0;
     }
   }

   public static void main(String[] argv) {
     ...
     InputStream is = new FileInputStream(fname);
     Parser p = new Parser(fname, new ErrorIgnorer(), null); // Suppress any parser errors
     TXDocument doc = p.readStream(is);
     ...
   }

 

Version:
Revision: 68 1.5 src/com/ibm/xml/parser/ErrorListener.java, parser, xml4j2, xml4j2_0_11

Method Summary
 int error(java.lang.String fileName, int lineNo, int charOffset, java.lang.Object key, java.lang.String msg)
          Interface to be implemented in order to receive control when error and warning events are recognized by the parser.
 

Method Detail

error

public int error(java.lang.String fileName,
                 int lineNo,
                 int charOffset,
                 java.lang.Object key,
                 java.lang.String msg)
Interface to be implemented in order to receive control when error and warning events are recognized by the parser. Control is transferred prior to calling any ErrorHandlers.
Parameters:
fileName - Processing file name, or null if error or warning occurs in a document.
lineNo - The line number where the current document event ends, or -1 if not available. Note that this is the line position of the first character after the text associated with the document event. Do NOT trust this value when the input stream includes invalid octet as its encoding.
charOffset - The column number where the current document event ends, or -1 if not available. Note that this is the column number of the first character after the text associated with the document event. The first column in a line is position 1. Do NOT trust this value when the input stream includes invalid octet as its encoding.
key - The object may be an instance of String or Exception. When this object is String, this value may help classify msg as an error (begins with "E_") or warning (begins with "W_"). See sources of com.ibm.xml.parser.r package.
msg - The error or warning message.
Returns:
1 if you want to increase an error counter or a warning counter in Parser; otherwise 0.
See Also:
Parser.getNumberOfErrors(), Parser.getNumberOfWarnings()

XML for Java Compatibility API 2.0.11