Skip to content

Commit

Permalink
replace binary delimiter with any character
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadia-Adaptive committed Jun 11, 2024
1 parent 397a54f commit 8d1e354
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void main(final String[] args)
private FixMessagePredicate predicate = FixMessagePredicates.alwaysTrue();
private boolean follow = false;
private boolean fixp = false;
private boolean pipeDelimiter = false;
private char delimiter = Character.MIN_VALUE;
private Class<? extends FixDictionary> fixDictionaryType = null;
private Predicate<SessionHeaderDecoder> headerPredicate = null;
private final PrintStream out;
Expand Down Expand Up @@ -142,10 +142,6 @@ private void parseArgs(final String[] args)
fixp = true;
break;

case "pipe-delimiter":
pipeDelimiter = true;
break;

default:
requiredArgument(eqIndex);
}
Expand Down Expand Up @@ -206,6 +202,10 @@ private void parseArgs(final String[] args)
case "log-file-dir":
logFileDir = optionValue;
break;

case "delimiter":
delimiter = optionValue.charAt(0);
break;
}
}
}
Expand Down Expand Up @@ -381,8 +381,8 @@ private void printHelp()
" This can be used to optimize scans that are time based",
false);
printOption(
"pipe-delimiter",
"Replace the binary delimiter with a pipe",
"delimiter",
"Specifies the character to replace the binary delimiter with",
false);
}

Expand All @@ -405,8 +405,8 @@ private void print(
{
final MessageStatus status = message.status();
final long timestamp = message.timestamp();
final String body = pipeDelimiter ? message.body().replace('\u0001', '|') : message.body();
final String body =
delimiter != Character.MIN_VALUE ? message.body().replace('\u0001', delimiter) : message.body();
out.printf("%1$20s: %2$s (%3$s)%n", timestamp, body, status);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void shouldUseDefaultDelimiter()
}

@Test(timeout = TEST_TIMEOUT_IN_MS)
public void canUsePipeAsDelimiter()
public void canUseSpecifiedCharAsDelimiter()
{
setupAndExchangeMessages();

Expand All @@ -91,7 +91,7 @@ public void canUsePipeAsDelimiter()
final ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
final FixArchivePrinter fixArchivePrinter = new FixArchivePrinter(new PrintStream(outputBytes), System.err);
final String[] args = new String[] {
"--pipe-delimiter",
"--delimiter=|",
"--aeron-channel=" + configuration.libraryAeronChannel(),
"--log-file-dir=" + configuration.logFileDir(),
"--aeron-dir-name=" + context.aeronDirectory().getAbsolutePath(),
Expand All @@ -100,7 +100,7 @@ public void canUsePipeAsDelimiter()

fixArchivePrinter.scan(args);

assertThat(outputBytes.toString(), containsString("|112=hi1"));
assertThat(outputBytes.toString(), containsString("|112=hi"));
}

private void setupAndExchangeMessages()
Expand All @@ -110,17 +110,3 @@ private void setupAndExchangeMessages()
assertInitiatingSequenceIndexIs(0);
}
}














0 comments on commit 8d1e354

Please sign in to comment.