R
- The type parameter R denotes the result type of the validation
process.public abstract class AbstractValidator<R> extends Object implements Validator<R>
Constructor and Description |
---|
AbstractValidator() |
Modifier and Type | Method and Description |
---|---|
protected abstract ValidationContext |
getValidationContext() |
protected abstract ValidationExceptionHandler<R> |
initializeHandler() |
boolean |
isValidatePrimitives() |
void |
setValidatePrimitives(boolean validatePrimitives)
Turns validating primtives on and off (default).
|
R |
validate(Message message)
Calls
initializeHandler() to obtain a default instance of a
ValidationExceptionHandler before starting the validation. |
R |
validate(Message message,
ValidationExceptionHandler<R> handler)
Validates a
Message using a custom ValidationExceptionHandler . |
R |
validate(String message,
boolean isXML,
String version)
Calls
initializeHandler() to obtain a default instance of a
ValidationExceptionHandler before starting the validation. |
R |
validate(String message,
boolean isXML,
String version,
ValidationExceptionHandler<R> handler)
Validates a String representing an encoded message.
|
public AbstractValidator()
public void setValidatePrimitives(boolean validatePrimitives)
validatePrimitives
- true if primitive fields shall be validated, false if notpublic boolean isValidatePrimitives()
public R validate(Message message) throws HL7Exception
initializeHandler()
to obtain a default instance of a
ValidationExceptionHandler
before starting the validation.validate
in interface Validator<R>
message
- message to be validatedtrue
if message is validHL7Exception
- if an unexpected error occurs while validatingValidator.validate(ca.uhn.hl7v2.model.Message)
public R validate(Message message, ValidationExceptionHandler<R> handler) throws HL7Exception
Validator
Message
using a custom ValidationExceptionHandler
. 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.
validate
in interface Validator<R>
message
- message to be validatedhandler
- message validation handlertrue
if message is validHL7Exception
- if an unexpected error occurs while validatingValidator.validate(ca.uhn.hl7v2.model.Message,
ca.uhn.hl7v2.validation.ValidationExceptionHandler)
public R validate(String message, boolean isXML, String version) throws HL7Exception
initializeHandler()
to obtain a default instance of a
ValidationExceptionHandler
before starting the validation.validate
in interface Validator<R>
message
- message to be validatedisXML
- true if message is supposed to be XMLversion
- message versiontrue
if message is validHL7Exception
- if an unexpected error occurs while validatingValidator.validate(Message,
ValidationExceptionHandler)
public R validate(String message, boolean isXML, String version, ValidationExceptionHandler<R> handler) throws HL7Exception
Validator
validate
in interface Validator<R>
message
- message to be validatedisXML
- true if message is supposed to be XMLversion
- message versionhandler
- message validation handlertrue
if message is validHL7Exception
- if an unexpected error occurs while validatingValidator.validate(java.lang.String,
boolean, java.lang.String,
ca.uhn.hl7v2.validation.ValidationExceptionHandler)
protected abstract ValidationContext getValidationContext()
protected abstract ValidationExceptionHandler<R> initializeHandler()
Copyright © 2001–2017 University Health Network. All rights reserved.