77 * In order to serialize the object it writes its byte and then calls back to the appropriate class where
78 * the serialization is performed. In order to deserialize the object it read in the type byte, switching
79 * in order to select which class to call back into.
80 * <p>
81 * The serialization format is determined on a per class basis. In the case of field based classes each
82 * of the fields is written out with an appropriate size format in descending order of the field's size. For
83 * example in the case of {@link LocalDate} year is written before month. Composite classes, such as
84 * {@link LocalDateTime} are serialized as one object. Enum classes are serialized using the index of their
85 * element.
86 * <p>
87 * This class is mutable and should be created once per serialization.
88 *
89 * @serial include
90 * @since 1.8
91 */
92 final class Ser implements Externalizable {
93
94 /**
95 * Serialization version.
96 */
97 private static final long serialVersionUID = -6103370247208168577L;
98
99 static final byte CHRONO_TYPE = 1;
100 static final byte CHRONO_LOCAL_DATE_TIME_TYPE = 2;
101 static final byte CHRONO_ZONE_DATE_TIME_TYPE = 3;
102 static final byte JAPANESE_DATE_TYPE = 4;
103 static final byte JAPANESE_ERA_TYPE = 5;
104 static final byte HIJRAH_DATE_TYPE = 6;
105 static final byte MINGUO_DATE_TYPE = 7;
106 static final byte THAIBUDDHIST_DATE_TYPE = 8;
107 static final byte CHRONO_PERIOD_TYPE = 9;
108
109 /** The type being serialized. */
110 private byte type;
111 /** The object being serialized. */
112 private Object object;
113
114 /**
115 * Constructor for deserialization.
116 */
232 private static Object readInternal(byte type, ObjectInput in) throws IOException, ClassNotFoundException {
233 switch (type) {
234 case CHRONO_TYPE: return AbstractChronology.readExternal(in);
235 case CHRONO_LOCAL_DATE_TIME_TYPE: return ChronoLocalDateTimeImpl.readExternal(in);
236 case CHRONO_ZONE_DATE_TIME_TYPE: return ChronoZonedDateTimeImpl.readExternal(in);
237 case JAPANESE_DATE_TYPE: return JapaneseDate.readExternal(in);
238 case JAPANESE_ERA_TYPE: return JapaneseEra.readExternal(in);
239 case HIJRAH_DATE_TYPE: return HijrahDate.readExternal(in);
240 case MINGUO_DATE_TYPE: return MinguoDate.readExternal(in);
241 case THAIBUDDHIST_DATE_TYPE: return ThaiBuddhistDate.readExternal(in);
242 case CHRONO_PERIOD_TYPE: return ChronoPeriodImpl.readExternal(in);
243 default: throw new StreamCorruptedException("Unknown serialized type");
244 }
245 }
246
247 /**
248 * Returns the object that will replace this one.
249 *
250 * @return the read object, should never be null
251 */
252 private Object readResolve() {
253 return object;
254 }
255
256 }
|
77 * In order to serialize the object it writes its byte and then calls back to the appropriate class where
78 * the serialization is performed. In order to deserialize the object it read in the type byte, switching
79 * in order to select which class to call back into.
80 * <p>
81 * The serialization format is determined on a per class basis. In the case of field based classes each
82 * of the fields is written out with an appropriate size format in descending order of the field's size. For
83 * example in the case of {@link LocalDate} year is written before month. Composite classes, such as
84 * {@link LocalDateTime} are serialized as one object. Enum classes are serialized using the index of their
85 * element.
86 * <p>
87 * This class is mutable and should be created once per serialization.
88 *
89 * @serial include
90 * @since 1.8
91 */
92 final class Ser implements Externalizable {
93
94 /**
95 * Serialization version.
96 */
97 @java.io.Serial
98 private static final long serialVersionUID = -6103370247208168577L;
99
100 static final byte CHRONO_TYPE = 1;
101 static final byte CHRONO_LOCAL_DATE_TIME_TYPE = 2;
102 static final byte CHRONO_ZONE_DATE_TIME_TYPE = 3;
103 static final byte JAPANESE_DATE_TYPE = 4;
104 static final byte JAPANESE_ERA_TYPE = 5;
105 static final byte HIJRAH_DATE_TYPE = 6;
106 static final byte MINGUO_DATE_TYPE = 7;
107 static final byte THAIBUDDHIST_DATE_TYPE = 8;
108 static final byte CHRONO_PERIOD_TYPE = 9;
109
110 /** The type being serialized. */
111 private byte type;
112 /** The object being serialized. */
113 private Object object;
114
115 /**
116 * Constructor for deserialization.
117 */
233 private static Object readInternal(byte type, ObjectInput in) throws IOException, ClassNotFoundException {
234 switch (type) {
235 case CHRONO_TYPE: return AbstractChronology.readExternal(in);
236 case CHRONO_LOCAL_DATE_TIME_TYPE: return ChronoLocalDateTimeImpl.readExternal(in);
237 case CHRONO_ZONE_DATE_TIME_TYPE: return ChronoZonedDateTimeImpl.readExternal(in);
238 case JAPANESE_DATE_TYPE: return JapaneseDate.readExternal(in);
239 case JAPANESE_ERA_TYPE: return JapaneseEra.readExternal(in);
240 case HIJRAH_DATE_TYPE: return HijrahDate.readExternal(in);
241 case MINGUO_DATE_TYPE: return MinguoDate.readExternal(in);
242 case THAIBUDDHIST_DATE_TYPE: return ThaiBuddhistDate.readExternal(in);
243 case CHRONO_PERIOD_TYPE: return ChronoPeriodImpl.readExternal(in);
244 default: throw new StreamCorruptedException("Unknown serialized type");
245 }
246 }
247
248 /**
249 * Returns the object that will replace this one.
250 *
251 * @return the read object, should never be null
252 */
253 @java.io.Serial
254 private Object readResolve() {
255 return object;
256 }
257
258 }
|