Package ca.uhn.hl7v2.validation
Class AbstractValidator<R>
java.lang.Object
ca.uhn.hl7v2.validation.AbstractValidator<R>
- Type Parameters:
R- The type parameter R denotes the result type of the validation process.
- All Implemented Interfaces:
Validator<R>
- Direct Known Subclasses:
DefaultValidator,MessageValidator
Abstract implementation of a message validator.
- Author:
- Christian Ohr
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ValidationContextprotected abstract ValidationExceptionHandler<R>booleanvoidsetValidatePrimitives(boolean validatePrimitives) Turns validating primtives on and off (default).CallsinitializeHandler()to obtain a default instance of aValidationExceptionHandlerbefore starting the validation.validate(Message message, ValidationExceptionHandler<R> handler) Validates aMessageusing a customValidationExceptionHandler.CallsinitializeHandler()to obtain a default instance of aValidationExceptionHandlerbefore starting the validation.validate(String message, boolean isXML, String version, ValidationExceptionHandler<R> handler) Validates a String representing an encoded message.
-
Constructor Details
-
AbstractValidator
public AbstractValidator()
-
-
Method Details
-
setValidatePrimitives
Turns validating primtives on and off (default). Note that primitive validation will significantly slow down the validation process.- Parameters:
validatePrimitives- true if primitive fields shall be validated, false if not
-
isValidatePrimitives
- Returns:
- true if primitive fields shall be validated, false if not
-
validate
CallsinitializeHandler()to obtain a default instance of aValidationExceptionHandlerbefore starting the validation.- Specified by:
validatein interfaceValidator<R>- Parameters:
message- message to be validated- Returns:
trueif message is valid- Throws:
HL7Exception- if an unexpected error occurs while validating- See Also:
-
validate
Description copied from interface:ValidatorValidates aMessageusing a customValidationExceptionHandler. The handler provides the possibility to react on the outcome of the validation process and its individual steps, e.g. collecting all validation, issues, aggregating them to a single issue, logging, throwing exceptions etc.As the handler usually maintains state, a new instance is required for every validation call.
- Specified by:
validatein interfaceValidator<R>- Parameters:
message- message to be validatedhandler- message validation handler- Returns:
trueif message is valid- Throws:
HL7Exception- if an unexpected error occurs while validating- See Also:
-
validate
CallsinitializeHandler()to obtain a default instance of aValidationExceptionHandlerbefore starting the validation.- Specified by:
validatein interfaceValidator<R>- Parameters:
message- message to be validatedisXML- true if message is supposed to be XMLversion- message version- Returns:
trueif message is valid- Throws:
HL7Exception- if an unexpected error occurs while validating- See Also:
-
validate
public R validate(String message, boolean isXML, String version, ValidationExceptionHandler<R> handler) throws HL7Exception Description copied from interface:ValidatorValidates a String representing an encoded message. As the handler usually maintains state, a new instance is required for every validation call.- Specified by:
validatein interfaceValidator<R>- Parameters:
message- message to be validatedisXML- true if message is supposed to be XMLversion- message versionhandler- message validation handler- Returns:
trueif message is valid- Throws:
HL7Exception- if an unexpected error occurs while validating- See Also:
-
getValidationContext
-
initializeHandler
-