From 38b161c1c61e8aa5a23f1c8df877ae83f676b795 Mon Sep 17 00:00:00 2001 From: Enrique Zamudio Date: Wed, 27 Nov 2013 11:03:47 -0600 Subject: [PATCH] Fix #20 use FieldParseInfo's own CustomField if available --- src/main/java/com/solab/iso8583/MessageFactory.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/solab/iso8583/MessageFactory.java b/src/main/java/com/solab/iso8583/MessageFactory.java index 2f1e9ba..c339279 100644 --- a/src/main/java/com/solab/iso8583/MessageFactory.java +++ b/src/main/java/com/solab/iso8583/MessageFactory.java @@ -423,7 +423,11 @@ public class MessageFactory { log.warn("Field {} is not really in the message even though it's in the bitmap", i); bs.clear(i - 1); } else { - IsoValue val = fpi.parseBinary(i, buf, pos, getCustomField(i)); + CustomField decoder = fpi.getDecoder(); + if (decoder == null) { + decoder = getCustomField(i); + } + IsoValue val = fpi.parseBinary(i, buf, pos, decoder); m.setField(i, val); if (val != null) { if (val.getType() == IsoType.NUMERIC || val.getType() == IsoType.DATE10 @@ -450,7 +454,11 @@ public class MessageFactory { log.warn("Field {} is not really in the message even though it's in the bitmap", i); bs.clear(i - 1); } else { - IsoValue val = fpi.parse(i, buf, pos, getCustomField(i)); + CustomField decoder = fpi.getDecoder(); + if (decoder == null) { + decoder = getCustomField(i); + } + IsoValue val = fpi.parse(i, buf, pos, decoder); m.setField(i, val); //To get the correct next position, we need to get the number of bytes, not chars pos += val.toString().getBytes(fpi.getCharacterEncoding()).length;