Interface Marshaller


  • public interface Marshaller
    Performs serialization and de-serialization of RPC call arguments and return values (including exceptions)
    Since:
    2.x, 4.0
    Author:
    Bela Ban
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default int estimatedSize​(java.lang.Object arg)
      Estimates the number of bytes needed to serialize an object to an output stream.
      java.lang.Object objectFromStream​(java.io.DataInput in)
      Creates an object from a stream
      void objectToStream​(java.lang.Object obj, java.io.DataOutput out)
      Serializes an object to an output stream
    • Method Detail

      • estimatedSize

        default int estimatedSize​(java.lang.Object arg)
        Estimates the number of bytes needed to serialize an object to an output stream. This is used to create an output stream with an initial capacity, so it does not need to be exact. However, if the estimated size is much smaller than the actual size needed by the arguments, the output stream's buffer will have to be copied, possibly multiple times.
        Parameters:
        arg - the object; argument to an RPC, or return value (could also be an exception). May be null (e.g. an RPC returning void)
        Returns:
        the estimated size
      • objectToStream

        void objectToStream​(java.lang.Object obj,
                            java.io.DataOutput out)
                     throws java.io.IOException
        Serializes an object to an output stream
        Parameters:
        obj - the object to be serialized
        out - the output stream, created taking estimatedSize(Object) into account
        Throws:
        java.io.IOException - thrown if serialization failed
      • objectFromStream

        java.lang.Object objectFromStream​(java.io.DataInput in)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException
        Creates an object from a stream
        Parameters:
        in - the input stream
        Returns:
        an object read from the input stream
        Throws:
        java.io.IOException - thrown if deserialization failed
        java.lang.ClassNotFoundException - if a requisite class was not found