Coverage Report - ca.uhn.hl7v2.protocol.impl.ProcessorContextImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ProcessorContextImpl
95%
23/24
N/A
1
 
 1  
 /*
 2  
  * Created on 19-Apr-2004
 3  
  */
 4  
 package ca.uhn.hl7v2.protocol.impl;
 5  
 
 6  
 import java.util.ArrayList;
 7  
 import java.util.List;
 8  
 
 9  
 import ca.uhn.hl7v2.protocol.AcceptValidator;
 10  
 import ca.uhn.hl7v2.protocol.ApplicationRouter;
 11  
 import ca.uhn.hl7v2.protocol.ProcessorContext;
 12  
 import ca.uhn.hl7v2.protocol.SafeStorage;
 13  
 import ca.uhn.hl7v2.protocol.TransportLayer;
 14  
 
 15  
 /**
 16  
  * Default implementation of <code>ProcessorContext</code>. 
 17  
  * 
 18  
  * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
 19  
  * @version $Revision: 1.1 $ updated on $Date: 2007-02-19 02:24:26 $ by $Author: jamesagnew $
 20  
  */
 21  
 public class ProcessorContextImpl implements ProcessorContext {
 22  
 
 23  
     private final ApplicationRouter myRouter;
 24  
     private final TransportLayer myLocallyDrivenTransport;
 25  
     private final TransportLayer myRemotelyDrivenTransport;
 26  
     private final SafeStorage mySafeStorage;
 27  
     private final List<AcceptValidator> myValidators;
 28  
     private final List<String> myMetadataFields;
 29  
 
 30  
     /**
 31  
      * Creates a new instance that uses the given resources.  
 32  
      * 
 33  
      * @param theRouter 
 34  
      * @param theTransport a <code>TransportLayer</code> used for both locally-initiated
 35  
      *      and remotely-initiated message exchanges 
 36  
      * @param theStorage
 37  
      */    
 38  
     public ProcessorContextImpl(
 39  
             ApplicationRouter theRouter,
 40  
             TransportLayer theTransport, 
 41  25
             SafeStorage theStorage) {
 42  
                 
 43  25
         myRouter = theRouter;
 44  25
         myRemotelyDrivenTransport = theTransport;
 45  25
         myLocallyDrivenTransport = theTransport;
 46  25
         mySafeStorage = theStorage;
 47  
         
 48  25
         myValidators = new ArrayList<AcceptValidator>(8);
 49  25
         myMetadataFields = new ArrayList<String>(30);
 50  25
     }
 51  
 
 52  
     /**
 53  
      * Creates a new instance that uses the given resources.  
 54  
      * 
 55  
      * @param theRouter 
 56  
      * @param theLocallyDrivenTransport a <code>TransportLayer</code> used for locally-initiated
 57  
      *      and message exchanges 
 58  
      * @param theRemotelyDrivenTransport a <code>TransportLayer</code> used for remotely-initiated
 59  
      *      and message exchanges 
 60  
      * @param theStorage
 61  
      */    
 62  
     public ProcessorContextImpl(
 63  
             ApplicationRouter theRouter,
 64  
             TransportLayer theLocallyDrivenTransport,
 65  
             TransportLayer theRemotelyDrivenTransport,  
 66  60
             SafeStorage theStorage) {
 67  
                 
 68  60
         myRouter = theRouter;
 69  60
         myRemotelyDrivenTransport = theRemotelyDrivenTransport;
 70  60
         myLocallyDrivenTransport = theLocallyDrivenTransport;
 71  60
         mySafeStorage = theStorage;
 72  
         
 73  60
         myValidators = new ArrayList<AcceptValidator>(8);
 74  60
         myMetadataFields = new ArrayList<String>(30);
 75  60
     }
 76  
 
 77  
     /**
 78  
      * @see ca.uhn.hl7v2.protocol.ProcessorContext#getRouter()
 79  
      */
 80  
     public ApplicationRouter getRouter() {
 81  20
         return myRouter;
 82  
     }
 83  
 
 84  
     /**
 85  
      * @see ca.uhn.hl7v2.protocol.ProcessorContext#getRemotelyDrivenTransportLayer()
 86  
      */
 87  
     public TransportLayer getRemotelyDrivenTransportLayer() {
 88  788
         return myRemotelyDrivenTransport;
 89  
     }
 90  
 
 91  
     /**
 92  
      * @see ca.uhn.hl7v2.protocol.ProcessorContext#getLocallyDrivenTransportLayer()
 93  
      */
 94  
     public TransportLayer getLocallyDrivenTransportLayer() {
 95  983
         return myLocallyDrivenTransport;
 96  
     }
 97  
 
 98  
     /**
 99  
      * @see ca.uhn.hl7v2.protocol.ProcessorContext#getValidators()
 100  
      */
 101  
     public AcceptValidator[] getValidators() {
 102  45
         return myValidators.toArray(new AcceptValidator[0]);
 103  
     }
 104  
     
 105  
     /**
 106  
      * Adds a new validator to the list of those returned by 
 107  
      * <code>getValidators()</code>.  
 108  
      *  
 109  
      * @param theValidator the validator to add 
 110  
      */
 111  
     public void addValidator(AcceptValidator theValidator) {
 112  10
         myValidators.add(theValidator);
 113  10
     }
 114  
 
 115  
     /**
 116  
      * @see ca.uhn.hl7v2.protocol.ProcessorContext#getSafeStorage()
 117  
      */
 118  
     public SafeStorage getSafeStorage() {
 119  40
         return mySafeStorage;
 120  
     }
 121  
 
 122  
     /** 
 123  
      * @see ca.uhn.hl7v2.protocol.ProcessorContext#getMetadataFields()
 124  
      */
 125  
     public List<String> getMetadataFields() {
 126  0
         return myMetadataFields;
 127  
     }
 128  
 
 129  
 }