Class SerializablePortability

  • All Implemented Interfaces:
    Portability<java.io.Serializable>
    Direct Known Subclasses:
    PersistentSerializablePortability

    public class SerializablePortability
    extends java.lang.Object
    implements Portability<java.io.Serializable>
    A trivially compressed Java serialization based portability.

    Class descriptors in the resultant bytes are encoded as integers. Mappings between the integer representation and the ObjectStreamClass, and the Class and the integer representation are stored in a single on-heap map.

    • Field Detail

      • nextStreamIndex

        protected int nextStreamIndex
      • lookup

        protected final java.util.concurrent.ConcurrentMap<java.lang.Object,​java.lang.Object> lookup
      • loader

        private final java.lang.ClassLoader loader
    • Constructor Detail

      • SerializablePortability

        public SerializablePortability()
      • SerializablePortability

        public SerializablePortability​(java.lang.ClassLoader loader)
    • Method Detail

      • encode

        public java.nio.ByteBuffer encode​(java.io.Serializable object)
        Description copied from interface: Portability
        Encodes an object of type T as a ByteBuffer.
        Specified by:
        encode in interface Portability<java.io.Serializable>
        Parameters:
        object - object to be encoded
        Returns:
        the encoded object
      • decode

        public java.io.Serializable decode​(java.nio.ByteBuffer buffer)
        Description copied from interface: Portability
        Decodes a ByteBuffer to an object of type T.
        Specified by:
        decode in interface Portability<java.io.Serializable>
        Parameters:
        buffer - bytes to decode
        Returns:
        the decoded object
      • getObjectOutputStream

        public java.io.ObjectOutputStream getObjectOutputStream​(java.io.OutputStream out)
                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • getObjectInputStream

        public java.io.ObjectInputStream getObjectInputStream​(java.io.InputStream input)
                                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • equals

        public boolean equals​(java.lang.Object value,
                              java.nio.ByteBuffer readBuffer)
        Description copied from interface: Portability
        Returns true if the encoded object once decoded would be Object.equals(Object) to the supplied object.
        Specified by:
        equals in interface Portability<java.io.Serializable>
        Parameters:
        value - object to compare to
        readBuffer - buffer containing encoded object
        Returns:
        true if the two parameters are "equal"
      • getOrAddMapping

        protected int getOrAddMapping​(java.io.ObjectStreamClass desc)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • addedMapping

        protected void addedMapping​(java.lang.Integer rep,
                                    java.io.ObjectStreamClass disconnected)
      • equals

        private static boolean equals​(java.io.ObjectStreamClass osc1,
                                      java.io.ObjectStreamClass osc2)
      • disconnect

        protected static java.io.ObjectStreamClass disconnect​(java.io.ObjectStreamClass desc)
      • getSerializedForm

        private static byte[] getSerializedForm​(java.io.ObjectStreamClass desc)
                                         throws java.io.IOException
        Throws:
        java.io.IOException