|
19 | 19 |
|
20 | 20 | import java.util.function.Supplier;
|
21 | 21 |
|
| 22 | +import static uk.co.real_logic.sbe.ir.Encoding.Presence.CONSTANT; |
| 23 | +import static uk.co.real_logic.sbe.ir.Encoding.Presence.OPTIONAL; |
| 24 | + |
22 | 25 | /**
|
23 | 26 | * Class to encapsulate a token of information for the message schema stream. This Intermediate Representation (IR)
|
24 | 27 | * is intended to be language, schema, platform independent.
|
25 | 28 | *
|
26 | 29 | * Processing and optimization could be run over a list of Tokens to perform various functions
|
27 | 30 | * <ul>
|
28 |
| - * <li>re-ordering of fields based on encodedLength</li> |
29 |
| - * <li>padding of fields in order to provide expansion room</li> |
30 |
| - * <li>computing offsets of individual fields</li> |
31 |
| - * <li>etc.</li> |
| 31 | + * <li>re-ordering of fields based on encodedLength</li> |
| 32 | + * <li>padding of fields in order to provide expansion room</li> |
| 33 | + * <li>computing offsets of individual fields</li> |
| 34 | + * <li>etc.</li> |
32 | 35 | * </ul>
|
33 | 36 | *
|
34 | 37 | * IR could be used to generate code or other specifications. It should be possible to do the
|
35 | 38 | * following:
|
36 | 39 | * <ul>
|
37 |
| - * <li>generate a FIX/SBE schema from IR</li> |
38 |
| - * <li>generate an ASN.1 spec from IR</li> |
39 |
| - * <li>generate a GPB spec from IR</li> |
40 |
| - * <li>etc.</li> |
| 40 | + * <li>generate a FIX/SBE schema from IR</li> |
| 41 | + * <li>generate an ASN.1 spec from IR</li> |
| 42 | + * <li>generate a GPB spec from IR</li> |
| 43 | + * <li>etc.</li> |
41 | 44 | * </ul>
|
42 | 45 | *
|
43 | 46 | * IR could be serialized to storage or network via code generated by SBE. Then read back in to
|
|
53 | 56 | *
|
54 | 57 | * An example encoding of a message headerStructure might be like this.
|
55 | 58 | * <ul>
|
56 |
| - * <li>Token 0 - Signal = BEGIN_MESSAGE, schemaId = 100</li> |
57 |
| - * <li>Token 1 - Signal = BEGIN_FIELD, schemaId = 25</li> |
58 |
| - * <li>Token 2 - Signal = ENCODING, PrimitiveType = uint32, encodedLength = 4, offset = 0</li> |
59 |
| - * <li>Token 3 - Signal = END_FIELD</li> |
60 |
| - * <li>Token 4 - Signal = END_MESSAGE</li> |
| 59 | + * <li>Token 0 - Signal = BEGIN_MESSAGE, schemaId = 100</li> |
| 60 | + * <li>Token 1 - Signal = BEGIN_FIELD, schemaId = 25</li> |
| 61 | + * <li>Token 2 - Signal = ENCODING, PrimitiveType = uint32, encodedLength = 4, offset = 0</li> |
| 62 | + * <li>Token 3 - Signal = END_FIELD</li> |
| 63 | + * <li>Token 4 - Signal = END_MESSAGE</li> |
61 | 64 | * </ul>
|
62 | 65 | */
|
63 | 66 | public class Token
|
@@ -218,7 +221,7 @@ public int arrayLength()
|
218 | 221 | return encodedLength / encoding.primitiveType().size();
|
219 | 222 | }
|
220 | 223 |
|
221 |
| - public CharSequence switchArray(Supplier<CharSequence> single, Supplier<CharSequence> array) |
| 224 | + public CharSequence switchArray(final Supplier<CharSequence> single, final Supplier<CharSequence> array) |
222 | 225 | {
|
223 | 226 | final int arrayLength = arrayLength();
|
224 | 227 |
|
@@ -258,12 +261,12 @@ public Encoding encoding()
|
258 | 261 |
|
259 | 262 | public boolean isConstantEncoding()
|
260 | 263 | {
|
261 |
| - return encoding.presence() == Encoding.Presence.CONSTANT; |
| 264 | + return encoding.presence() == CONSTANT; |
262 | 265 | }
|
263 | 266 |
|
264 | 267 | public boolean isOptionalEncoding()
|
265 | 268 | {
|
266 |
| - return encoding.presence() == Encoding.Presence.OPTIONAL; |
| 269 | + return encoding.presence() == OPTIONAL; |
267 | 270 | }
|
268 | 271 |
|
269 | 272 | public String toString()
|
|
0 commit comments