src/java.base/share/classes/java/time/zone/Ser.java
changeset 58362 628c12967b02
parent 57544 99d2dd7b84a8
child 58679 9c3209ff7550
equal deleted inserted replaced
58361:ad863044567e 58362:628c12967b02
    66 import java.io.Externalizable;
    66 import java.io.Externalizable;
    67 import java.io.IOException;
    67 import java.io.IOException;
    68 import java.io.InvalidClassException;
    68 import java.io.InvalidClassException;
    69 import java.io.ObjectInput;
    69 import java.io.ObjectInput;
    70 import java.io.ObjectOutput;
    70 import java.io.ObjectOutput;
       
    71 import java.io.Serializable;
    71 import java.io.StreamCorruptedException;
    72 import java.io.StreamCorruptedException;
    72 import java.time.ZoneOffset;
    73 import java.time.ZoneOffset;
    73 
    74 
    74 /**
    75 /**
    75  * The shared serialization delegate for this package.
    76  * The shared serialization delegate for this package.
    95     static final byte ZOTRULE = 3;
    96     static final byte ZOTRULE = 3;
    96 
    97 
    97     /** The type being serialized. */
    98     /** The type being serialized. */
    98     private byte type;
    99     private byte type;
    99     /** The object being serialized. */
   100     /** The object being serialized. */
   100     private Object object;
   101     private Serializable object;
   101 
   102 
   102     /**
   103     /**
   103      * Constructor for deserialization.
   104      * Constructor for deserialization.
   104      */
   105      */
   105     public Ser() {
   106     public Ser() {
   109      * Creates an instance for serialization.
   110      * Creates an instance for serialization.
   110      *
   111      *
   111      * @param type  the type
   112      * @param type  the type
   112      * @param object  the object
   113      * @param object  the object
   113      */
   114      */
   114     Ser(byte type, Object object) {
   115     Ser(byte type, Serializable object) {
   115         this.type = type;
   116         this.type = type;
   116         this.object = object;
   117         this.object = object;
   117     }
   118     }
   118 
   119 
   119     //-----------------------------------------------------------------------
   120     //-----------------------------------------------------------------------
   181     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   182     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   182         type = in.readByte();
   183         type = in.readByte();
   183         object = readInternal(type, in);
   184         object = readInternal(type, in);
   184     }
   185     }
   185 
   186 
   186     static Object read(DataInput in) throws IOException, ClassNotFoundException {
   187     static Serializable read(DataInput in) throws IOException, ClassNotFoundException {
   187         byte type = in.readByte();
   188         byte type = in.readByte();
   188         return readInternal(type, in);
   189         return readInternal(type, in);
   189     }
   190     }
   190 
   191 
   191     private static Object readInternal(byte type, DataInput in) throws IOException, ClassNotFoundException {
   192     private static Serializable readInternal(byte type, DataInput in)
       
   193             throws IOException, ClassNotFoundException {
   192         switch (type) {
   194         switch (type) {
   193             case ZRULES:
   195             case ZRULES:
   194                 return ZoneRules.readExternal(in);
   196                 return ZoneRules.readExternal(in);
   195             case ZOT:
   197             case ZOT:
   196                 return ZoneOffsetTransition.readExternal(in);
   198                 return ZoneOffsetTransition.readExternal(in);