From 3b1cf15c3ed9046099113afb180d0ff36c481fc4 Mon Sep 17 00:00:00 2001 From: Enrique Zamudio Date: Wed, 27 Nov 2013 11:02:58 -0600 Subject: [PATCH] Parse fields with subfields in parse guides for #17 --- .../com/solab/iso8583/parse/ConfigParser.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/solab/iso8583/parse/ConfigParser.java b/src/main/java/com/solab/iso8583/parse/ConfigParser.java index 38780ab..054fea7 100644 --- a/src/main/java/com/solab/iso8583/parse/ConfigParser.java +++ b/src/main/java/com/solab/iso8583/parse/ConfigParser.java @@ -243,13 +243,25 @@ public class ConfigParser { } protected static FieldParseInfo getParser( - Element f, MessageFactory mfact) { + Element f, MessageFactory mfact) throws IOException { IsoType itype = IsoType.valueOf(f.getAttribute("type")); int length = 0; if (f.getAttribute("length").length() > 0) { length = Integer.parseInt(f.getAttribute("length")); } - return FieldParseInfo.getInstance(itype, length, mfact.getCharacterEncoding()); + FieldParseInfo fpi = FieldParseInfo.getInstance(itype, length, mfact.getCharacterEncoding()); + NodeList subs = f.getElementsByTagName("field"); + if (subs != null && subs.getLength() > 0) { + final CompositeField combo = new CompositeField(); + for (int i=0; i void parseGuides( @@ -273,8 +285,10 @@ public class ConfigParser { NodeList fields = elem.getElementsByTagName("field"); for (int j = 0; j < fields.getLength(); j++) { Element f = (Element)fields.item(j); - int num = Integer.parseInt(f.getAttribute("num")); - parseMap.put(num, getParser(f, mfact)); + if (f.getParentNode()==elem) { + int num = Integer.parseInt(f.getAttribute("num")); + parseMap.put(num, getParser(f, mfact)); + } } mfact.setParseMap(type, parseMap); guides.put(type, parseMap);