Package ca.uhn.hl7v2.validation
Class ReportingValidationExceptionHandler
java.lang.Object
ca.uhn.hl7v2.validation.ReportingValidationExceptionHandler
- All Implemented Interfaces:
ValidationExceptionHandler<Boolean>,ValidationExceptionHandlerFactory<Boolean>
public class ReportingValidationExceptionHandler
extends Object
implements ValidationExceptionHandler<Boolean>, ValidationExceptionHandlerFactory<Boolean>
ValidationExceptionHandler that logs all
ValidationExceptions and
optionally throws the first one wrapped in a HL7Exception.
The mimics the behavior of the MessageValidator of previous releases.
- Author:
- Christian Ohr
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetNewInstance(HapiContext context) booleanReturns a boolean flag indicating whether a validation was successful or not.voidonExceptions(ValidationException... exceptions) Logs all exceptionsresult()If the validation failed, throws Exception or returnsfalse, depending on {linkthrowFirstException.voidsetValidationSubject(Object subject) Does nothing
-
Constructor Details
-
ReportingValidationExceptionHandler
- Parameters:
throwFirstException- true if first exception shall be thrown
-
-
Method Details
-
onExceptions
Logs all exceptions- Specified by:
onExceptionsin interfaceValidationExceptionHandler<Boolean>- Parameters:
exceptions- the exceptions that describe the validatin errors- See Also:
-
result
If the validation failed, throws Exception or returnsfalse, depending on {linkthrowFirstException.- Specified by:
resultin interfaceValidationExceptionHandler<Boolean>- Returns:
- the validation result
- Throws:
HL7Exception- if validation has failed andthrowFirstExceptionis true- See Also:
-
hasFailed
Description copied from interface:ValidationExceptionHandlerReturns a boolean flag indicating whether a validation was successful or not. This is independent ofValidationExceptionHandler.result()which may return a more complex object.- Specified by:
hasFailedin interfaceValidationExceptionHandler<Boolean>- Returns:
- true if the validation is considered to be failed.
-
getNewInstance
- Specified by:
getNewInstancein interfaceValidationExceptionHandlerFactory<Boolean>- Parameters:
context- HAPI context- Returns:
- a new instance of a ValidationExceptionHandler
-
setValidationSubject
Does nothing- Specified by:
setValidationSubjectin interfaceValidationExceptionHandler<Boolean>- Parameters:
subject- subject to be validated
-