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 private final List<SubComponent> components = new ArrayList<>();
16
17
18 public Component() {
19 }
20
21
22
23
24
25
26
27
28
29 public SubComponent getSubComponent(int index) {
30 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 index--;
46 while (components.size() <= index) {
47 components.add(null);
48 }
49 SubComponent oldComponent = this.components.get(index);
50 this.components.set(index, component);
51 try {
52 vetoableChangeSupport.fireVetoableChange("components", null, null);
53 } catch (java.beans.PropertyVetoException vetoException) {
54 this.components.set(index, oldComponent);
55 throw new ProfileException(null, vetoException);
56 }
57 propertyChangeSupport.firePropertyChange("components", null, null);
58 }
59
60
61
62 public int getSubComponents() {
63 return this.components.size();
64 }
65
66 public List<SubComponent> getChildrenAsList() {
67 return (this.components);
68 }
69
70 @Override
71 public String toString() {
72 return "Component[" + getName() + "]";
73 }
74
75 }