001    package ca.uhn.hl7v2.conf.spec.message;
002    
003    import ca.uhn.hl7v2.conf.ProfileException;
004    
005    /**
006     * A specification for a segment group in a conformance profile.  
007     * @author Bryan Tripp
008     */
009    public class SegGroup extends AbstractSegmentContainer implements ProfileStructure {
010        
011        private String predicate;
012        private String name;
013        private String longName;
014        private String usage;
015        private short min;
016        private short max;
017        
018        /** Utility field used by bound properties. */
019        private java.beans.PropertyChangeSupport propertyChangeSupport =  new java.beans.PropertyChangeSupport(this);
020        
021        /** Utility field used by constrained properties. */
022        private java.beans.VetoableChangeSupport vetoableChangeSupport =  new java.beans.VetoableChangeSupport(this);
023        
024        /** Creates a new instance of SegGroup */
025        public SegGroup() {
026        }
027        
028        /** Adds a PropertyChangeListener to the listener list.
029         * @param l The listener to add.
030         */
031        public void addPropertyChangeListener(java.beans.PropertyChangeListener l) {
032            propertyChangeSupport.addPropertyChangeListener(l);
033        }
034        
035        /** Removes a PropertyChangeListener from the listener list.
036         * @param l The listener to remove.
037         */
038        public void removePropertyChangeListener(java.beans.PropertyChangeListener l) {
039            propertyChangeSupport.removePropertyChangeListener(l);
040        }
041        
042        /** Adds a VetoableChangeListener to the listener list.
043         * @param l The listener to add.
044         */
045        public void addVetoableChangeListener(java.beans.VetoableChangeListener l) {
046            vetoableChangeSupport.addVetoableChangeListener(l);
047        }
048        
049        /** Removes a VetoableChangeListener from the listener list.
050         * @param l The listener to remove.
051         */
052        public void removeVetoableChangeListener(java.beans.VetoableChangeListener l) {
053            vetoableChangeSupport.removeVetoableChangeListener(l);
054        }
055        
056        /** Getter for property predicate.
057         * @return Value of property predicate.
058         */
059        public String getPredicate() {
060            return this.predicate;
061        }
062        
063        /** Setter for property predicate.
064         * @param predicate New value of property predicate.
065         *
066         * @throws ProfileException
067         */
068        public void setPredicate(String predicate) throws ProfileException {
069            String oldPredicate = this.predicate;
070            try {
071                vetoableChangeSupport.fireVetoableChange("predicate", oldPredicate, predicate);
072            } catch (Exception e) {
073                throw new ProfileException(null, e);
074            }
075            this.predicate = predicate;
076            propertyChangeSupport.firePropertyChange("predicate", oldPredicate, predicate);
077        }
078        
079        /** Getter for property name.
080         * @return Value of property name.
081         */
082        public String getName() {
083            return this.name;
084        }
085        
086        /** Setter for property name.
087         * @param name New value of property name.
088         *
089         * @throws ProfileException
090         */
091        public void setName(String name) throws ProfileException {
092            String oldName = this.name;
093            try {
094                vetoableChangeSupport.fireVetoableChange("name", oldName, name);
095            } catch (Exception e) {
096                throw new ProfileException(null, e);
097            }            
098            this.name = name;
099            propertyChangeSupport.firePropertyChange("name", oldName, name);
100        }
101        
102        /** Getter for property longName.
103         * @return Value of property longName.
104         */
105        public String getLongName() {
106            return this.longName;
107        }
108        
109        /** Setter for property longName.
110         * @param longName New value of property longName.
111         *
112         * @throws ProfileException
113         */
114        public void setLongName(String longName) throws ProfileException {
115            String oldLongName = this.longName;
116            try {
117                vetoableChangeSupport.fireVetoableChange("longName", oldLongName, longName);            
118            } catch (Exception e) {
119                throw new ProfileException(null, e);
120            }
121            this.longName = longName;
122            propertyChangeSupport.firePropertyChange("longName", oldLongName, longName);
123        }
124        
125        /** Getter for property usage.
126         * @return Value of property usage.
127         */
128        public String getUsage() {
129            return this.usage;
130        }
131        
132        /** Setter for property usage.
133         * @param usage New value of property usage.
134         *
135         * @throws ProfileException
136         */
137        public void setUsage(String usage) throws ProfileException {
138            String oldUsage = this.usage;
139            try {
140                vetoableChangeSupport.fireVetoableChange("usage", oldUsage, usage);
141            } catch (Exception e) {
142                throw new ProfileException(null, e);
143            }
144            this.usage = usage;
145            propertyChangeSupport.firePropertyChange("usage", oldUsage, usage);
146        }
147        
148        /** Getter for property min.
149         * @return Value of property min.
150         */
151        public short getMin() {
152            return this.min;
153        }
154        
155        /** Setter for property min.
156         * @param min New value of property min.
157         *
158         * @throws ProfileException
159         */
160        public void setMin(short min) throws ProfileException {
161            short oldMin = this.min;
162            try {
163                vetoableChangeSupport.fireVetoableChange("min", new Short(oldMin), new Short(min));
164            } catch (Exception e) {
165                throw new ProfileException(null, e);
166            }
167            this.min = min;
168            propertyChangeSupport.firePropertyChange("min", new Short(oldMin), new Short(min));
169        }
170        
171        /** Getter for property max.
172         * @return Value of property max.
173         */
174        public short getMax() {
175            return this.max;
176        }
177        
178        /** Setter for property max.
179         * @param max New value of property max.
180         *
181         * @throws ProfileException
182         */
183        public void setMax(short max) throws ProfileException {
184            short oldMax = this.max;
185            try {
186                vetoableChangeSupport.fireVetoableChange("max", new Short(oldMax), new Short(max));
187            } catch (Exception e) {
188                throw new ProfileException(null, e);
189            }
190            this.max = max;
191            propertyChangeSupport.firePropertyChange("max", new Short(oldMax), new Short(max));
192        }
193        
194    }