-
Notifications
You must be signed in to change notification settings - Fork 514
/
FrameCodecDecoder.java
983 lines (820 loc) · 27.3 KB
/
FrameCodecDecoder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
/* Generated SBE (Simple Binary Encoding) message codec. */
package uk.co.real_logic.sbe.ir.generated;
import org.agrona.MutableDirectBuffer;
import org.agrona.DirectBuffer;
/**
* Frame Header for start of encoding IR.
*/
@SuppressWarnings("all")
public final class FrameCodecDecoder
{
private static final boolean ENABLE_BOUNDS_CHECKS = !Boolean.getBoolean("agrona.disable.bounds.checks");
private static final boolean SBE_ENABLE_IR_PRECEDENCE_CHECKS = Boolean.parseBoolean(System.getProperty(
"sbe.enable.ir.precedence.checks",
Boolean.toString(ENABLE_BOUNDS_CHECKS)));
/**
* The states in which a encoder/decoder/codec can live.
*
* <p>The state machine diagram below, encoded in the dot language, describes
* the valid state transitions according to the order in which fields may be
* accessed safely. Tools such as PlantUML and Graphviz can render it.
*
* <pre>{@code
* digraph G {
* NOT_WRAPPED -> V0_BLOCK [label=" wrap(version=0) "];
* V0_BLOCK -> V0_BLOCK [label=" irId(?) "];
* V0_BLOCK -> V0_BLOCK [label=" irVersion(?) "];
* V0_BLOCK -> V0_BLOCK [label=" schemaVersion(?) "];
* V0_BLOCK -> V0_BLOCK [label=" packageNameLength() "];
* V0_BLOCK -> V0_PACKAGENAME_DONE [label=" packageName(?) "];
* V0_PACKAGENAME_DONE -> V0_PACKAGENAME_DONE [label=" namespaceNameLength() "];
* V0_PACKAGENAME_DONE -> V0_NAMESPACENAME_DONE [label=" namespaceName(?) "];
* V0_NAMESPACENAME_DONE -> V0_NAMESPACENAME_DONE [label=" semanticVersionLength() "];
* V0_NAMESPACENAME_DONE -> V0_SEMANTICVERSION_DONE [label=" semanticVersion(?) "];
* }
* }</pre>
*/
private static class CodecStates
{
private static final int NOT_WRAPPED = 0;
private static final int V0_BLOCK = 1;
private static final int V0_PACKAGENAME_DONE = 2;
private static final int V0_NAMESPACENAME_DONE = 3;
private static final int V0_SEMANTICVERSION_DONE = 4;
private static final String[] STATE_NAME_LOOKUP =
{
"NOT_WRAPPED",
"V0_BLOCK",
"V0_PACKAGENAME_DONE",
"V0_NAMESPACENAME_DONE",
"V0_SEMANTICVERSION_DONE",
};
private static final String[] STATE_TRANSITIONS_LOOKUP =
{
"\"wrap(version=0)\"",
"\"irId(?)\", \"irVersion(?)\", \"schemaVersion(?)\", \"packageNameLength()\", \"packageName(?)\"",
"\"namespaceNameLength()\", \"namespaceName(?)\"",
"\"semanticVersionLength()\", \"semanticVersion(?)\"",
"",
};
private static String name(final int state)
{
return STATE_NAME_LOOKUP[state];
}
private static String transitions(final int state)
{
return STATE_TRANSITIONS_LOOKUP[state];
}
}
private int codecState = CodecStates.NOT_WRAPPED;
private int codecState()
{
return codecState;
}
private void codecState(int newState)
{
codecState = newState;
}
public static final int BLOCK_LENGTH = 12;
public static final int TEMPLATE_ID = 1;
public static final int SCHEMA_ID = 1;
public static final int SCHEMA_VERSION = 0;
public static final String SEMANTIC_VERSION = "";
public static final java.nio.ByteOrder BYTE_ORDER = java.nio.ByteOrder.LITTLE_ENDIAN;
private final FrameCodecDecoder parentMessage = this;
private DirectBuffer buffer;
private int offset;
private int limit;
int actingBlockLength;
int actingVersion;
public int sbeBlockLength()
{
return BLOCK_LENGTH;
}
public int sbeTemplateId()
{
return TEMPLATE_ID;
}
public int sbeSchemaId()
{
return SCHEMA_ID;
}
public int sbeSchemaVersion()
{
return SCHEMA_VERSION;
}
public String sbeSemanticType()
{
return "";
}
public DirectBuffer buffer()
{
return buffer;
}
public int offset()
{
return offset;
}
private void onWrap(final int actingVersion)
{
if (actingVersion >= 0)
{
codecState(CodecStates.V0_BLOCK);
return;
}
throw new IllegalStateException("Unsupported acting version: " + actingVersion);
}
public FrameCodecDecoder wrap(
final DirectBuffer buffer,
final int offset,
final int actingBlockLength,
final int actingVersion)
{
if (buffer != this.buffer)
{
this.buffer = buffer;
}
this.offset = offset;
this.actingBlockLength = actingBlockLength;
this.actingVersion = actingVersion;
limit(offset + actingBlockLength);
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onWrap(actingVersion);
}
return this;
}
public FrameCodecDecoder wrapAndApplyHeader(
final DirectBuffer buffer,
final int offset,
final MessageHeaderDecoder headerDecoder)
{
headerDecoder.wrap(buffer, offset);
final int templateId = headerDecoder.templateId();
if (TEMPLATE_ID != templateId)
{
throw new IllegalStateException("Invalid TEMPLATE_ID: " + templateId);
}
return wrap(
buffer,
offset + MessageHeaderDecoder.ENCODED_LENGTH,
headerDecoder.blockLength(),
headerDecoder.version());
}
public FrameCodecDecoder sbeRewind()
{
return wrap(buffer, offset, actingBlockLength, actingVersion);
}
public int sbeDecodedLength()
{
final int currentLimit = limit();
final int currentCodecState = codecState();
sbeSkip();
final int decodedLength = encodedLength();
limit(currentLimit);
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
codecState(currentCodecState);
}
return decodedLength;
}
public int actingVersion()
{
return actingVersion;
}
public int encodedLength()
{
return limit - offset;
}
public int limit()
{
return limit;
}
public void limit(final int limit)
{
this.limit = limit;
}
public static int irIdId()
{
return 1;
}
public static int irIdSinceVersion()
{
return 0;
}
public static int irIdEncodingOffset()
{
return 0;
}
public static int irIdEncodingLength()
{
return 4;
}
public static String irIdMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
private void onIrIdAccessed()
{
if (codecState() == CodecStates.NOT_WRAPPED)
{
throw new IllegalStateException("Illegal field access order. " +
"Cannot access field \"irId\" in state: " + CodecStates.name(codecState()) +
". Expected one of these transitions: [" + CodecStates.transitions(codecState()) +
"]. Please see the diagram in the Javadoc of the class FrameCodecDecoder#CodecStates.");
}
}
public static int irIdNullValue()
{
return -2147483648;
}
public static int irIdMinValue()
{
return -2147483647;
}
public static int irIdMaxValue()
{
return 2147483647;
}
public int irId()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onIrIdAccessed();
}
return buffer.getInt(offset + 0, BYTE_ORDER);
}
public static int irVersionId()
{
return 2;
}
public static int irVersionSinceVersion()
{
return 0;
}
public static int irVersionEncodingOffset()
{
return 4;
}
public static int irVersionEncodingLength()
{
return 4;
}
public static String irVersionMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
private void onIrVersionAccessed()
{
if (codecState() == CodecStates.NOT_WRAPPED)
{
throw new IllegalStateException("Illegal field access order. " +
"Cannot access field \"irVersion\" in state: " + CodecStates.name(codecState()) +
". Expected one of these transitions: [" + CodecStates.transitions(codecState()) +
"]. Please see the diagram in the Javadoc of the class FrameCodecDecoder#CodecStates.");
}
}
public static int irVersionNullValue()
{
return -2147483648;
}
public static int irVersionMinValue()
{
return -2147483647;
}
public static int irVersionMaxValue()
{
return 2147483647;
}
public int irVersion()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onIrVersionAccessed();
}
return buffer.getInt(offset + 4, BYTE_ORDER);
}
public static int schemaVersionId()
{
return 3;
}
public static int schemaVersionSinceVersion()
{
return 0;
}
public static int schemaVersionEncodingOffset()
{
return 8;
}
public static int schemaVersionEncodingLength()
{
return 4;
}
public static String schemaVersionMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
private void onSchemaVersionAccessed()
{
if (codecState() == CodecStates.NOT_WRAPPED)
{
throw new IllegalStateException("Illegal field access order. " +
"Cannot access field \"schemaVersion\" in state: " + CodecStates.name(codecState()) +
". Expected one of these transitions: [" + CodecStates.transitions(codecState()) +
"]. Please see the diagram in the Javadoc of the class FrameCodecDecoder#CodecStates.");
}
}
public static int schemaVersionNullValue()
{
return -2147483648;
}
public static int schemaVersionMinValue()
{
return -2147483647;
}
public static int schemaVersionMaxValue()
{
return 2147483647;
}
public int schemaVersion()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onSchemaVersionAccessed();
}
return buffer.getInt(offset + 8, BYTE_ORDER);
}
public static int packageNameId()
{
return 4;
}
public static int packageNameSinceVersion()
{
return 0;
}
public static String packageNameCharacterEncoding()
{
return java.nio.charset.StandardCharsets.UTF_8.name();
}
public static String packageNameMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public static int packageNameHeaderLength()
{
return 2;
}
void onPackageNameLengthAccessed()
{
switch (codecState())
{
case CodecStates.V0_BLOCK:
codecState(CodecStates.V0_BLOCK);
break;
default:
throw new IllegalStateException("Illegal field access order. " +
"Cannot decode length of var data \"packageName\" in state: " + CodecStates.name(codecState()) +
". Expected one of these transitions: [" + CodecStates.transitions(codecState()) +
"]. Please see the diagram in the Javadoc of the class FrameCodecDecoder#CodecStates.");
}
}
private void onPackageNameAccessed()
{
switch (codecState())
{
case CodecStates.V0_BLOCK:
codecState(CodecStates.V0_PACKAGENAME_DONE);
break;
default:
throw new IllegalStateException("Illegal field access order. " +
"Cannot access field \"packageName\" in state: " + CodecStates.name(codecState()) +
". Expected one of these transitions: [" + CodecStates.transitions(codecState()) +
"]. Please see the diagram in the Javadoc of the class FrameCodecDecoder#CodecStates.");
}
}
public int packageNameLength()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onPackageNameLengthAccessed();
}
final int limit = parentMessage.limit();
return (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
}
public int skipPackageName()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onPackageNameAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
final int dataOffset = limit + headerLength;
parentMessage.limit(dataOffset + dataLength);
return dataLength;
}
public int getPackageName(final MutableDirectBuffer dst, final int dstOffset, final int length)
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onPackageNameAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
final int bytesCopied = Math.min(length, dataLength);
parentMessage.limit(limit + headerLength + dataLength);
buffer.getBytes(limit + headerLength, dst, dstOffset, bytesCopied);
return bytesCopied;
}
public int getPackageName(final byte[] dst, final int dstOffset, final int length)
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onPackageNameAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
final int bytesCopied = Math.min(length, dataLength);
parentMessage.limit(limit + headerLength + dataLength);
buffer.getBytes(limit + headerLength, dst, dstOffset, bytesCopied);
return bytesCopied;
}
public void wrapPackageName(final DirectBuffer wrapBuffer)
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onPackageNameAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
parentMessage.limit(limit + headerLength + dataLength);
wrapBuffer.wrap(buffer, limit + headerLength, dataLength);
}
public String packageName()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onPackageNameAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
parentMessage.limit(limit + headerLength + dataLength);
if (0 == dataLength)
{
return "";
}
final byte[] tmp = new byte[dataLength];
buffer.getBytes(limit + headerLength, tmp, 0, dataLength);
return new String(tmp, java.nio.charset.StandardCharsets.UTF_8);
}
public static int namespaceNameId()
{
return 5;
}
public static int namespaceNameSinceVersion()
{
return 0;
}
public static String namespaceNameCharacterEncoding()
{
return java.nio.charset.StandardCharsets.UTF_8.name();
}
public static String namespaceNameMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public static int namespaceNameHeaderLength()
{
return 2;
}
void onNamespaceNameLengthAccessed()
{
switch (codecState())
{
case CodecStates.V0_PACKAGENAME_DONE:
codecState(CodecStates.V0_PACKAGENAME_DONE);
break;
default:
throw new IllegalStateException("Illegal field access order. " +
"Cannot decode length of var data \"namespaceName\" in state: " + CodecStates.name(codecState()) +
". Expected one of these transitions: [" + CodecStates.transitions(codecState()) +
"]. Please see the diagram in the Javadoc of the class FrameCodecDecoder#CodecStates.");
}
}
private void onNamespaceNameAccessed()
{
switch (codecState())
{
case CodecStates.V0_PACKAGENAME_DONE:
codecState(CodecStates.V0_NAMESPACENAME_DONE);
break;
default:
throw new IllegalStateException("Illegal field access order. " +
"Cannot access field \"namespaceName\" in state: " + CodecStates.name(codecState()) +
". Expected one of these transitions: [" + CodecStates.transitions(codecState()) +
"]. Please see the diagram in the Javadoc of the class FrameCodecDecoder#CodecStates.");
}
}
public int namespaceNameLength()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onNamespaceNameLengthAccessed();
}
final int limit = parentMessage.limit();
return (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
}
public int skipNamespaceName()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onNamespaceNameAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
final int dataOffset = limit + headerLength;
parentMessage.limit(dataOffset + dataLength);
return dataLength;
}
public int getNamespaceName(final MutableDirectBuffer dst, final int dstOffset, final int length)
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onNamespaceNameAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
final int bytesCopied = Math.min(length, dataLength);
parentMessage.limit(limit + headerLength + dataLength);
buffer.getBytes(limit + headerLength, dst, dstOffset, bytesCopied);
return bytesCopied;
}
public int getNamespaceName(final byte[] dst, final int dstOffset, final int length)
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onNamespaceNameAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
final int bytesCopied = Math.min(length, dataLength);
parentMessage.limit(limit + headerLength + dataLength);
buffer.getBytes(limit + headerLength, dst, dstOffset, bytesCopied);
return bytesCopied;
}
public void wrapNamespaceName(final DirectBuffer wrapBuffer)
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onNamespaceNameAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
parentMessage.limit(limit + headerLength + dataLength);
wrapBuffer.wrap(buffer, limit + headerLength, dataLength);
}
public String namespaceName()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onNamespaceNameAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
parentMessage.limit(limit + headerLength + dataLength);
if (0 == dataLength)
{
return "";
}
final byte[] tmp = new byte[dataLength];
buffer.getBytes(limit + headerLength, tmp, 0, dataLength);
return new String(tmp, java.nio.charset.StandardCharsets.UTF_8);
}
public static int semanticVersionId()
{
return 6;
}
public static int semanticVersionSinceVersion()
{
return 0;
}
public static String semanticVersionCharacterEncoding()
{
return java.nio.charset.StandardCharsets.UTF_8.name();
}
public static String semanticVersionMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public static int semanticVersionHeaderLength()
{
return 2;
}
void onSemanticVersionLengthAccessed()
{
switch (codecState())
{
case CodecStates.V0_NAMESPACENAME_DONE:
codecState(CodecStates.V0_NAMESPACENAME_DONE);
break;
default:
throw new IllegalStateException("Illegal field access order. " +
"Cannot decode length of var data \"semanticVersion\" in state: " + CodecStates.name(codecState()) +
". Expected one of these transitions: [" + CodecStates.transitions(codecState()) +
"]. Please see the diagram in the Javadoc of the class FrameCodecDecoder#CodecStates.");
}
}
private void onSemanticVersionAccessed()
{
switch (codecState())
{
case CodecStates.V0_NAMESPACENAME_DONE:
codecState(CodecStates.V0_SEMANTICVERSION_DONE);
break;
default:
throw new IllegalStateException("Illegal field access order. " +
"Cannot access field \"semanticVersion\" in state: " + CodecStates.name(codecState()) +
". Expected one of these transitions: [" + CodecStates.transitions(codecState()) +
"]. Please see the diagram in the Javadoc of the class FrameCodecDecoder#CodecStates.");
}
}
public int semanticVersionLength()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onSemanticVersionLengthAccessed();
}
final int limit = parentMessage.limit();
return (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
}
public int skipSemanticVersion()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onSemanticVersionAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
final int dataOffset = limit + headerLength;
parentMessage.limit(dataOffset + dataLength);
return dataLength;
}
public int getSemanticVersion(final MutableDirectBuffer dst, final int dstOffset, final int length)
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onSemanticVersionAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
final int bytesCopied = Math.min(length, dataLength);
parentMessage.limit(limit + headerLength + dataLength);
buffer.getBytes(limit + headerLength, dst, dstOffset, bytesCopied);
return bytesCopied;
}
public int getSemanticVersion(final byte[] dst, final int dstOffset, final int length)
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onSemanticVersionAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
final int bytesCopied = Math.min(length, dataLength);
parentMessage.limit(limit + headerLength + dataLength);
buffer.getBytes(limit + headerLength, dst, dstOffset, bytesCopied);
return bytesCopied;
}
public void wrapSemanticVersion(final DirectBuffer wrapBuffer)
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onSemanticVersionAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
parentMessage.limit(limit + headerLength + dataLength);
wrapBuffer.wrap(buffer, limit + headerLength, dataLength);
}
public String semanticVersion()
{
if (SBE_ENABLE_IR_PRECEDENCE_CHECKS)
{
onSemanticVersionAccessed();
}
final int headerLength = 2;
final int limit = parentMessage.limit();
final int dataLength = (buffer.getShort(limit, BYTE_ORDER) & 0xFFFF);
parentMessage.limit(limit + headerLength + dataLength);
if (0 == dataLength)
{
return "";
}
final byte[] tmp = new byte[dataLength];
buffer.getBytes(limit + headerLength, tmp, 0, dataLength);
return new String(tmp, java.nio.charset.StandardCharsets.UTF_8);
}
public String toString()
{
if (null == buffer)
{
return "";
}
final FrameCodecDecoder decoder = new FrameCodecDecoder();
decoder.wrap(buffer, offset, actingBlockLength, actingVersion);
return decoder.appendTo(new StringBuilder()).toString();
}
public StringBuilder appendTo(final StringBuilder builder)
{
if (null == buffer)
{
return builder;
}
final int originalLimit = limit();
limit(offset + actingBlockLength);
builder.append("[FrameCodec](sbeTemplateId=");
builder.append(TEMPLATE_ID);
builder.append("|sbeSchemaId=");
builder.append(SCHEMA_ID);
builder.append("|sbeSchemaVersion=");
if (parentMessage.actingVersion != SCHEMA_VERSION)
{
builder.append(parentMessage.actingVersion);
builder.append('/');
}
builder.append(SCHEMA_VERSION);
builder.append("|sbeBlockLength=");
if (actingBlockLength != BLOCK_LENGTH)
{
builder.append(actingBlockLength);
builder.append('/');
}
builder.append(BLOCK_LENGTH);
builder.append("):");
builder.append("irId=");
builder.append(this.irId());
builder.append('|');
builder.append("irVersion=");
builder.append(this.irVersion());
builder.append('|');
builder.append("schemaVersion=");
builder.append(this.schemaVersion());
builder.append('|');
builder.append("packageName=");
builder.append('\'').append(packageName()).append('\'');
builder.append('|');
builder.append("namespaceName=");
builder.append('\'').append(namespaceName()).append('\'');
builder.append('|');
builder.append("semanticVersion=");
builder.append('\'').append(semanticVersion()).append('\'');
limit(originalLimit);
return builder;
}
public FrameCodecDecoder sbeSkip()
{
sbeRewind();
skipPackageName();
skipNamespaceName();
skipSemanticVersion();
return this;
}
}