001    /**
002    The 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. 
004    You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
005    Software distributed under the License is distributed on an "AS IS" basis, 
006    WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
007    specific language governing rights and limitations under the License. 
008    
009    The Original Code is "Rule.java".  Description: 
010    "A testable rule to which HL7 messages should conform" 
011    
012    The Initial Developer of the Original Code is University Health Network. Copyright (C) 
013    2002.  All Rights Reserved. 
014    
015    Contributor(s): ______________________________________. 
016    
017    Alternatively, the contents of this file may be used under the terms of the 
018    GNU General Public License (the  ???GPL???), in which case the provisions of the GPL are 
019    applicable instead of those above.  If you wish to allow use of your version of this 
020    file only under the terms of the GPL and not to allow others to use your version 
021    of this file under the MPL, indicate your decision by deleting  the provisions above 
022    and replace  them with the notice and other provisions required by the GPL License.  
023    If you do not delete the provisions above, a recipient may use your version of 
024    this file under either the MPL or the GPL. 
025    */
026    
027    package ca.uhn.hl7v2.validation;
028    
029    import java.io.Serializable;
030    
031    /**
032     * <p>A testable rule to which HL7 messages (at least certain specific message) should conform.  
033     * This is the central interface of the new HAPI validation model (as of HAPI 0.4).  
034     * Previously, the only run-time message validation HAPI performs is within the
035     * setValue() methods of the Primitive datatype classes.  For example when you
036     * called setValue() on a DT an exception was thrown if the String arg was not in
037     * the correct DT format.  This method served well initially but left us with the 
038     * following limitations: 
039     * <ol><li>Sometimes validation is inappropriate (e.g. some of the standard rules, like phone
040     * number format, don't make sense in some regions).  </li>
041     * <li>Couldn't add further optional constraints (such as all timestamps must have
042     * a time zone).  </li>
043     * <li>Couldn't turn off validation to improve performance. </li>
044     * <li>Other forms of validation (e.g. conformance profiles, standard DTDs) were
045     * not covered.  </li></ol></p>
046     * <p>Thus the new validation model is broader in scope, and is based on validation rules 
047     * implemented as Rule objects, which can be configured to run or not, as needed, depending on 
048     * run-time configuration.</p>
049     * <p>There are three kinds of rules: 
050     * <ol><li>DataTypeRule: Called when the values of simple datatypes are set, like
051     * the existing hard-coded datatype validations (e.g. TNFollowsNorthAmericanFormat).</li>  
052     * <li>MessageRule: Called when complete message content is to be checked on a
053     * parsed message (e.g. conformance profile). </li>
054     * <li>EncodingRule: Applied to an encoded message (e.g. validation against a
055     * 2.xml Schema, a rule that prohibits empty tags, etc.).</li>
056     * </ol></p>
057     * @author Bryan Tripp
058     */
059    public interface Rule extends Serializable {
060    
061        /**
062         * Returns a text description of the rule.  This description may be used as a message 
063         * in exceptions generated if validation against the rule fails, or in a user 
064         * interface for rule configuration.   
065         */  
066        public String getDescription();
067        
068        /**
069         * A string indicating the section of the HL7 standard from which this rule 
070         * is derived (if applicable).  Like the description, this may be used in an exception 
071         * message or configuration UI. 
072         */
073         public String getSectionReference();
074    
075    }