1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 package ca.uhn.hl7v2.conf.classes.generator.genclasses;
32
33 import ca.uhn.hl7v2.conf.classes.generator.builders.*;
34
35
36
37
38
39
40
41
42 public class GeneratedConformanceContainer extends GeneratedClass {
43
44
45 public GeneratedConformanceContainer() {
46 }
47
48
49
50
51
52
53
54 private void addChild(ProfileName profileName, int componentNumber, String childGetter) {
55
56
57 this.addMemberVariable("private " + profileName.getClassName() + " " + profileName.getMemberName() + ";");
58
59
60 this.getConstructor().addToBody(childGetter);
61
62
63 GeneratedMethodgenclasses/GeneratedMethod.html#GeneratedMethod">GeneratedMethod getChildMethod = new GeneratedMethod();
64 getChildMethod.addToComments("Provides access to the " + profileName.getOriginalName() + " component child");
65 getChildMethod.addToComments("@return " + profileName.getClassName() + " The " + profileName.getOriginalName() + " component child");
66 getChildMethod.setVisibility("public");
67 getChildMethod.setReturnType(profileName.getClassName());
68 getChildMethod.setName(profileName.getAccessorName());
69 getChildMethod.addToBody("return " + profileName.getMemberName() + ";");
70 this.addMethod(getChildMethod);
71 }
72
73
74
75
76
77 public void addComponent(ProfileName profileName, int componentNumber, boolean hasChildren) {
78 String underlyingType = hasChildren ? "Composite" : "Primitive";
79 String childGetter = " " + profileName.getMemberName() + " = new " + profileName.getClassName() + "( (" + underlyingType + ")hapiType.getComponent(" + componentNumber + ") );";
80 this.addChild(profileName, componentNumber, childGetter);
81 }
82
83
84
85
86
87
88 public void addSubComponent(ProfileName profileName, int subComponentNumber) {
89 this.addComponent(profileName, subComponentNumber, false);
90 }
91
92
93
94
95
96
97 public void addTSSubComponent(ProfileName profileName, int componentNumber, String hl7Version) {
98
99 String componentOneAccessor = "(Primitive)((ca.uhn.hl7v2.model." + hl7Version + ".datatype.TS)(hapiType.getComponent(" + componentNumber + "))).getComponent(0)";
100 String childGetter = " " + profileName.getMemberName() + " = new " + profileName.getClassName() + "( " + componentOneAccessor + " );";
101 this.addChild(profileName, componentNumber, childGetter);
102 }
103
104
105
106
107
108 public void setMinMaxReps(short minReps, short maxReps) {
109
110 GeneratedMethod/genclasses/GeneratedMethod.html#GeneratedMethod">GeneratedMethod maxRepsMethod = new GeneratedMethod();
111 GeneratedMethod/genclasses/GeneratedMethod.html#GeneratedMethod">GeneratedMethod minRepsMethod = new GeneratedMethod();
112
113 this.addMemberVariable("private final short MAX_REPS = " + maxReps + ";");
114 this.addMemberVariable("private final short MIN_REPS = " + minReps + ";");
115
116
117 DocumentationBuilder.getDocumentationBuilder().decorateMaxReps(maxRepsMethod);
118 maxRepsMethod.setVisibility("public");
119 maxRepsMethod.setReturnType("short");
120 maxRepsMethod.setName("getMaxReps");
121 maxRepsMethod.addToBody("return this.MAX_REPS;");
122 this.addMethod(maxRepsMethod);
123
124
125 DocumentationBuilder.getDocumentationBuilder().decorateMaxReps(minRepsMethod);
126 minRepsMethod.setVisibility("public");
127 minRepsMethod.setReturnType("short");
128 minRepsMethod.setName("getMinReps");
129 minRepsMethod.addToBody("return this.MIN_REPS;");
130 this.addMethod(minRepsMethod);
131 }
132
133 }