Class AsciiStringSerializer

java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.serializers.AsciiStringSerializer
All Implemented Interfaces:
BabelNetworkSerializer<io.netty.util.AsciiString>

@AutoService(BabelNetworkSerializer.class) public class AsciiStringSerializer extends Object implements BabelNetworkSerializer<io.netty.util.AsciiString>
Binary serializer for Netty AsciiString instances.

Prefixed with a 4-byte integer length followed by the raw ASCII bytes.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new AsciiStringSerializer.
  • Method Summary

    Modifier and Type
    Method
    Description
    io.netty.util.AsciiString
    deserialize(io.netty.buffer.ByteBuf in, NodeStore store)
    Reads an instance of T from the supplied buffer.
    int
    getEstimateSize(io.netty.util.AsciiString object)
    Returns an estimated size in bytes for the given object.
    Class<io.netty.util.AsciiString>
    Returns the class of objects handled by this serializer, used for registry lookup.
    void
    serialize(io.netty.util.AsciiString object, io.netty.buffer.ByteBuf out, NodeStore store)
    Encodes object and appends the resulting bytes to out.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface BabelNetworkSerializer

    getEstimateSize
    Modifier and Type
    Method
    Description
    default int
    getEstimateSize(io.netty.util.AsciiString object, @Nullable NodeStore store)
    Returns a size estimate to fit the entire object in a ByteBuf without needing resizes.
  • Constructor Details

    • AsciiStringSerializer

      public AsciiStringSerializer()
      Constructs a new AsciiStringSerializer.
  • Method Details

    • deserialize

      public io.netty.util.AsciiString deserialize(io.netty.buffer.ByteBuf in, NodeStore store)
      Description copied from interface: BabelNetworkSerializer
      Reads an instance of T from 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:
      deserialize in interface BabelNetworkSerializer<io.netty.util.AsciiString>
      Parameters:
      in - the source buffer
      store - the node store context for resolving node components
      Returns:
      the deserialized object
    • serialize

      public void serialize(io.netty.util.AsciiString object, io.netty.buffer.ByteBuf out, NodeStore store)
      Description copied from interface: BabelNetworkSerializer
      Encodes object and appends the resulting bytes to out.
      Specified by:
      serialize in interface BabelNetworkSerializer<io.netty.util.AsciiString>
      Parameters:
      object - the object to serialize
      out - the destination buffer
      store - the node store context for resolving node components
    • getObjectClass

      public Class<io.netty.util.AsciiString> getObjectClass()
      Description copied from interface: BabelNetworkSerializer
      Returns the class of objects handled by this serializer, used for registry lookup.
      Specified by:
      getObjectClass in interface BabelNetworkSerializer<io.netty.util.AsciiString>
      Returns:
      the handled class
    • getEstimateSize

      public int getEstimateSize(io.netty.util.AsciiString object)
      Description copied from interface: BabelNetworkSerializer
      Returns an estimated size in bytes for the given object.
      Specified by:
      getEstimateSize in interface BabelNetworkSerializer<io.netty.util.AsciiString>
      Parameters:
      object - the object to estimate
      Returns:
      estimated byte size, or 0 if unknown