Coverage Report - ca.uhn.hl7v2.conf.spec.message.Field
 
Classes in this File Line Coverage Branch Coverage Complexity
Field
67%
37/55
100%
2/2
1.6
 
 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 specific field in a message profile.  
 10  
  * @author Bryan Tripp
 11  
  */
 12  
 public class Field extends AbstractComponent<Field> {
 13  
     
 14  
     /** Utility field used by bound properties. */
 15  1586
     private java.beans.PropertyChangeSupport propertyChangeSupport =  new java.beans.PropertyChangeSupport(this);
 16  
     
 17  
     /** Utility field used by constrained properties. */
 18  1586
     private java.beans.VetoableChangeSupport vetoableChangeSupport =  new java.beans.VetoableChangeSupport(this);
 19  
     
 20  
     private short min;
 21  
     private short max;
 22  
     private short itemNo;
 23  
 
 24  1586
     private final List<Component> components = new ArrayList<Component>();
 25  
     
 26  
     /** Creates a new instance of Field */
 27  1586
     public Field() {
 28  1586
     }
 29  
     
 30  
     /** Adds a PropertyChangeListener to the listener list.
 31  
      * @param l The listener to add.
 32  
      */
 33  
     public void addPropertyChangeListener(java.beans.PropertyChangeListener l) {
 34  0
         propertyChangeSupport.addPropertyChangeListener(l);
 35  0
     }
 36  
     
 37  
     /** Removes a PropertyChangeListener from the listener list.
 38  
      * @param l The listener to remove.
 39  
      */
 40  
     public void removePropertyChangeListener(java.beans.PropertyChangeListener l) {
 41  0
         propertyChangeSupport.removePropertyChangeListener(l);
 42  0
     }
 43  
     
 44  
     /** Adds a VetoableChangeListener to the listener list.
 45  
      * @param l The listener to add.
 46  
      */
 47  
     public void addVetoableChangeListener(java.beans.VetoableChangeListener l) {
 48  0
         vetoableChangeSupport.addVetoableChangeListener(l);
 49  0
     }
 50  
     
 51  
     /** Removes a VetoableChangeListener from the listener list.
 52  
      * @param l The listener to remove.
 53  
      */
 54  
     public void removeVetoableChangeListener(java.beans.VetoableChangeListener l) {
 55  0
         vetoableChangeSupport.removeVetoableChangeListener(l);
 56  0
     }
 57  
     
 58  
     /** Getter for property min.
 59  
      * @return Value of property min.
 60  
      */
 61  
     public short getMin() {
 62  530
         return this.min;
 63  
     }
 64  
     
 65  
     /** Setter for property min.
 66  
      * @param min New value of property min.
 67  
      *
 68  
      * @throws ProfileException
 69  
      */
 70  
     public void setMin(short min) throws ProfileException {
 71  1586
         short oldMin = this.min;
 72  
         try {
 73  1586
             vetoableChangeSupport.fireVetoableChange("min", new Short(oldMin), new Short(min));
 74  0
         } catch (Exception e) {
 75  0
             throw new ProfileException(null, e);
 76  1586
         }
 77  1586
         this.min = min;
 78  1586
         propertyChangeSupport.firePropertyChange("min", new Short(oldMin), new Short(min));
 79  1586
     }
 80  
     
 81  
     /** Getter for property max.
 82  
      * @return Value of property max.
 83  
      */
 84  
     public short getMax() {
 85  530
         return this.max;
 86  
     }
 87  
     
 88  
     /** Setter for property max.
 89  
      * @param max New value of property max.
 90  
      *
 91  
      * @throws ProfileException
 92  
      */
 93  
     public void setMax(short max) throws ProfileException {
 94  1586
         short oldMax = this.max;
 95  
         try {
 96  1586
             vetoableChangeSupport.fireVetoableChange("max", new Short(oldMax), new Short(max));
 97  0
         } catch (Exception e) {
 98  0
             throw new ProfileException(null, e);
 99  1586
         }
 100  1586
         this.max = max;
 101  1586
         propertyChangeSupport.firePropertyChange("max", new Short(oldMax), new Short(max));
 102  1586
     }
 103  
     
 104  
     /** Getter for property itemNo.
 105  
      * @return Value of property itemNo.
 106  
      */
 107  
     public short getItemNo() {
 108  1
         return this.itemNo;
 109  
     }
 110  
     
 111  
     /** Setter for property itemNo.
 112  
      * @param itemNo New value of property itemNo.
 113  
      *
 114  
      * @throws ProfileException
 115  
      */
 116  
     public void setItemNo(short itemNo) throws ProfileException {
 117  1558
         short oldItemNo = this.itemNo;
 118  
         try {
 119  1558
             vetoableChangeSupport.fireVetoableChange("itemNo", new Short(oldItemNo), new Short(itemNo));
 120  0
         } catch (Exception e) {
 121  0
             throw new ProfileException(null, e);
 122  1558
         }            
 123  1558
         this.itemNo = itemNo;
 124  1558
         propertyChangeSupport.firePropertyChange("itemNo", new Short(oldItemNo), new Short(itemNo));
 125  1558
     }    
 126  
     
 127  
     /** Indexed getter for property components (index starts at 1 following HL7 convention).
 128  
      * @param index Index of the property (starts at 1 following HL7 convention).
 129  
      * @return Value of the property at <CODE>index</CODE>.
 130  
      */
 131  
     public Component getComponent(int index) {
 132  402
         return this.components.get(index - 1);
 133  
     }
 134  
     
 135  
     /** Indexed setter for property components (index starts at 1 following HL7 convention).
 136  
      * @param index Index of the property (starts at 1 following HL7 convention).
 137  
      * @param component New value of the property at <CODE>index</CODE>.
 138  
      *
 139  
      * @throws ProfileException
 140  
      */
 141  
     public void setComponent(int index, Component component) throws ProfileException {
 142  5429
         index--;
 143  10858
         while (components.size() <= index) {
 144  5429
                 components.add(null);
 145  
         }
 146  5429
         Component oldComponent = this.components.get(index);
 147  5429
         this.components.set(index, component);
 148  
         try {
 149  5429
             vetoableChangeSupport.fireVetoableChange("components", null, null );
 150  
         }
 151  0
         catch(java.beans.PropertyVetoException vetoException ) {
 152  0
             this.components.set(index, oldComponent);
 153  0
             throw new ProfileException(null, vetoException);
 154  5429
         }
 155  5429
         propertyChangeSupport.firePropertyChange("components", null, null );
 156  5429
     }    
 157  
 
 158  
     
 159  
     /** Returns the number of components */
 160  
     public int getComponents() {
 161  862
                 return this.components.size();
 162  
     }
 163  
 
 164  
     /** Returns the number of components */
 165  
     public List<Component> getChildrenAsList() {
 166  0
         return (this.components);
 167  
     }
 168  
     
 169  
 }
 170  
     
 171