Class AbstractMarshaller

    • Constructor Detail

      • AbstractMarshaller

        public AbstractMarshaller()
    • Method Detail

      • getBufferSizePredictor

        public BufferSizePredictor getBufferSizePredictor​(Object o)
        Description copied from interface: Marshaller
        Returns a marshalled payload size predictor for a particular type. Accurate prediction of a type's serialized payload size helps avoid unnecessary copying and speeds up application performance.
        Specified by:
        getBufferSizePredictor in interface Marshaller
        Parameters:
        o - Object for which serialized predictor will be returned
        Returns:
        an instance of BufferSizePredictor
      • objectToBuffer

        public ByteBuffer objectToBuffer​(Object obj)
                                  throws IOException,
                                         InterruptedException
        Description copied from interface: Marshaller
        A method that returns an instance of ByteBuffer, which allows direct access to the byte array with minimal array copying
        Specified by:
        objectToBuffer in interface Marshaller
        Parameters:
        obj - object to marshall
        Throws:
        IOException - if marshalling cannot complete due to some I/O error
        InterruptedException - if the marshalling process was interrupted. Clients should take this as a sign that the marshaller is no longer available, maybe due to shutdown, and so no more marshalling should be attempted.
      • objectToByteBuffer

        public byte[] objectToByteBuffer​(Object o)
                                  throws IOException,
                                         InterruptedException
        Description copied from interface: Marshaller
        Marshalls an object to a byte array.
        Specified by:
        objectToByteBuffer in interface Marshaller
        Parameters:
        o - object to convert to a byte array. Must not be null.
        Returns:
        a byte array
        Throws:
        IOException - if marshalling cannot complete due to some I/O error
        InterruptedException - if the marshalling process was interrupted. Clients should take this as a sign that the marshaller is no longer available, maybe due to shutdown, and so no more marshalling should be attempted.
      • objectToByteBuffer

        public byte[] objectToByteBuffer​(Object obj,
                                         int estimatedSize)
                                  throws IOException,
                                         InterruptedException
        Description copied from interface: Marshaller
        Marshalls an object to a byte array. The estimatedSize parameter is a hint that can be passed in to allow for efficient sizing of the byte array before attempting to marshall the object. The more accurate this estimate is, the less likely byte[]s will need to be resized to hold the byte stream generated by marshalling the object.
        Specified by:
        objectToByteBuffer in interface Marshaller
        Parameters:
        obj - object to convert to a byte array. Must not be null.
        estimatedSize - an estimate of how large the resulting byte array may be
        Returns:
        a byte array with the marshalled form of the object
        Throws:
        IOException - if marshalling cannot complete due to some I/O error
        InterruptedException - if the marshalling was interrupted. Clients should take this as a sign that the marshaller is no longer available, maybe due to shutdown, and so no more unmarshalling should be attempted.