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 import ca.uhn.hl7v2.conf.classes.generator.builders.*;
33
34
35
36
37
38
39
40
41 public class GeneratedPrimitive extends GeneratedConformanceContainer {
42 private final DocumentationBuilder docBuilder;
43
44 private boolean hasConstantValue;
45
46
47
48 public GeneratedPrimitive() {
49 super();
50
51 docBuilder = DocumentationBuilder.getDocumentationBuilder();
52
53 hasConstantValue = false;
54
55
56 this.getConstructor().addParam("Primitive hapiPrimitive", "Reference to the underlying HAPI <CODE>Primitive</CODE> data type.");
57 this.getConstructor().addToBody("super( hapiPrimitive );");
58
59 GeneratedMethodr/genclasses/GeneratedMethod.html#GeneratedMethod">GeneratedMethod getMaxLength = new GeneratedMethod();
60 getMaxLength.setName("getMaxLength");
61 getMaxLength.addToBody("return MAX_LENGTH;");
62 getMaxLength.setReturnType("long");
63 getMaxLength.setVisibility("public");
64 docBuilder.decorateMaxLength(getMaxLength);
65 this.addMethod(getMaxLength);
66
67 GeneratedMethodnclasses/GeneratedMethod.html#GeneratedMethod">GeneratedMethod getConstantValue = new GeneratedMethod();
68 getConstantValue.setName("getConstantValue");
69 getConstantValue.addToBody("return CONSTANT_VALUE;");
70 getConstantValue.setReturnType("String");
71 getConstantValue.setVisibility("public");
72 docBuilder.decorateConstantValue(getConstantValue);
73 this.addMethod(getConstantValue);
74
75 }
76
77
78
79
80 public void addConstantValue(String constantValue) {
81 hasConstantValue = true;
82
83 if (constantValue != null) {
84 constantValue = "\"" + constantValue + "\"";
85 } else
86 constantValue = "null";
87
88 this.addMemberVariable("private final String CONSTANT_VALUE = " + constantValue + ";");
89 }
90
91
92
93
94 public void addMaxLength(long maxLength) {
95 this.addMemberVariable("private final int MAX_LENGTH = " + maxLength + ";");
96 }
97
98
99
100
101 public String toString() {
102 if (!hasConstantValue)
103 addConstantValue(null);
104
105 return super.toString();
106 }
107
108 }