Class FastBinarySerializer


  • @Beta
    public class FastBinarySerializer
    extends Serializer
    Compact binary serializer. This uses a pretty compact binary format while being optimized for fewer operations during read and write.

    Documentation: Fast Binary Serialization Format with IDL and explanation.

    • Constructor Detail

      • FastBinarySerializer

        public FastBinarySerializer()
        Construct a serializer instance.
      • FastBinarySerializer

        public FastBinarySerializer​(boolean readStrict)
        Construct a serializer instance.
        Parameters:
        readStrict - If serializer should fail on unknown input data.
    • Method Detail

      • serialize

        public <Message extends PMessage<Message,Field>,Field extends PField> int serialize​(@Nonnull
                                                                                            java.io.OutputStream os,
                                                                                            @Nonnull
                                                                                            Message message)
                                                                                     throws java.io.IOException
        Description copied from class: Serializer
        Serialize a message.
        Specified by:
        serialize in class Serializer
        Type Parameters:
        Message - The message type.
        Field - The message field type.
        Parameters:
        os - The output stream to write to.
        message - The message to write.
        Returns:
        The number of bytes written to the output stream.
        Throws:
        java.io.IOException - If writing or serialization failed.
      • serialize

        public <Message extends PMessage<Message,Field>,Field extends PField> int serialize​(@Nonnull
                                                                                            java.io.OutputStream os,
                                                                                            @Nonnull
                                                                                            PServiceCall<Message,Field> call)
                                                                                     throws java.io.IOException
        Description copied from class: Serializer
        Serialize a service call.
        Specified by:
        serialize in class Serializer
        Type Parameters:
        Message - The message type contained in the service call.
        Field - The message field type.
        Parameters:
        os - The output stream to write to.
        call - The service call to write.
        Returns:
        The number of bytes written to the output stream.
        Throws:
        java.io.IOException - If writing or serialization failed.
      • deserialize

        @Nonnull
        public <Message extends PMessage<Message,Field>,Field extends PField> Message deserialize​(@Nonnull
                                                                                                  java.io.InputStream is,
                                                                                                  @Nonnull
                                                                                                  PMessageDescriptor<Message,Field> descriptor)
                                                                                           throws java.io.IOException
        Description copied from class: Serializer
        Deserialize a message.
        Specified by:
        deserialize in class Serializer
        Type Parameters:
        Message - The message type.
        Field - The message field type.
        Parameters:
        is - The input stream to read from.
        descriptor - The descriptor of the message to read.
        Returns:
        The message read.
        Throws:
        java.io.IOException - If reading or deserialization failed.
      • deserialize

        @Nonnull
        public <Message extends PMessage<Message,Field>,Field extends PFieldPServiceCall<Message,Field> deserialize​(@Nonnull
                                                                                                                      java.io.InputStream is,
                                                                                                                      @Nonnull
                                                                                                                      PService service)
                                                                                                               throws SerializerException
        Description copied from class: Serializer
        Deserialize a service call.
        Specified by:
        deserialize in class Serializer
        Type Parameters:
        Message - The message type contained in the returned service call.
        Field - The message field type.
        Parameters:
        is - The input stream to read from.
        service - The service definition to read for.
        Returns:
        The service call read.
        Throws:
        SerializerException
      • binaryProtocol

        public boolean binaryProtocol()
        Specified by:
        binaryProtocol in class Serializer
        Returns:
        True if the protocol of the serializer is "binary" a.k.a. unreadable to most humans.
      • mediaType

        @Nonnull
        public java.lang.String mediaType()
        Specified by:
        mediaType in class Serializer
        Returns:
        Media type of the content generated by the serializer. Can be used for Content-Type and Accept HTTP headers, MIME type etc.