Class SerializationUtils


  • public final class SerializationUtils
    extends Object
    Static utility to help with serialization.
    Author:
    Dave Syer, Gary Russell
    • Method Detail

      • serialize

        public static byte[] serialize​(Object object)
        Serialize the object provided.
        Parameters:
        object - the object to serialize
        Returns:
        an array of bytes representing the object in a portable fashion
      • deserialize

        public static Object deserialize​(byte[] bytes)
        Deserialize the bytes.
        Parameters:
        bytes - a serialized object created
        Returns:
        the result of deserializing the bytes
      • deserialize

        public static Object deserialize​(ObjectInputStream stream)
        Deserialize the stream.
        Parameters:
        stream - an object stream created from a serialized object
        Returns:
        the result of deserializing the bytes
      • deserialize

        public static Object deserialize​(InputStream inputStream,
                                         Set<String> allowedListPatterns,
                                         ClassLoader classLoader)
                                  throws IOException
        Deserialize the stream.
        Parameters:
        inputStream - the stream.
        allowedListPatterns - allowed classes.
        classLoader - the class loader.
        Returns:
        the result.
        Throws:
        IOException - IO Exception.
        Since:
        2.1
      • checkAllowedList

        public static void checkAllowedList​(Class<?> clazz,
                                            Set<String> patterns)
        Verify that the class is in the allowed list.
        Parameters:
        clazz - the class.
        patterns - the patterns.
        Since:
        2.1