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