Class JavaSerializationMarshaller

  • All Implemented Interfaces:
    Marshaller

    public class JavaSerializationMarshaller
    extends AbstractMarshaller
    Standard Java serialization marshaller.
    Since:
    5.3
    Author:
    Galder ZamarreƱo
    • Constructor Detail

      • JavaSerializationMarshaller

        public JavaSerializationMarshaller()
      • JavaSerializationMarshaller

        public JavaSerializationMarshaller​(ClassWhiteList whiteList)
    • Method Detail

      • objectToBuffer

        protected ByteBuffer objectToBuffer​(java.lang.Object o,
                                            int estimatedSize)
                                     throws java.io.IOException
        Description copied from class: AbstractMarshaller
        This is a convenience method for converting an object into a ByteBuffer which takes an estimated size as parameter. A ByteBuffer allows direct access to the byte array with minimal array copying
        Specified by:
        objectToBuffer in class AbstractMarshaller
        Parameters:
        o - object to marshall
        estimatedSize - an estimate of how large the resulting byte array may be
        Throws:
        java.io.IOException
      • objectFromByteBuffer

        public java.lang.Object objectFromByteBuffer​(byte[] buf,
                                                     int offset,
                                                     int length)
                                              throws java.io.IOException,
                                                     java.lang.ClassNotFoundException
        Description copied from interface: Marshaller
        Unmarshalls an object from a specific portion of a byte array.
        Parameters:
        buf - byte array containing the binary representation of an object. Must not be null.
        offset - point in buffer to start reading
        length - number of bytes to consider
        Returns:
        an object
        Throws:
        java.io.IOException - if unmarshalling cannot complete due to some I/O error
        java.lang.ClassNotFoundException - if the class of the object trying to unmarshall is unknown
      • isMarshallable

        public boolean isMarshallable​(java.lang.Object o)
                               throws java.lang.Exception
        Description copied from interface: Marshaller
        A method that checks whether the given object is marshallable as per the rules of this marshaller.
        Parameters:
        o - object to verify whether it's marshallable or not
        Returns:
        true if the object is marshallable, otherwise false
        Throws:
        java.lang.Exception - if while checking whether the object was serializable or not, an exception arose
      • mediaType

        public MediaType mediaType()
        Returns:
        the MediaType associated with the content produced by the marshaller