FileDocCategorySizeDatePackage
MyErrorHandler.javaAPI DocExample2095Fri Feb 01 12:49:52 GMT 2002None

MyErrorHandler

public class MyErrorHandler extends Object implements ErrorHandler
Customizable Diagnostic Error Handler

Fields Summary
private int
flags
public static final int
ERR_PRINT
public static final int
ERR_IGNORE
public static final int
WARN_PRINT
public static final int
FATAL_PRINT
public static final int
FATAL_IGNORE
Constructors Summary
public MyErrorHandler()


        flags = ~0; 
public MyErrorHandler(int flags)

 this.flags = flags; 
Methods Summary
public voiderror(org.xml.sax.SAXParseException e)

	if ((flags & ERR_PRINT) != 0)
	    System.err.print (printParseException ("Error", e));
	if ((flags & ERR_IGNORE) == 0)
	    throw e;
    
public voidfatalError(org.xml.sax.SAXParseException e)

	if ((flags & FATAL_PRINT) != 0)
	    System.err.print (printParseException ("FATAL", e));
	if ((flags & FATAL_IGNORE) == 0)
	    throw e;
    
private static java.lang.StringprintParseException(java.lang.String label, org.xml.sax.SAXParseException e)

	StringBuffer        buf = new StringBuffer ();
	int                 temp;

	buf.append ("** ");
	buf.append (label);
	buf.append (": ");
	buf.append (e.getMessage ());
	buf.append ('\n");
	// most such exceptions include the (absolute) URI for the text
	if (e.getSystemId () != null) {
	    buf.append ("   URI:  ");
	    buf.append (e.getSystemId ());
	    buf.append ('\n");
	}
	// many include line and column numbers
	if ((temp = e.getLineNumber ()) != -1) {
	    buf.append ("   line: ");
	    buf.append (temp);
	    buf.append ('\n");
	}
	if ((temp = e.getColumnNumber ()) != -1) {
	    buf.append ("   char: ");
	    buf.append (temp);
	    buf.append ('\n");
	}
	// public ID might be available, but is seldom useful

	return buf.toString ();
    
public voidwarning(org.xml.sax.SAXParseException e)

	if ((flags & WARN_PRINT) != 0)
	    System.err.print (printParseException ("Warning", e));
	// always ignored