Coverage Report - ca.uhn.hl7v2.model.GenericComposite
 
Classes in this File Line Coverage Branch Coverage Complexity
GenericComposite
100%
9/9
100%
2/2
1.25
 
 1  
 package ca.uhn.hl7v2.model;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.List;
 5  
 
 6  
 /**
 7  
  * An unspecified Composite datatype that has an undefined number of components, each 
 8  
  * of which is a Varies.  
 9  
  * This is used to store Varies data, when the data type is unknown.  It is also 
 10  
  * used to store unrecognized message constituents.  
 11  
  * @author Bryan Tripp
 12  
  */
 13  
 @SuppressWarnings("serial")
 14  
 public class GenericComposite extends AbstractComposite {
 15  
     
 16  
     private List<Type> components;
 17  
     private Message message;
 18  
 
 19  
     /**
 20  
      * Creates a generic composite
 21  
      *
 22  
      * @param message message this object is linked to
 23  
      */
 24  
     public GenericComposite(Message message) {
 25  129
         super(message);
 26  129
         this.message = message;
 27  129
         components = new ArrayList<Type>(20);
 28  129
     }
 29  
     
 30  
     /** 
 31  
      * Returns the single component of this composite at the specified position (starting at 0) - 
 32  
      * Creates it (and any nonexistent components before it) if necessary.  
 33  
      */
 34  
     public Type getComponent(int number) throws DataTypeException {
 35  1697
         for (int i = components.size(); i <= number; i++) {
 36  603
             components.add(new Varies(message));
 37  
         }
 38  1094
         return components.get(number);
 39  
     }    
 40  
     
 41  
     /** 
 42  
      * Returns an array containing the components of this field.
 43  
      */
 44  
     public Type[] getComponents() {
 45  1407
             return components.toArray(new Type[components.size()]);
 46  
     }    
 47  
     
 48  
     /** Returns the name of the type (used in XML encoding and profile checking)  */
 49  
     public String getName() {
 50  1
         return "UNKNOWN";
 51  
     }
 52  
 
 53  
 
 54  
 }