|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ConverterListener
This is the error reporting interface for Converter errors.
(It is modeled somewhat on the SAX ErrorHandler
interface.)
If an XML Converter application needs to implement customized error handling
then it may implement this interface and register it with the Converter
object. This may be done either by assigning a ConverterListener to the
ConverterFactory
in which case they all share the same instance, or afterwards to
an individual Converter
, ConvertToXML
or ConvertFromXML
object.
One use might be simply to report warnings and errors encountered. A simple
ConverterListener
like the one
below would do that:
package com.ddtek.custom; import com.ddtek.xmlconverter.ConverterListener; import com.ddtek.xmlconverter.exception.ConverterException; public class ReportingListener implements ConverterListener { public void warning(ConverterException exception) throws ConverterException { System.err.println(exception.getMessage()); } public void error(ConverterException exception) throws ConverterException { System.err.println(exception.getMessage()); } public void fatalError(ConverterException exception) throws ConverterException { System.err.println(exception.getMessage()); } }
Currently, only the EDI converter supports the ConverterListener. If an application registers a ConverterListener with any converter other than an EDI converter, then it will be ignored.
ConverterException
,
EDIConverterException
Method Summary | |
---|---|
void |
error(ConverterException exception)
Receive notification of a recoverable error. |
void |
fatalError(ConverterException exception)
Receive notification of a non-recoverable error. |
void |
warning(ConverterException exception)
Receive notification of a warning. |
Method Detail |
---|
void warning(ConverterException exception) throws ConverterException
Warnings will never interrupt the processing of an EDI file. They are minor conditions that can be captured for validation purposes, such as when a certain unused element has an incorrect value and can automatically be corrected.
The EDI converter will continue normal parsing after this event is invoked unless the handler explicitly throws an exception.
exception
- The warning information encapsulated in a ConverterException.
ConverterException
- Any ConverterException. The actual class may be
a subclass of ConverterException, such as EDIConverterException
,
and as such it may contain more specific information about the warning.void error(ConverterException exception) throws ConverterException
This method is used to report errors in the EDI document which could compromise the integrity of the stream, but which simple heuristics are available to recover, or fallback strategies are defined.
Examples are values that are not in codelists, segments in HL7 that are not in the repository, or elements whose content is too long or too short.
exception
- The error information encapsulated in a ConverterException.
ConverterException
- Any ConverterException. The actual class may be
a subclass of ConverterException, such as EDIConverterException
,
and as such it may contain more specific information about the error.void fatalError(ConverterException exception) throws ConverterException
No exceptions will be thrown after this notification is seen.
The caller should assume that the resultant document is unusable if this method is called.
Examples of errors that qualify as fatal errors are encodings that are not recognized, EDI dialects that are unknown or that are missing the header so that the version information cannot be extracted, or improperly nested groups.
exception
- The fatal error information encapsulated in a ConverterException.
ConverterException
- Any ConverterException. The actual class may be
a subclass of ConverterException, such as EDIConverterException
,
and as such it may contain more specific information about the error.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |