Class SerializingCloner

  • All Implemented Interfaces:
    ObjectCloner

    class SerializingCloner
    extends java.lang.Object
    implements ObjectCloner
    An object cloner which uses serialization methods to clone objects.
    • Field Detail

      • bufferSize

        private final int bufferSize
      • clones

        private final java.util.IdentityHashMap<java.lang.Object,​java.lang.Object> clones
      • UNCLONED

        private static final java.util.Set<java.lang.Class<?>> UNCLONED
      • PRIMITIVE_ARRAYS

        private static final IdentityIntMap<java.lang.Class<?>> PRIMITIVE_ARRAYS
      • proxyInvocationHandler

        private static final java.lang.reflect.Field proxyInvocationHandler
    • Constructor Detail

      • SerializingCloner

        SerializingCloner​(ClonerConfiguration configuration)
        Create a new instance.
        Parameters:
        configuration - the configuration to use
    • Method Detail

      • reset

        public void reset()
        Description copied from interface: ObjectCloner
        Clear the cloner state and any caches.
        Specified by:
        reset in interface ObjectCloner
      • clone

        public java.lang.Object clone​(java.lang.Object orig)
                               throws java.io.IOException,
                                      java.lang.ClassNotFoundException
        Description copied from interface: ObjectCloner
        Create a deep clone of the given object.
        Specified by:
        clone in interface ObjectCloner
        Parameters:
        orig - the original object
        Returns:
        the deep clone
        Throws:
        java.io.IOException - if a serialization error occurs
        java.lang.ClassNotFoundException - if a class cannot be loaded during the cloning process
      • clone

        private java.lang.Object clone​(java.lang.Object orig,
                                       boolean replace)
                                throws java.io.IOException,
                                       java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • initSerializableClone

        private void initSerializableClone​(java.lang.Object orig,
                                           SerializableClass origInfo,
                                           java.lang.Object clone,
                                           SerializableClass cloneInfo)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • prepareFields

        private void prepareFields​(java.lang.Object subject,
                                   SerializingCloner.ClonerPutField fields)
                            throws java.io.InvalidObjectException
        Throws:
        java.io.InvalidObjectException
      • cloneFields

        private void cloneFields​(SerializingCloner.ClonerPutField fields)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • simpleClone

        private static java.lang.Object simpleClone​(java.lang.Object orig,
                                                    java.lang.Class<?> objClass)
      • getInvocationHandler

        private static java.lang.reflect.InvocationHandler getInvocationHandler​(java.lang.Object orig)