001/** 002The contents of this file are subject to the Mozilla Public License Version 1.1 003(the "License"); you may not use this file except in compliance with the License. 004You may obtain a copy of the License at http://www.mozilla.org/MPL/ 005Software distributed under the License is distributed on an "AS IS" basis, 006WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 007specific language governing rights and limitations under the License. 008 009The Original Code is "Rule.java". Description: 010"A testable rule to which HL7 messages should conform" 011 012The Initial Developer of the Original Code is University Health Network. Copyright (C) 0132002. All Rights Reserved. 014 015Contributor(s): ______________________________________. 016 017Alternatively, the contents of this file may be used under the terms of the 018GNU General Public License (the �GPL�), in which case the provisions of the GPL are 019applicable instead of those above. If you wish to allow use of your version of this 020file only under the terms of the GPL and not to allow others to use your version 021of this file under the MPL, indicate your decision by deleting the provisions above 022and replace them with the notice and other provisions required by the GPL License. 023If you do not delete the provisions above, a recipient may use your version of 024this file under either the MPL or the GPL. 025 */ 026 027package ca.uhn.hl7v2.validation; 028 029import java.io.Serializable; 030 031/** 032 * <p> 033 * A testable rule to which HL7 messages (at least certain specific message) 034 * should conform. 035 * <p> 036 * There are three kinds of rules: 037 * <ul> 038 * <li>PrimitiveTypeRule: Called when the values of simple datatypes are set, 039 * like the existing hard-coded datatype validations (e.g. 040 * TNFollowsNorthAmericanFormat).</li> 041 * <li>MessageRule: Called when complete message content is to be checked on a 042 * parsed message (e.g. conformance profile).</li> 043 * <li>EncodingRule: Applied to an encoded message (e.g. validation against a 044 * .xml Schema, a rule that prohibits empty tags, etc.).</li> 045 * </ul> 046 * </p> 047 * 048 * @author Bryan Tripp 049 */ 050public interface Rule<T> extends Serializable { 051 052 /** 053 * Returns a text description of the rule. This description may be used as a 054 * message in exceptions generated if validation against the rule fails, or 055 * in a user interface for rule configuration. 056 * 057 * @return rule description 058 */ 059 public String getDescription(); 060 061 /** 062 * Returns a string indicating the section of the HL7 standard from which this rule 063 * is derived (if applicable). Like the description, this may be used in an 064 * exception message or configuration UI. 065 * 066 * @return HL7 specification section reference 067 */ 068 public String getSectionReference(); 069 070 /** 071 * Applies to rule to an object to be checked 072 * 073 * @param value object to be checked 074 * @return an (potentially empty) array of ValidationExceptions 075 */ 076 public ValidationException[] apply(T value); 077 078}