1
2
3
4
5
6
7
8
9
10 package it.imolinfo.jbi4cics.commareaparser;
11
12 import it.imolinfo.jbi4cics.exception.ParseException;
13 import it.imolinfo.jbi4cics.typemapping.cobol.CobolType;
14 import it.imolinfo.jbi4cics.typemapping.cobol.CobolTypeDescriptor;
15
16
17
18
19
20
21
22 public class PictureDefinition {
23
24
25
26
27 public static final int NUMERIC = 0;
28
29
30
31
32 public static final int STRING = 1;
33
34
35
36
37
38 private int type;
39
40
41
42
43 private int stringLength;
44
45
46
47
48 private int integerLength;
49
50
51
52
53 private int decimalLength;
54
55 private boolean signed;
56
57 private boolean signPlus;
58
59 public PictureDefinition() {
60 }
61
62
63
64
65 public int getDecimalLength() {
66 return decimalLength;
67 }
68
69
70
71
72
73 public void setDecimalLength(int decimalLength) {
74 this.decimalLength = decimalLength;
75 }
76
77
78
79
80 public int getIntegerLength() {
81 return integerLength;
82 }
83
84
85
86
87
88 public void setIntegerLength(int integerLength) {
89 this.integerLength = integerLength;
90 }
91
92
93
94
95 public int getStringLength() {
96 return stringLength;
97 }
98
99
100
101
102
103 public void setStringLength(int stringLength) {
104 this.stringLength = stringLength;
105 }
106
107
108
109
110 public int getType() {
111 return type;
112 }
113
114
115
116
117
118 public final void setType(final int type) {
119 this.type = type;
120 }
121
122 public void populate(CobolTypeDescriptor cobolTypeDescriptor)
123 throws ParseException {
124 switch (type) {
125 case NUMERIC:
126 cobolTypeDescriptor.setType(CobolType.ZONED);
127 cobolTypeDescriptor.setDecimalPartLength(decimalLength);
128 cobolTypeDescriptor.setIntegerPartLength(integerLength);
129 cobolTypeDescriptor.setSigned(signed);
130 if (signPlus) {
131 cobolTypeDescriptor.setZonedSignFormat(
132 CobolTypeDescriptor.SIGN_FORMAT_LEADING_SEPARATE);
133 }
134 break;
135
136 case STRING:
137 cobolTypeDescriptor.setType(CobolType.STRING);
138 cobolTypeDescriptor.setStringLength(stringLength);
139 cobolTypeDescriptor.setPadCharacter(" ");
140 cobolTypeDescriptor.setJustification(
141 CobolTypeDescriptor.STRING_JUSTIFICATION_LEFT);
142 break;
143
144 default:
145 throw new ParseException("CIC000002_Unrecognized_type",
146 new Object[] {type});
147 }
148 }
149
150
151
152
153 public boolean isSigned() {
154 return signed;
155 }
156
157
158
159
160
161 public void setSigned(boolean signed) {
162 this.signed = signed;
163 }
164
165
166
167
168 public boolean isSignPlus() {
169 return signPlus;
170 }
171
172
173
174
175
176 public void setSignPlus(boolean signPlus) {
177 this.signPlus = signPlus;
178 }
179 }