Skip to content

Commit 49ab801

Browse files
fixup the compiling code
1 parent 28bf522 commit 49ab801

File tree

7 files changed

+30
-21
lines changed

7 files changed

+30
-21
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
import baseline.OptionalExtras;
2323
import baseline.MetaAttribute;
2424
import baseline.MessageHeader;
25+
26+
import uk.co.real_logic.agrona.MutableDirectBuffer;
27+
import uk.co.real_logic.agrona.concurrent.UnsafeBuffer;
2528
import uk.co.real_logic.sbe.codec.java.DirectBuffer;
2629

2730
import java.io.FileOutputStream;
@@ -60,7 +63,7 @@ public static void main(final String[] args) throws Exception
6063
System.out.println("\n*** Basic Stub Example ***");
6164

6265
final ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4096);
63-
final DirectBuffer directBuffer = new DirectBuffer(byteBuffer);
66+
final MutableDirectBuffer directBuffer = new UnsafeBuffer(byteBuffer);
6467
final short messageTemplateVersion = 0;
6568
int bufferOffset = 0;
6669
int encodingLength = 0;
@@ -109,7 +112,7 @@ public static void main(final String[] args) throws Exception
109112
decode(CAR, directBuffer, bufferOffset, actingBlockLength, schemaId, actingVersion);
110113
}
111114

112-
public static int encode(final Car car, final DirectBuffer directBuffer, final int bufferOffset)
115+
public static int encode(final Car car, final MutableDirectBuffer directBuffer, final int bufferOffset)
113116
{
114117
final int srcOffset = 0;
115118

@@ -163,7 +166,7 @@ public static int encode(final Car car, final DirectBuffer directBuffer, final i
163166

164167
public static void decode(
165168
final Car car,
166-
final DirectBuffer directBuffer,
169+
final MutableDirectBuffer directBuffer,
167170
final int bufferOffset,
168171
final int actingBlockLength,
169172
final int schemaId,

main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package uk.co.real_logic.sbe.generation.java;
1717

18-
import uk.co.real_logic.agrona.DirectBuffer;
1918
import uk.co.real_logic.agrona.MutableDirectBuffer;
2019
import uk.co.real_logic.sbe.PrimitiveType;
2120
import uk.co.real_logic.sbe.generation.CodeGenerator;
@@ -63,10 +62,10 @@ private String validateBufferImplementation(final String fullyQualifiedBufferImp
6362
try
6463
{
6564
final Class<?> cls = Class.forName(fullyQualifiedBufferImplementation);
66-
if (!cls.isAssignableFrom(MutableDirectBuffer.class))
65+
if (!MutableDirectBuffer.class.isAssignableFrom(cls))
6766
{
6867
throw new IllegalArgumentException(
69-
fullyQualifiedBufferImplementation + " doesn't implement " + DirectBuffer.class.getName());
68+
fullyQualifiedBufferImplementation + " doesn't implement " + MutableDirectBuffer.class.getName());
7069
}
7170
return cls.getSimpleName();
7271
}

main/java/uk/co/real_logic/sbe/ir/generated/FrameCodec.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* Generated SBE (Simple Binary Encoding) message codec */
22
package uk.co.real_logic.sbe.ir.generated;
33

4-
import uk.co.real_logic.sbe.codec.java.*;
4+
import uk.co.real_logic.sbe.codec.java.CodecUtil;
5+
6+
import uk.co.real_logic.agrona.MutableDirectBuffer;
57

68
public class FrameCodec
79
{
@@ -11,7 +13,7 @@ public class FrameCodec
1113
public static final int SCHEMA_VERSION = 0;
1214

1315
private final FrameCodec parentMessage = this;
14-
private DirectBuffer buffer;
16+
private MutableDirectBuffer buffer;
1517
private int offset;
1618
private int limit;
1719
private int actingBlockLength;
@@ -47,7 +49,7 @@ public int offset()
4749
return offset;
4850
}
4951

50-
public FrameCodec wrapForEncode(final DirectBuffer buffer, final int offset)
52+
public FrameCodec wrapForEncode(final MutableDirectBuffer buffer, final int offset)
5153
{
5254
this.buffer = buffer;
5355
this.offset = offset;
@@ -59,7 +61,7 @@ public FrameCodec wrapForEncode(final DirectBuffer buffer, final int offset)
5961
}
6062

6163
public FrameCodec wrapForDecode(
62-
final DirectBuffer buffer, final int offset, final int actingBlockLength, final int actingVersion)
64+
final MutableDirectBuffer buffer, final int offset, final int actingBlockLength, final int actingVersion)
6365
{
6466
this.buffer = buffer;
6567
this.offset = offset;

main/java/uk/co/real_logic/sbe/ir/generated/MessageHeader.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/* Generated SBE (Simple Binary Encoding) message codec */
22
package uk.co.real_logic.sbe.ir.generated;
33

4-
import uk.co.real_logic.sbe.codec.java.*;
4+
import uk.co.real_logic.agrona.MutableDirectBuffer;
5+
import uk.co.real_logic.sbe.codec.java.CodecUtil;
56

67
public class MessageHeader
78
{
8-
private DirectBuffer buffer;
9+
private MutableDirectBuffer buffer;
910
private int offset;
1011
private int actingVersion;
1112

12-
public MessageHeader wrap(final DirectBuffer buffer, final int offset, final int actingVersion)
13+
public MessageHeader wrap(final MutableDirectBuffer buffer, final int offset, final int actingVersion)
1314
{
1415
this.buffer = buffer;
1516
this.offset = offset;

main/java/uk/co/real_logic/sbe/ir/generated/TokenCodec.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* Generated SBE (Simple Binary Encoding) message codec */
22
package uk.co.real_logic.sbe.ir.generated;
33

4-
import uk.co.real_logic.sbe.codec.java.*;
4+
import uk.co.real_logic.agrona.MutableDirectBuffer;
5+
import uk.co.real_logic.sbe.codec.java.CodecUtil;
56

67
public class TokenCodec
78
{
@@ -11,7 +12,7 @@ public class TokenCodec
1112
public static final int SCHEMA_VERSION = 0;
1213

1314
private final TokenCodec parentMessage = this;
14-
private DirectBuffer buffer;
15+
private MutableDirectBuffer buffer;
1516
private int offset;
1617
private int limit;
1718
private int actingBlockLength;
@@ -47,7 +48,7 @@ public int offset()
4748
return offset;
4849
}
4950

50-
public TokenCodec wrapForEncode(final DirectBuffer buffer, final int offset)
51+
public TokenCodec wrapForEncode(final MutableDirectBuffer buffer, final int offset)
5152
{
5253
this.buffer = buffer;
5354
this.offset = offset;
@@ -59,7 +60,7 @@ public TokenCodec wrapForEncode(final DirectBuffer buffer, final int offset)
5960
}
6061

6162
public TokenCodec wrapForDecode(
62-
final DirectBuffer buffer, final int offset, final int actingBlockLength, final int actingVersion)
63+
final MutableDirectBuffer buffer, final int offset, final int actingBlockLength, final int actingVersion)
6364
{
6465
this.buffer = buffer;
6566
this.offset = offset;

main/java/uk/co/real_logic/sbe/ir/generated/VarDataEncoding.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/* Generated SBE (Simple Binary Encoding) message codec */
22
package uk.co.real_logic.sbe.ir.generated;
33

4-
import uk.co.real_logic.sbe.codec.java.*;
4+
import uk.co.real_logic.agrona.MutableDirectBuffer;
5+
import uk.co.real_logic.sbe.codec.java.CodecUtil;
56

67
public class VarDataEncoding
78
{
8-
private DirectBuffer buffer;
9+
private MutableDirectBuffer buffer;
910
private int offset;
1011
private int actingVersion;
1112

12-
public VarDataEncoding wrap(final DirectBuffer buffer, final int offset, final int actingVersion)
13+
public VarDataEncoding wrap(final MutableDirectBuffer buffer, final int offset, final int actingVersion)
1314
{
1415
this.buffer = buffer;
1516
this.offset = offset;

test/java/uk/co/real_logic/sbe/codec/java/CodecUtilTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package uk.co.real_logic.sbe.codec.java;
1717

1818
import org.junit.Test;
19+
import uk.co.real_logic.agrona.MutableDirectBuffer;
20+
import uk.co.real_logic.agrona.concurrent.UnsafeBuffer;
1921

2022
import java.nio.ByteOrder;
2123

@@ -29,7 +31,7 @@ public class CodecUtilTest
2931
private static final ByteOrder BYTE_ORDER = ByteOrder.nativeOrder();
3032
private static final int BUFFER_CAPACITY = 64;
3133

32-
private final DirectBuffer buffer = new DirectBuffer(new byte[BUFFER_CAPACITY]);
34+
private final MutableDirectBuffer buffer = new UnsafeBuffer(new byte[BUFFER_CAPACITY]);
3335

3436
@Test
3537
public void shouldTestBitInByte()

0 commit comments

Comments
 (0)