Skip to content

Commit b2ac939

Browse files
committed
[Java]: Fix for aeron-io#197 - TokenListener.onGroupHeader(Token, int) added as a meta data callback to indicate the number of times the group with repeat.
1 parent a601c48 commit b2ac939

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

examples/java/uk/co/real_logic/sbe/examples/ExampleTokenListener.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ public void onEndComposite(final Token fieldToken, final List<Token> tokens, fin
124124
namedScope.pop();
125125
}
126126

127+
public void onGroupHeader(final Token token, final int numInGroup)
128+
{
129+
printScope();
130+
out.append(token.name())
131+
.append(" Group Header : numInGroup=")
132+
.append(Integer.toString(numInGroup))
133+
.println();
134+
}
135+
127136
public void onBeginGroup(final Token token, final int groupIndex, final int numInGroup)
128137
{
129138
namedScope.push(token.name() + ".");

main/java/uk/co/real_logic/sbe/otf/OtfMessageDecoder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ private static int decodeGroups(final DirectBuffer buffer,
123123
final int nextGroupIndex = findNextOrLimit(tokens, beginFieldsIndex, toIndex, Signal.BEGIN_GROUP);
124124
final int endOfFieldsIndex = Math.min(endGroupIndex, nextGroupIndex) - 1;
125125

126+
listener.onGroupHeader(token, numInGroup);
127+
126128
for (int g = 0; g < numInGroup; g++)
127129
{
128130
listener.onBeginGroup(token, g, numInGroup);

main/java/uk/co/real_logic/sbe/otf/TokenListener.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ void onBitSet(Token fieldToken,
106106
*/
107107
void onEndComposite(Token fieldToken, List<Token> tokens, int fromIndex, int toIndex);
108108

109+
/**
110+
* Group encountered.
111+
*
112+
* @param token describing the group.
113+
* @param numInGroup number of times the group will be repeated.
114+
*/
115+
void onGroupHeader(Token token, int numInGroup);
116+
109117
/**
110118
* Beginning of group encoded type encountered.
111119
*

0 commit comments

Comments
 (0)