Skip to content

Commit 43053d2

Browse files
committed
[Java] Provide byte order as a constant on generated messages and composites.
1 parent 0bfc79c commit 43053d2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,11 +2027,12 @@ private static CharSequence generateFixedFlyweightCode(
20272027
bufferImplementation);
20282028
}
20292029

2030-
private static CharSequence generateCompositeFlyweightCode(
2030+
private CharSequence generateCompositeFlyweightCode(
20312031
final String className, final int size, final String bufferImplementation)
20322032
{
20332033
return String.format(
20342034
" public static final int ENCODED_LENGTH = %2$d;\n" +
2035+
" public static final java.nio.ByteOrder BYTE_ORDER = java.nio.ByteOrder.%4$s;\n\n" +
20352036
" private int offset;\n" +
20362037
" private %3$s buffer;\n\n" +
20372038
" public %1$s wrap(final %3$s buffer, final int offset)\n" +
@@ -2054,7 +2055,8 @@ private static CharSequence generateCompositeFlyweightCode(
20542055
" }\n",
20552056
className,
20562057
size,
2057-
bufferImplementation);
2058+
bufferImplementation,
2059+
ir.byteOrder());
20582060
}
20592061

20602062
private CharSequence generateDecoderFlyweightCode(final String className, final Token token)
@@ -2098,7 +2100,8 @@ private CharSequence generateFlyweightCode(
20982100
" public static final %1$s BLOCK_LENGTH = %2$s;\n" +
20992101
" public static final %3$s TEMPLATE_ID = %4$s;\n" +
21002102
" public static final %5$s SCHEMA_ID = %6$s;\n" +
2101-
" public static final %7$s SCHEMA_VERSION = %8$s;\n\n" +
2103+
" public static final %7$s SCHEMA_VERSION = %8$s;\n" +
2104+
" public static final java.nio.ByteOrder BYTE_ORDER = java.nio.ByteOrder.%14$s;\n\n" +
21022105
" private final %9$s parentMessage = this;\n" +
21032106
" private %11$s buffer;\n" +
21042107
" protected int offset;\n" +
@@ -2158,7 +2161,8 @@ private CharSequence generateFlyweightCode(
21582161
semanticType,
21592162
bufferImplementation,
21602163
wrapMethod,
2161-
actingFields);
2164+
actingFields,
2165+
ir.byteOrder());
21622166
}
21632167

21642168
private CharSequence generateEncoderFlyweightCode(final String className, final Token token)

0 commit comments

Comments
 (0)