Java TypeCode Serialization/Deserialization

2 posts / 0 new
Last post
Offline
Last seen: 4 years 10 months ago
Joined: 08/03/2017
Posts: 13
Java TypeCode Serialization/Deserialization

I saw a few forum entries about TypeCode Serialization/Deserialization in Modern C++, but there doesn't seem to be similar functionality in Java. 

I am able to serialize TypeCodes using the following Java code:

TypeCode tc = layout.getTypeCode();

CdrOutputStream cos = new CdrOutputStream(new CdrBuffer(tc.get_serialized_size(0)));

tc.serialize(cos);

ArrayList<byte[]> binaryHolder = new ArrayList<byte[]>();
binaryHolder.add(cos.getBuffer().getBuffer());


But I seem to be unable to find a method to derserialize that same data into a TypeCode object. Anyone have any ideas? Thanks.

 

Offline
Last seen: 4 years 10 months ago
Joined: 08/03/2017
Posts: 13

After some lucky digging, I found this post that explains both serialization and deserialization:

https://research.rti.com/forum-topic/dynamic-discovery-and-type-codes

boolean needByteSwap = NativeInterface.getInstance().isNativeByteOrderLittleEndian();
CdrInputStream stream = new CdrInputStream(cos.getBuffer().getBuffer(), needByteSwap);
TypeCode typeCode = TypeCodeFactory.get_instance().create_tc_from_stream(stream);