Name

ErrorListener

Synopsis

This interface defines methods that Transformer and TransformerFactory use for reporting warnings, errors, and fatal errors to an application. To use an ErrorListener, an application must implement this interface and pass an implementing object to the setErrorListener( ) method of Transformer or TransformerFactory. The argument to each method of this interface is a TransformerException object, and the implementation of these methods can throw that exception if it chooses, or it can simply log the warning or error in some way and return. A Transformer or TransformerFactory is not required to continue processing after reporting a nonrecoverable error with an invocation of the fatalError( ) method.

If you are familiar with the SAX API for parsing XML documents, you’ll recognize that this interface is very similar to org.xml.sax.ErrorHandler.

public interface ErrorListener {
// Public Instance Methods
     void error(TransformerException exception) throws TransformerException;  
     void fatalError(TransformerException exception) throws TransformerException;  
     void warning(TransformerException exception) throws TransformerException;  
}

Passed To

Transformer.setErrorListener( ), TransformerFactory.setErrorListener( )

Returned By

Transformer.getErrorListener( ), TransformerFactory.getErrorListener( )

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.