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 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
public class Component extends AbstractComponent<Component> { |
14 | |
|
15 | 26385 | private final List<SubComponent> components = new ArrayList<SubComponent>(); |
16 | |
|
17 | |
|
18 | 26385 | public Component() { |
19 | 26385 | } |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public SubComponent getSubComponent(int index) { |
30 | 20 | return this.components.get(index - 1); |
31 | |
} |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
public void setSubComponent(int index, SubComponent component) throws ProfileException { |
45 | 21770 | index--; |
46 | 43540 | while (components.size() <= index) { |
47 | 21770 | components.add(null); |
48 | |
} |
49 | 21770 | SubComponent oldComponent = this.components.get(index); |
50 | 21770 | this.components.set(index, component); |
51 | |
try { |
52 | 21770 | vetoableChangeSupport.fireVetoableChange("components", null, null); |
53 | 0 | } catch (java.beans.PropertyVetoException vetoException) { |
54 | 0 | this.components.set(index, oldComponent); |
55 | 0 | throw new ProfileException(null, vetoException); |
56 | 21770 | } |
57 | 21770 | propertyChangeSupport.firePropertyChange("components", null, null); |
58 | 21770 | } |
59 | |
|
60 | |
|
61 | |
|
62 | |
public int getSubComponents() { |
63 | 2025 | return this.components.size(); |
64 | |
} |
65 | |
|
66 | |
public List<SubComponent> getChildrenAsList() { |
67 | 0 | return (this.components); |
68 | |
} |
69 | |
|
70 | |
@Override |
71 | |
public String toString() { |
72 | 0 | return "Component[" + getName() + "]"; |
73 | |
} |
74 | |
|
75 | |
} |