Skip to content

Commit d6c15fc

Browse files
andreydpAndrii Poletaiev
authored andcommitted
Add property to set repeating group delimiter from first tag in group
1 parent e612ee6 commit d6c15fc

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

quickfixj-core/src/main/java/quickfix/DataDictionary.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ private static Supplier<DocumentBuilderFactory> createDocumentBuilderFactorySupp
9393
private boolean checkUserDefinedFields = true;
9494
private boolean checkUnorderedGroupFields = true;
9595
private boolean allowUnknownMessageFields = false;
96+
private boolean firstFieldInGroupIsDelimiter = false;
9697
private String beginString;
9798
private String fullVersion;
9899
private String majorVersion;
@@ -561,6 +562,24 @@ public boolean isAllowUnknownMessageFields() {
561562
return allowUnknownMessageFields;
562563
}
563564

565+
public boolean isFirstFieldInGroupIsDelimiter() {
566+
return firstFieldInGroupIsDelimiter;
567+
}
568+
/**
569+
* Controls whether any field which is
570+
* first in the group would be used as delimiter
571+
*
572+
* @param flag true = use first field from message, false = follow data dictionary
573+
*/
574+
public void setFirstFieldInGroupIsDelimiter(boolean flag) {
575+
firstFieldInGroupIsDelimiter = flag;
576+
for (Map<Integer, GroupInfo> gm : groups.values()) {
577+
for (GroupInfo gi : gm.values()) {
578+
gi.getDataDictionary().setFirstFieldInGroupIsDelimiter(flag);
579+
}
580+
}
581+
}
582+
564583
/**
565584
* Controls whether group fields are in the same order
566585
*

quickfixj-core/src/main/java/quickfix/Message.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ private void parseGroup(String msgType, StringField field, DataDictionary dd, Da
723723
throw MessageUtils.newInvalidMessageException("Repeating group count requires an Integer but found '" + field.getValue() + "' in " + messageData, this);
724724
}
725725
parent.setField(groupCountTag, field);
726-
final int firstField = rg.getDelimiterField();
726+
int firstField = groupDataDictionary.isFirstFieldInGroupIsDelimiter() ? -1 : rg.getDelimiterField();
727727
Group group = null;
728728
boolean inGroupParse = true;
729729
while (inGroupParse) {
@@ -733,7 +733,9 @@ private void parseGroup(String msgType, StringField field, DataDictionary dd, Da
733733
break;
734734
}
735735
int tag = field.getTag();
736-
if (tag == firstField) {
736+
boolean shouldCreateNewGroup = tag == firstField || (groupDataDictionary.isFirstFieldInGroupIsDelimiter() && firstField < 0);
737+
if (shouldCreateNewGroup) {
738+
firstField = tag;
737739
addGroupRefToParent(group, parent);
738740
group = new Group(groupCountTag, firstField, groupDataDictionary.getOrderedFields());
739741
group.setField(field);

0 commit comments

Comments
 (0)