Class Serializer

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean DEFAULT_STRICT
      Default value for the "strict" serializer settings.
    • Constructor Summary

      Constructors 
      Constructor Description
      Serializer()  
    • Field Detail

      • DEFAULT_STRICT

        public static final boolean DEFAULT_STRICT
        Default value for the "strict" serializer settings.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Serializer

        public Serializer()
    • Method Detail

      • serialize

        public abstract <Message extends PMessage<Message,Field>,Field extends PField> int serialize​(@Nonnull
                                                                                                     java.io.OutputStream output,
                                                                                                     @Nonnull
                                                                                                     Message message)
                                                                                              throws java.io.IOException
        Serialize a message.
        Type Parameters:
        Message - The message type.
        Field - The message field type.
        Parameters:
        output - 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 abstract <Message extends PMessage<Message,Field>,Field extends PField> int serialize​(@Nonnull
                                                                                                     java.io.OutputStream output,
                                                                                                     @Nonnull
                                                                                                     PServiceCall<Message,Field> call)
                                                                                              throws java.io.IOException
        Serialize a service call.
        Type Parameters:
        Message - The message type contained in the service call.
        Field - The message field type.
        Parameters:
        output - 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 abstract <Message extends PMessage<Message,Field>,Field extends PField> Message deserialize​(@Nonnull
                                                                                                           java.io.InputStream input,
                                                                                                           @Nonnull
                                                                                                           PMessageDescriptor<Message,Field> descriptor)
                                                                                                    throws java.io.IOException
        Deserialize a message.
        Type Parameters:
        Message - The message type.
        Field - The message field type.
        Parameters:
        input - 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 abstract <Message extends PMessage<Message,Field>,Field extends PFieldPServiceCall<Message,Field> deserialize​(@Nonnull
                                                                                                                               java.io.InputStream input,
                                                                                                                               @Nonnull
                                                                                                                               PService service)
                                                                                                                        throws java.io.IOException
        Deserialize a service call.
        Type Parameters:
        Message - The message type contained in the returned service call.
        Field - The message field type.
        Parameters:
        input - The input stream to read from.
        service - The service definition to read for.
        Returns:
        The service call read.
        Throws:
        java.io.IOException - If reading or deserialization failed.
      • binaryProtocol

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

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

        protected boolean isRequestCallType​(PServiceCallType type)
        Utility method to check if a service call is a request type.
        Parameters:
        type - The service call type.
        Returns:
        If the service call is a request, and not a response.