Class Ser

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable

    final class Ser
    extends java.lang.Object
    implements java.io.Externalizable
    The shared serialization delegate for this package.

    Implementation notes

    This class wraps the object being serialized, and takes a byte representing the type of the class to be serialized. This byte can also be used for versioning the serialization format. In this case another byte flag would be used in order to specify an alternative version of the type format. For example JAPANESE_DATE_TYPE_VERSION_2 = 21.

    In order to serialise the object it writes its byte and then calls back to the appropriate class where the serialisation is performed. In order to deserialise the object it read in the type byte, switching in order to select which class to call back into.

    The serialisation format is determined on a per class basis. In the case of field based classes each of the fields is written out with an appropriate size format in descending order of the field's size. For example in the case of LocalDate year is written before month. Composite classes, such as LocalDateTime are serialised as one object.

    This class is mutable and should be created once per serialization.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Ser()
      Constructor for deserialization.
      Ser​(byte type, java.lang.Object object)
      Creates an instance for serialization.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static java.lang.Object read​(java.io.ObjectInput in)  
      void readExternal​(java.io.ObjectInput in)
      Implements the Externalizable interface to read the object.
      private static java.lang.Object readInternal​(byte type, java.io.ObjectInput in)  
      private java.lang.Object readResolve()
      Returns the object that will replace this one.
      void writeExternal​(java.io.ObjectOutput out)
      Implements the Externalizable interface to write the object.
      private static void writeInternal​(byte type, java.lang.Object object, java.io.ObjectOutput out)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Ser

        public Ser()
        Constructor for deserialization.
      • Ser

        Ser​(byte type,
            java.lang.Object object)
        Creates an instance for serialization.
        Parameters:
        type - the type
        object - the object
    • Method Detail

      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Implements the Externalizable interface to write the object.
        Specified by:
        writeExternal in interface java.io.Externalizable
        Parameters:
        out - the data stream to write to, not null
        Throws:
        java.io.IOException
      • writeInternal

        private static void writeInternal​(byte type,
                                          java.lang.Object object,
                                          java.io.ObjectOutput out)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Implements the Externalizable interface to read the object.
        Specified by:
        readExternal in interface java.io.Externalizable
        Parameters:
        in - the data to read, not null
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • read

        static java.lang.Object read​(java.io.ObjectInput in)
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • readInternal

        private static java.lang.Object readInternal​(byte type,
                                                     java.io.ObjectInput in)
                                              throws java.io.IOException,
                                                     java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • readResolve

        private java.lang.Object readResolve()
        Returns the object that will replace this one.
        Returns:
        the read object, should never be null