3kAPhCc7987hSLMNaHiS0k changeset

Changeset393963333639 (b)
ParentNone (a)
ab
0+public String getRequestString() throws MQException {
0+  RequestBuilder req = new RequestBuilder();
0+ 
0+  req.sessionNumber('0', 3)
0+     .version('0', 3)
0+     .transaction('X', 4)
0+     .language('X', 2)
0+     .callersPhoneNumber('0', 16)
0+     .customerNumber(' ', 16)
0+     .nrUnsuccessfulCalls('0', 3);
0+     
0+  return req.build();
0+}
0+
0+private class RequestBuilder {
0+  private StringBuilder b = new StringBuilder();
0+ 
0+  public RequestBuilder callersPhoneNumber(char pad, int width) {
0+    add(Helper.leftRightFilled(true, getCallersPhoneNumber(), pad, width));
0+    return this;
0+  }
0+ 
0+  public RequestBuilder customerNumber(char pad, int width) throws MQException {
0+    add(Helper.leftRightFilled(false, dynamicSettingMQ.getCustomerNumber(), pad, width));
0+    return this;
0+  }
0+ 
0+  public RequestBuilder language(char pad, int width) throws MQException {
0+    add(Helper.leftRightFilled(true, getLanguage(), pad, width));
0+    return this;
0+  }
0+ 
0+  public RequestBuilder nrUnsuccessfulCalls(char pad, int width) throws MQException {
0+    add(Helper.leftRightFilled(true, dynamicSettingMQ.getNumberOfUnsucceededCalls(), pad, width));
0+    return this;
0+  }
0+ 
0+  public RequestBuilder sessionNumber(char pad, int width) throws MQException {
0+    add(Helper.leftRightFilled(true, getSessionNumberAndIncreaseIt(), pad, width));
0+    return this;
0+  }
0+ 
0+  public RequestBuilder transaction(char pad, int width) throws MQException {
0+    add(Helper.leftRightFilled(true, getTransaction(), pad, width));
0+    return this;
0+  }
0+ 
0+  public RequestBuilder version(char pad, int width) throws MQException {
0+    add(Helper.leftRightFilled(true, getVersion(), pad, width));
0+    return this;
0+  }
0+ 
0+  public String build() {
0+    return b.toString();
0+  }
0+ 
0+  private void add(String str) {
0+    b.append(str);
0+  }
0+}
...
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--- Revision None
+++ Revision 393963333639
@@ -0,0 +1,60 @@
+public String getRequestString() throws MQException {
+ RequestBuilder req = new RequestBuilder();
+
+ req.sessionNumber('0', 3)
+ .version('0', 3)
+ .transaction('X', 4)
+ .language('X', 2)
+ .callersPhoneNumber('0', 16)
+ .customerNumber(' ', 16)
+ .nrUnsuccessfulCalls('0', 3);
+
+ return req.build();
+}
+
+private class RequestBuilder {
+ private StringBuilder b = new StringBuilder();
+
+ public RequestBuilder callersPhoneNumber(char pad, int width) {
+ add(Helper.leftRightFilled(true, getCallersPhoneNumber(), pad, width));
+ return this;
+ }
+
+ public RequestBuilder customerNumber(char pad, int width) throws MQException {
+ add(Helper.leftRightFilled(false, dynamicSettingMQ.getCustomerNumber(), pad, width));
+ return this;
+ }
+
+ public RequestBuilder language(char pad, int width) throws MQException {
+ add(Helper.leftRightFilled(true, getLanguage(), pad, width));
+ return this;
+ }
+
+ public RequestBuilder nrUnsuccessfulCalls(char pad, int width) throws MQException {
+ add(Helper.leftRightFilled(true, dynamicSettingMQ.getNumberOfUnsucceededCalls(), pad, width));
+ return this;
+ }
+
+ public RequestBuilder sessionNumber(char pad, int width) throws MQException {
+ add(Helper.leftRightFilled(true, getSessionNumberAndIncreaseIt(), pad, width));
+ return this;
+ }
+
+ public RequestBuilder transaction(char pad, int width) throws MQException {
+ add(Helper.leftRightFilled(true, getTransaction(), pad, width));
+ return this;
+ }
+
+ public RequestBuilder version(char pad, int width) throws MQException {
+ add(Helper.leftRightFilled(true, getVersion(), pad, width));
+ return this;
+ }
+
+ public String build() {
+ return b.toString();
+ }
+
+ private void add(String str) {
+ b.append(str);
+ }
+}