Coverage Report - ca.uhn.hl7v2.conf.spec.message.AbstractComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractComponent
69%
80/115
100%
2/2
1.852
 
 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  
  * An abstraction of the common features of Field, Component, and SubComponent.  
 10  
  * @author Bryan Tripp
 11  
  */
 12  
 public class AbstractComponent<T> {
 13  
     
 14  
     /** Creates a new instance of AbstractComponent */
 15  11441
     public AbstractComponent() {
 16  11441
     }
 17  
     
 18  
     
 19  
     /** Utility field used by bound properties. */
 20  11441
     protected java.beans.PropertyChangeSupport propertyChangeSupport =  new java.beans.PropertyChangeSupport(this);
 21  
     
 22  
     /** Utility field used by constrained properties. */
 23  11441
     protected java.beans.VetoableChangeSupport vetoableChangeSupport =  new java.beans.VetoableChangeSupport(this);
 24  
     
 25  
     private String impNote;
 26  
     private String description;
 27  
     private String reference;
 28  
     private String predicate;
 29  11441
     private final List<DataValue> dataValues = new ArrayList<DataValue>();
 30  
     private String name;
 31  
     private String usage;
 32  
     private String datatype;
 33  
     private long length;
 34  
     private String constantValue;
 35  
     private String table;
 36  
     
 37  
     /** Adds a PropertyChangeListener to the listener list.
 38  
      * @param l The listener to add.
 39  
      */
 40  
     public void addPropertyChangeListener(java.beans.PropertyChangeListener l) {
 41  0
         propertyChangeSupport.addPropertyChangeListener(l);
 42  0
     }
 43  
     
 44  
     /** Removes a PropertyChangeListener from the listener list.
 45  
      * @param l The listener to remove.
 46  
      */
 47  
     public void removePropertyChangeListener(java.beans.PropertyChangeListener l) {
 48  0
         propertyChangeSupport.removePropertyChangeListener(l);
 49  0
     }
 50  
     
 51  
     /** Adds a VetoableChangeListener to the listener list.
 52  
      * @param l The listener to add.
 53  
      */
 54  
     public void addVetoableChangeListener(java.beans.VetoableChangeListener l) {
 55  0
         vetoableChangeSupport.addVetoableChangeListener(l);
 56  0
     }
 57  
     
 58  
     /** Removes a VetoableChangeListener from the listener list.
 59  
      * @param l The listener to remove.
 60  
      */
 61  
     public void removeVetoableChangeListener(java.beans.VetoableChangeListener l) {
 62  0
         vetoableChangeSupport.removeVetoableChangeListener(l);
 63  0
     }
 64  
     
 65  
     /** Getter for property impNote.
 66  
      * @return Value of property impNote.
 67  
      */
 68  
     public String getImpNote() {
 69  0
         return this.impNote;
 70  
     }
 71  
     
 72  
     /** Setter for property impNote.
 73  
      * @param impNote New value of property impNote.
 74  
      *
 75  
      * @throws ProfileException
 76  
      */
 77  
     public void setImpNote(String impNote) throws ProfileException {
 78  11441
         String oldImpNote = this.impNote;
 79  
         try {
 80  11441
             vetoableChangeSupport.fireVetoableChange("impNote", oldImpNote, impNote);
 81  0
         } catch (Exception e) {
 82  0
             throw new ProfileException(null, e);
 83  11441
         }
 84  11441
         this.impNote = impNote;
 85  11441
         propertyChangeSupport.firePropertyChange("impNote", oldImpNote, impNote);
 86  11441
     }
 87  
     
 88  
     /** Getter for property description.
 89  
      * @return Value of property description.
 90  
      */
 91  
     public String getDescription() {
 92  0
         return this.description;
 93  
     }
 94  
     
 95  
     /** Setter for property description.
 96  
      * @param description New value of property description.
 97  
      *
 98  
      * @throws ProfileException
 99  
      */
 100  
     public void setDescription(String description) throws ProfileException {
 101  11441
         String oldDescription = this.description;
 102  
         try {
 103  11441
             vetoableChangeSupport.fireVetoableChange("description", oldDescription, description);
 104  0
         } catch (Exception e) {
 105  0
             throw new ProfileException(null, e);
 106  11441
         }
 107  11441
         this.description = description;
 108  11441
         propertyChangeSupport.firePropertyChange("description", oldDescription, description);
 109  11441
     }
 110  
     
 111  
     /** Getter for property reference.
 112  
      * @return Value of property reference.
 113  
      */
 114  
     public String getReference() {
 115  1
         return this.reference;
 116  
     }
 117  
     
 118  
     /** Setter for property reference.
 119  
      * @param reference New value of property reference.
 120  
      *
 121  
      * @throws ProfileException
 122  
      */
 123  
     public void setReference(String reference) throws ProfileException {
 124  11441
         String oldReference = this.reference;
 125  
         try {
 126  11441
             vetoableChangeSupport.fireVetoableChange("reference", oldReference, reference);
 127  0
         } catch (Exception e) {
 128  0
             throw new ProfileException(null, e);
 129  11441
         }
 130  11441
         this.reference = reference;
 131  11441
         propertyChangeSupport.firePropertyChange("reference", oldReference, reference);
 132  11441
     }
 133  
     
 134  
     /** Getter for property predicate.
 135  
      * @return Value of property predicate.
 136  
      */
 137  
     public String getPredicate() {
 138  0
         return this.predicate;
 139  
     }
 140  
     
 141  
     /** Setter for property predicate.
 142  
      * @param predicate New value of property predicate.
 143  
      *
 144  
      * @throws ProfileException
 145  
      */
 146  
     public void setPredicate(String predicate) throws ProfileException {
 147  11441
         String oldPredicate = this.predicate;
 148  
         try {
 149  11441
             vetoableChangeSupport.fireVetoableChange("predicate", oldPredicate, predicate);
 150  0
         } catch (Exception e) {
 151  0
             throw new ProfileException(null, e);
 152  11441
         }
 153  11441
         this.predicate = predicate;
 154  11441
         propertyChangeSupport.firePropertyChange("predicate", oldPredicate, predicate);
 155  11441
     }
 156  
     
 157  
     /** Indexed getter for property dataValues.
 158  
      * @param index Index of the property.
 159  
      * @return Value of the property at <CODE>index</CODE>.
 160  
      */
 161  
     public DataValue getDataValues(int index) {
 162  0
         return this.dataValues.get(index);
 163  
     }
 164  
     
 165  
     /** Indexed setter for property dataValues.
 166  
      * @param index Index of the property.
 167  
      * @param dataValues New value of the property at <CODE>index</CODE>.
 168  
      *
 169  
      * @throws ProfileException
 170  
      */
 171  
     public void setDataValues(int index, DataValue dataValue) throws ProfileException {
 172  1164
         while (dataValues.size() <= index) {
 173  582
                 dataValues.add(null);
 174  
         }
 175  582
         DataValue oldDataValues = this.dataValues.get(index);
 176  582
         this.dataValues.set(index, dataValue);
 177  
         try {
 178  582
             vetoableChangeSupport.fireVetoableChange("dataValues", null, null );
 179  
         }
 180  0
         catch(java.beans.PropertyVetoException vetoException ) {
 181  0
             this.dataValues.set(index, oldDataValues);
 182  0
             throw new ProfileException(null, vetoException);
 183  582
         }
 184  582
         propertyChangeSupport.firePropertyChange("dataValues", null, null );
 185  582
     }
 186  
     
 187  
     
 188  
     
 189  
     
 190  
     /** Getter for property name.
 191  
      * @return Value of property name.
 192  
      */
 193  
     public String getName() {
 194  1471
         return this.name;
 195  
     }
 196  
     
 197  
     /** Setter for property name.
 198  
      * @param name New value of property name.
 199  
      *
 200  
      * @throws ProfileException
 201  
      */
 202  
     public void setName(String name) throws ProfileException {
 203  11441
         String oldName = this.name;
 204  
         try {
 205  11441
             vetoableChangeSupport.fireVetoableChange("name", oldName, name);
 206  0
         } catch (Exception e) {
 207  0
             throw new ProfileException(null, e);
 208  11441
         }
 209  11441
         this.name = name;
 210  11441
         propertyChangeSupport.firePropertyChange("name", oldName, name);
 211  11441
     }
 212  
     
 213  
     /** Getter for property usage.
 214  
      * @return Value of property usage.
 215  
      */
 216  
     public String getUsage() {
 217  3085
         return this.usage;
 218  
     }
 219  
     
 220  
     /** Setter for property usage.
 221  
      * @param usage New value of property usage.
 222  
      *
 223  
      * @throws ProfileException
 224  
      */
 225  
     public void setUsage(String usage) throws ProfileException {
 226  13027
         String oldUsage = this.usage;
 227  
         try {
 228  13027
             vetoableChangeSupport.fireVetoableChange("usage", oldUsage, usage);
 229  0
         } catch (Exception e) {
 230  0
             throw new ProfileException(null, e);
 231  13027
         }
 232  13027
         this.usage = usage;
 233  13027
         propertyChangeSupport.firePropertyChange("usage", oldUsage, usage);
 234  13027
     }
 235  
     
 236  
     /** Getter for property datatype.
 237  
      * @return Value of property datatype.
 238  
      */
 239  
     public String getDatatype() {
 240  909
         return this.datatype;
 241  
     }
 242  
     
 243  
     /** Setter for property datatype.
 244  
      * @param datatype New value of property datatype.
 245  
      *
 246  
      * @throws ProfileException
 247  
      */
 248  
     public void setDatatype(String datatype) throws ProfileException {
 249  11441
         String oldDatatype = this.datatype;
 250  
         try {
 251  11441
             vetoableChangeSupport.fireVetoableChange("datatype", oldDatatype, datatype);
 252  0
         } catch (Exception e) {
 253  0
             throw new ProfileException(null, e);
 254  11441
         }
 255  11441
         this.datatype = datatype;
 256  11441
         propertyChangeSupport.firePropertyChange("datatype", oldDatatype, datatype);
 257  11441
     }
 258  
     
 259  
     /** Getter for property length.
 260  
      * @return Value of property length.
 261  
      */
 262  
     public long getLength() {
 263  920
         return this.length;
 264  
     }
 265  
     
 266  
     /** Setter for property length.
 267  
      * @param length New value of property length.
 268  
      *
 269  
      * @throws ProfileException
 270  
      */
 271  
     public void setLength(long length) throws ProfileException {
 272  11324
         long oldLength = this.length;
 273  
         try {
 274  11324
             vetoableChangeSupport.fireVetoableChange("length", new Long(oldLength), new Long(length));
 275  0
         } catch (Exception e) {
 276  0
             throw new ProfileException(null, e);
 277  11324
         }
 278  11324
         this.length = length;
 279  11324
         propertyChangeSupport.firePropertyChange("length", new Long(oldLength), new Long(length));
 280  11324
     }
 281  
     
 282  
     /** Getter for property constantValue.
 283  
      * @return Value of property constantValue.
 284  
      */
 285  
     public String getConstantValue() {
 286  1794
         return this.constantValue;
 287  
     }
 288  
     
 289  
     /** Setter for property constantValue.
 290  
      * @param constantValue New value of property constantValue.
 291  
      *
 292  
      * @throws ProfileException
 293  
      */
 294  
     public void setConstantValue(String constantValue) throws ProfileException {
 295  11441
         String oldConstantValue = this.constantValue;
 296  
         try {
 297  11441
             vetoableChangeSupport.fireVetoableChange("constantValue", oldConstantValue, constantValue);
 298  0
         } catch (Exception e) {
 299  0
             throw new ProfileException(null, e);
 300  11441
         }
 301  11441
         this.constantValue = constantValue;
 302  11441
         propertyChangeSupport.firePropertyChange("constantValue", oldConstantValue, constantValue);
 303  11441
     }
 304  
     
 305  
     /** Getter for property table.
 306  
      * @return Value of property table.
 307  
      */
 308  
     public String getTable() {
 309  1265
         return this.table;
 310  
     }
 311  
     
 312  
     /** Setter for property table.
 313  
      * @param table New value of property table.
 314  
      *
 315  
      * @throws ProfileException
 316  
      */
 317  
     public void setTable(String table) throws ProfileException {
 318  4212
         String oldTable = this.table;
 319  
         try {
 320  4212
             vetoableChangeSupport.fireVetoableChange("table", oldTable, table);
 321  0
         } catch (Exception e) {
 322  0
             throw new ProfileException(null, e);
 323  4212
         }
 324  4212
         this.table = table;
 325  4212
         propertyChangeSupport.firePropertyChange("table", oldTable, table);
 326  4212
     }
 327  
     
 328  
 }