Class StringSerializer
java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.serializers.StringSerializer
- All Implemented Interfaces:
BabelNetworkSerializer<String>
@AutoService(BabelNetworkSerializer.class)
public class StringSerializer
extends Object
implements BabelNetworkSerializer<String>
Binary serializer for UTF-8 encoded
String values.
Prefixed with a 4-byte integer length followed by the raw UTF-8 bytes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(io.netty.buffer.ByteBuf in, NodeStore store) Reads an instance ofTfrom the supplied buffer.intgetEstimateSize(String object) Returns an estimated size in bytes for the given object.Returns the class of objects handled by this serializer, used for registry lookup.voidEncodesobjectand appends the resulting bytes toout.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BabelNetworkSerializer
getEstimateSizeModifier and TypeMethodDescriptiondefault intgetEstimateSize(String object, @Nullable NodeStore store) Returns a size estimate to fit the entire object in aByteBufwithout needing resizes.
-
Constructor Details
-
StringSerializer
public StringSerializer()Constructs a newStringSerializer.
-
-
Method Details
-
deserialize
Description copied from interface:BabelNetworkSerializerReads an instance ofTfrom the supplied buffer. The buffer's reader index must be positioned at the first byte of the encoded object. Upon return the reader index is advanced past all bytes consumed.- Specified by:
deserializein interfaceBabelNetworkSerializer<String>- Parameters:
in- the source bufferstore- the node store context for resolving node components- Returns:
- the deserialized object
-
serialize
Description copied from interface:BabelNetworkSerializerEncodesobjectand appends the resulting bytes toout.- Specified by:
serializein interfaceBabelNetworkSerializer<String>- Parameters:
object- the object to serializeout- the destination bufferstore- the node store context for resolving node components
-
getObjectClass
Description copied from interface:BabelNetworkSerializerReturns the class of objects handled by this serializer, used for registry lookup.- Specified by:
getObjectClassin interfaceBabelNetworkSerializer<String>- Returns:
- the handled class
-
getEstimateSize
Description copied from interface:BabelNetworkSerializerReturns an estimated size in bytes for the given object.- Specified by:
getEstimateSizein interfaceBabelNetworkSerializer<String>- Parameters:
object- the object to estimate- Returns:
- estimated byte size, or 0 if unknown
-