Coverage Report - ca.uhn.hl7v2.conf.spec.message.Component
 
Classes in this File Line Coverage Branch Coverage Complexity
Component
73%
14/19
100%
2/2
1.5
 
 1  
 package ca.uhn.hl7v2.conf.spec.message;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.List;
 5  
 
 6  
 import ca.uhn.hl7v2.conf.ProfileException;
 7  
 
 8  
 /**
 9  
  * The specification for a particular field component in a message profile.
 10  
  * 
 11  
  * @author Bryan Tripp
 12  
  */
 13  
 public class Component extends AbstractComponent<Component> {
 14  
 
 15  5429
         private final List<SubComponent> components = new ArrayList<SubComponent>();
 16  
 
 17  
         /** Creates a new instance of Component */
 18  5429
         public Component() {
 19  5429
         }
 20  
 
 21  
         /**
 22  
          * Indexed getter for property components (index starts at 1 following HL7
 23  
          * convention).
 24  
          * 
 25  
          * @param index
 26  
          *            Index of the property (starts at 1 following HL7 convention).
 27  
          * @return Value of the property at <CODE>index</CODE>.
 28  
          */
 29  
         public SubComponent getSubComponent(int index) {
 30  307
                 return this.components.get(index - 1);
 31  
         }
 32  
 
 33  
         /**
 34  
          * Indexed setter for property components (index starts at 1 following HL7
 35  
          * convention).
 36  
          * 
 37  
          * @param index
 38  
          *            Index of the property (starts at 1 following HL7 convention).
 39  
          * @param component
 40  
          *            New value of the property at <CODE>index</CODE>.
 41  
          * 
 42  
          * @throws ProfileException
 43  
          */
 44  
         public void setSubComponent(int index, SubComponent component) throws ProfileException {
 45  4426
                 index--;
 46  8852
                 while (components.size() <= index) {
 47  4426
                         components.add(null);
 48  
                 }
 49  4426
                 SubComponent oldComponent = this.components.get(index);
 50  4426
                 this.components.set(index, component);
 51  
                 try {
 52  4426
                         vetoableChangeSupport.fireVetoableChange("components", null, null);
 53  0
                 } catch (java.beans.PropertyVetoException vetoException) {
 54  0
                         this.components.set(index, oldComponent);
 55  0
                         throw new ProfileException(null, vetoException);
 56  4426
                 }
 57  4426
                 propertyChangeSupport.firePropertyChange("components", null, null);
 58  4426
         }
 59  
 
 60  
 
 61  
         /** Returns the number of subcomponents in this component */
 62  
         public int getSubComponents() {
 63  826
                 return this.components.size();
 64  
         }
 65  
 
 66  
         public List<SubComponent> getChildrenAsList() {
 67  0
                 return (this.components);
 68  
         }
 69  
 
 70  
         @Override
 71  
         public String toString() {
 72  0
                 return "Component[" + getName() + "]";
 73  
         }
 74  
 
 75  
 }