Package io.servicetalk.serializer.utils
Class StringSerializer
java.lang.Object
io.servicetalk.serializer.utils.StringSerializer
- All Implemented Interfaces:
Deserializer<String>
,Serializer<String>
,SerializerDeserializer<String>
-
Method Summary
Modifier and TypeMethodDescriptionfinal String
deserialize
(Buffer serializedData, BufferAllocator allocator) Deserialize the contents from theBuffer
parameter.final Buffer
serialize
(String toSerialize, BufferAllocator allocator) Serialize theSerializer
parameter to aBuffer
.void
serialize
(String toSerialize, BufferAllocator allocator, Buffer buffer) Serialize theSerializer
parameter to theBuffer
parameter.static SerializerDeserializer<String>
stringSerializer
(Charset charset) Create a new instance.
-
Method Details
-
stringSerializer
Create a new instance.- Parameters:
charset
- The charset used for encoding.- Returns:
- A serializer that uses
charset
for encoding.
-
deserialize
Description copied from interface:Deserializer
Deserialize the contents from theBuffer
parameter.The caller is responsible for assuming the buffer contents contains enough
Buffer.readableBytes()
to successfully deserialize.- Specified by:
deserialize
in interfaceDeserializer<String>
- Parameters:
serializedData
-Buffer
whoseBuffer.readableBytes()
contains a serialized object. TheBuffer.readerIndex()
will be advanced to indicate the content which has been consumed.allocator
- Used to allocate intermediateBuffer
s if required.- Returns:
- The result of the deserialization.
-
serialize
Description copied from interface:Serializer
Serialize theSerializer
parameter to aBuffer
.- Specified by:
serialize
in interfaceSerializer<String>
- Parameters:
toSerialize
- TheSerializer
to serialize.allocator
- Used to allocate the buffer to serialize to.- Returns:
- The results of the serialization.
-
serialize
Description copied from interface:Serializer
Serialize theSerializer
parameter to theBuffer
parameter.- Specified by:
serialize
in interfaceSerializer<String>
- Parameters:
toSerialize
- TheSerializer
to serialize.allocator
- Used to allocate intermediateBuffer
s if required.buffer
- Where the results of the serialization will be written to.
-