From 254fb8666b9d38358d0dd4cb0e0c933b1e5ff9fd Mon Sep 17 00:00:00 2001 From: Barzilai Spinak Date: Thu, 6 Oct 2022 18:13:16 -0300 Subject: [PATCH] OriginalDataElementsWrapper: change STAN to a long to support 12-digit STANs --- .../jpos/cmf/OriginalDataElementsWrapper.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/cmf/src/main/java/org/jpos/cmf/OriginalDataElementsWrapper.java b/modules/cmf/src/main/java/org/jpos/cmf/OriginalDataElementsWrapper.java index 02628951d6..b6ba0ebcf3 100644 --- a/modules/cmf/src/main/java/org/jpos/cmf/OriginalDataElementsWrapper.java +++ b/modules/cmf/src/main/java/org/jpos/cmf/OriginalDataElementsWrapper.java @@ -33,14 +33,13 @@ public final class OriginalDataElementsWrapper { private static final int MAX_FIELD_LENGTH = 41; private String originalMTI; - private int originalSTAN; + private long originalSTAN; private Date originalLocalDate; private String originalAcquiringInstCode; public OriginalDataElementsWrapper() { } public OriginalDataElementsWrapper(String fieldValue) { - Objects.requireNonNull(fieldValue); if (fieldValue.length() > MAX_FIELD_LENGTH) @@ -50,11 +49,9 @@ public OriginalDataElementsWrapper(String fieldValue) { } private void parse(String fieldValue) { - try { - setOriginalMTI(fieldValue.substring(0, 4)); - setOriginalSTAN(Integer.valueOf(fieldValue.substring(4, 16))); + setOriginalSTAN(Long.parseLong(fieldValue.substring(4, 16))); setOriginalLocalDate(DateUtils.parseDate(fieldValue.substring(16, 30), "yyyyMMddHHmmss")); setOriginalAcquiringInstCode(fieldValue.substring(30)); } @@ -65,7 +62,6 @@ private void parse(String fieldValue) { } public String serialize() { - StringBuilder r = new StringBuilder(); if (StringUtils.isNotBlank(getOriginalMTI())) @@ -73,7 +69,7 @@ public String serialize() { else r.append("0000"); - r.append(StringUtils.leftPad(Integer.toString(getOriginalSTAN()), 12, '0')); + r.append(StringUtils.leftPad(Long.toString(getOriginalSTAN()), 12, '0')); if (getOriginalLocalDate() != null) r.append(ISODate.formatDate(getOriginalLocalDate(), "yyyyMMddHHmmss")); @@ -101,12 +97,11 @@ public void setOriginalMTI(String originalMTI) { this.originalMTI = originalMTI; } - public int getOriginalSTAN() { + public long getOriginalSTAN() { return originalSTAN; } - public void setOriginalSTAN(int originalSTAN) { - + public void setOriginalSTAN(long originalSTAN) { if (originalSTAN < 0) throw new IllegalArgumentException("originalSTAN must be a positive number"); @@ -126,7 +121,6 @@ public String getOriginalAcquiringInstCode() { } public void setOriginalAcquiringInstCode(String originalAcquiringInstCode) { - Objects.requireNonNull(originalAcquiringInstCode); if (originalAcquiringInstCode.length() > 11)