a | b | |
---|
| 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 | + | } |
---|
... | |
---|