1 | |
package ca.uhn.hl7v2.conf.spec.message; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.Arrays; |
5 | |
import java.util.Iterator; |
6 | |
import java.util.List; |
7 | |
|
8 | |
import ca.uhn.hl7v2.conf.ProfileException; |
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
public class AbstractSegmentContainer implements Iterable<ProfileStructure> { |
15 | |
|
16 | |
private String description; |
17 | |
private String reference; |
18 | |
private String impNote; |
19 | 165 | private List<ProfileStructure> children = new ArrayList<ProfileStructure>(); |
20 | |
|
21 | |
|
22 | 165 | private java.beans.PropertyChangeSupport propertyChangeSupport = new java.beans.PropertyChangeSupport(this); |
23 | |
|
24 | |
|
25 | 165 | private java.beans.VetoableChangeSupport vetoableChangeSupport = new java.beans.VetoableChangeSupport(this); |
26 | |
|
27 | |
|
28 | 165 | public AbstractSegmentContainer() { |
29 | 165 | } |
30 | |
|
31 | |
public List<ProfileStructure> getChildrenAsList() { |
32 | 0 | return (children); |
33 | |
} |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public void addPropertyChangeListener(java.beans.PropertyChangeListener l) { |
39 | 0 | propertyChangeSupport.addPropertyChangeListener(l); |
40 | 0 | } |
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
public void removePropertyChangeListener(java.beans.PropertyChangeListener l) { |
46 | 0 | propertyChangeSupport.removePropertyChangeListener(l); |
47 | 0 | } |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
public void addVetoableChangeListener(java.beans.VetoableChangeListener l) { |
53 | 0 | vetoableChangeSupport.addVetoableChangeListener(l); |
54 | 0 | } |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
public void removeVetoableChangeListener(java.beans.VetoableChangeListener l) { |
60 | 0 | vetoableChangeSupport.removeVetoableChangeListener(l); |
61 | 0 | } |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
public String getDescription() { |
67 | 0 | return this.description; |
68 | |
} |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
public void setDescription(String description) throws ProfileException { |
76 | 165 | String oldDescription = this.description; |
77 | |
try { |
78 | 165 | vetoableChangeSupport.fireVetoableChange("description", oldDescription, description); |
79 | 0 | } catch (Exception e) { |
80 | 0 | throw new ProfileException(null, e); |
81 | 165 | } |
82 | 165 | this.description = description; |
83 | 165 | propertyChangeSupport.firePropertyChange("description", oldDescription, description); |
84 | 165 | } |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
public String getReference() { |
90 | 0 | return this.reference; |
91 | |
} |
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
public void setReference(String reference) throws ProfileException { |
99 | 165 | String oldReference = this.reference; |
100 | |
try { |
101 | 165 | vetoableChangeSupport.fireVetoableChange("reference", oldReference, reference); |
102 | 0 | } catch (Exception e) { |
103 | 0 | throw new ProfileException(null, e); |
104 | 165 | } |
105 | 165 | this.reference = reference; |
106 | 165 | propertyChangeSupport.firePropertyChange("reference", oldReference, reference); |
107 | 165 | } |
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
public String getImpNote() { |
113 | 0 | return this.impNote; |
114 | |
} |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
public void setImpNote(String impNote) throws ProfileException { |
122 | 165 | String oldImpNote = this.impNote; |
123 | |
try { |
124 | 165 | vetoableChangeSupport.fireVetoableChange("impNote", oldImpNote, impNote); |
125 | 0 | } catch (Exception e) { |
126 | 0 | throw new ProfileException(null, e); |
127 | 165 | } |
128 | 165 | this.impNote = impNote; |
129 | 165 | propertyChangeSupport.firePropertyChange("impNote", oldImpNote, impNote); |
130 | 165 | } |
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
public ProfileStructure getChild(int index) { |
138 | 20 | return this.children.get(index - 1); |
139 | |
} |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
public void setChild(int index, ProfileStructure structure) throws ProfileException { |
148 | 540 | index--; |
149 | 1080 | while (children.size() <= index) { |
150 | 540 | children.add(null); |
151 | |
} |
152 | 540 | ProfileStructure oldStructure = this.children.get(index); |
153 | 540 | this.children.set(index, structure); |
154 | |
try { |
155 | 540 | vetoableChangeSupport.fireVetoableChange("structure", null, null ); |
156 | |
} |
157 | 0 | catch(java.beans.PropertyVetoException vetoException ) { |
158 | 0 | this.children.set(index, oldStructure); |
159 | 0 | throw new ProfileException(null, vetoException); |
160 | 540 | } |
161 | 540 | propertyChangeSupport.firePropertyChange("structure", null, null ); |
162 | 540 | } |
163 | |
|
164 | |
|
165 | |
public int getChildren() { |
166 | 0 | return this.children.size(); |
167 | |
} |
168 | |
|
169 | |
public Iterator<ProfileStructure> iterator() { |
170 | 105 | return (this.children).iterator(); |
171 | |
} |
172 | |
|
173 | |
} |