Coverage Report - ca.uhn.hl7v2.llp.LowerLayerProtocol
 
Classes in this File Line Coverage Branch Coverage Complexity
LowerLayerProtocol
80%
4/5
N/A
1
 
 1  
 /**
 2  
 The contents of this file are subject to the Mozilla Public License Version 1.1 
 3  
 (the "License"); you may not use this file except in compliance with the License. 
 4  
 You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
 5  
 Software distributed under the License is distributed on an "AS IS" basis, 
 6  
 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
 7  
 specific language governing rights and limitations under the License. 
 8  
 
 9  
 The Original Code is "LowerLayerProtocol.java".  Description: 
 10  
 "Represents a particular "lower layer protocol" over which HL7 messages can be 
 11  
   sent" 
 12  
 
 13  
 The Initial Developer of the Original Code is University Health Network. Copyright (C) 
 14  
 2001.  All Rights Reserved. 
 15  
 
 16  
 Contributor(s): ______________________________________. 
 17  
 
 18  
 Alternatively, the contents of this file may be used under the terms of the 
 19  
 GNU General Public License (the  �GPL�), in which case the provisions of the GPL are 
 20  
 applicable instead of those above.  If you wish to allow use of your version of this 
 21  
 file only under the terms of the GPL and not to allow others to use your version 
 22  
 of this file under the MPL, indicate your decision by deleting  the provisions above 
 23  
 and replace  them with the notice and other provisions required by the GPL License.  
 24  
 If you do not delete the provisions above, a recipient may use your version of 
 25  
 this file under either the MPL or the GPL. 
 26  
 
 27  
 */
 28  
 
 29  
 package ca.uhn.hl7v2.llp;
 30  
 
 31  
 import java.io.InputStream;
 32  
 import java.io.OutputStream;
 33  
 
 34  
 import org.slf4j.Logger;
 35  
 import org.slf4j.LoggerFactory;
 36  
 
 37  
 /**
 38  
  * Represents a particular "lower layer protocol" over which HL7 messages can be 
 39  
  * sent.  An example is the "minimal lower layer protocol" defines in the HL7
 40  
  * implementation guide (appendix C) - this is implemented by the class 
 41  
  * MinLowerLayerProtocol.  Implementations should call the static method 
 42  
  * <code>logCharacterReceived()</code> when a character is read from a remote system.  
 43  
  * This method may or may not log receipt, as configured (see docs for this method).  
 44  
  * @author  Bryan Tripp
 45  
  */
 46  490
 public abstract class LowerLayerProtocol {
 47  
 
 48  1
     private static final Logger log = LoggerFactory.getLogger(LowerLayerProtocol.class);
 49  
     
 50  
     /** 
 51  
      * Returns a particular implementation of LowerLayerProtocol.
 52  
      * 
 53  
      *  @deprecated as there is now the choice between {@link MinLowerLayerProtocol}
 54  
      *  and {@link ExtendedMinLowerLayerProtocol}.
 55  
      */
 56  
     public static LowerLayerProtocol makeLLP() {
 57  0
         return new MinLowerLayerProtocol();
 58  
     }
 59  
     
 60  
     /** 
 61  
      * Returns an HL7Reader that implements message reading according to 
 62  
      * this protocol.  
 63  
      */ 
 64  
     public abstract HL7Reader getReader(InputStream in) throws LLPException;
 65  
           
 66  
     /** 
 67  
      * Returns an HL7Writer that implements message writing according to 
 68  
      * this protocol.  
 69  
      */ 
 70  
     public abstract HL7Writer getWriter(OutputStream out) throws LLPException;
 71  
     
 72  
     /**
 73  
      * <p>
 74  
      * Logs the fact that a character has been received, if configured to do so.  This is a 
 75  
      * debugging feature.  This is enabled by setting the system property 
 76  
      * ca.uhn.hl7v2.llp.logBytesRead=TRUE (before LowerLayerProtocol is instantiated).  
 77  
      * A message is logged for each character.  THIS IS VERY SLOW and should
 78  
      * normally be turned off. 
 79  
      * </p><p>
 80  
      * Note that as of HAPI 1.3, this will be logged using commons-logging at
 81  
      * a level of "info" instead of being printed to System.out
 82  
      * </p>
 83  
      */
 84  
     public static void logCharacterReceived(int c) {
 85  52114
         log.trace("Char received: {} ({})", c, (char) c);
 86  52114
     }
 87  
     
 88  
 }
 89