/** * @see ca.uhn.hl7v2.validation.Validator#validate(java.lang.String, * boolean, java.lang.String, * ca.uhn.hl7v2.validation.ValidationExceptionHandler) */ public R validate(String message, boolean isXML, String version, ValidationExceptionHandler<R> handler) throws HL7Exception { if (message == null) { throw new NullPointerException("Message may not be null"); } if (handler == null) { throw new NullPointerException("ValidationExceptionHandler may not be null"); } handler.setValidationSubject(message); List<EncodingRule> rules = new ArrayList<EncodingRule>(); if (getValidationContext() != null) { rules.addAll(getValidationContext().getEncodingRules(version, isXML ? "XML" : "ER7")); } LOG.debug("Validating message against {} encoding rules", rules.size()); for (EncodingRule rule : rules) { ValidationException[] ex = rule.apply(message); if (ex != null && ex.length > 0) { handler.onExceptions(ex); } } return handler.result(); }
/** * @see ca.uhn.hl7v2.validation.Validator#validate(java.lang.String, * boolean, java.lang.String, * ca.uhn.hl7v2.validation.ValidationExceptionHandler) */ public R validate(String message, boolean isXML, String version, ValidationExceptionHandler<R> handler) throws HL7Exception { if (message == null) { throw new NullPointerException("Message may not be null"); } if (handler == null) { throw new NullPointerException("ValidationExceptionHandler may not be null"); } handler.setValidationSubject(message); List<EncodingRule> rules = new ArrayList<EncodingRule>(); if (getValidationContext() != null) { rules.addAll(getValidationContext().getEncodingRules(version, isXML ? "XML" : "ER7")); } LOG.debug("Validating message against {} encoding rules", rules.size()); for (EncodingRule rule : rules) { ValidationException[] ex = rule.apply(message); if (ex != null && ex.length > 0) { handler.onExceptions(ex); } } return handler.result(); }