74 * <p>
75 * In order to serialize the object it writes its byte and then calls back to the appropriate class where
76 * the serialization is performed. In order to deserialize the object it read in the type byte, switching
77 * in order to select which class to call back into.
78 * <p>
79 * The serialization format is determined on a per class basis. In the case of field based classes each
80 * of the fields is written out with an appropriate size format in descending order of the field's size. For
81 * example in the case of {@link LocalDate} year is written before month. Composite classes, such as
82 * {@link LocalDateTime} are serialized as one object.
83 * <p>
84 * This class is mutable and should be created once per serialization.
85 *
86 * @serial include
87 * @since 1.8
88 */
89 final class Ser implements Externalizable {
90
91 /**
92 * Serialization version.
93 */
94 private static final long serialVersionUID = -7683839454370182990L;
95
96 static final byte DURATION_TYPE = 1;
97 static final byte INSTANT_TYPE = 2;
98 static final byte LOCAL_DATE_TYPE = 3;
99 static final byte LOCAL_TIME_TYPE = 4;
100 static final byte LOCAL_DATE_TIME_TYPE = 5;
101 static final byte ZONE_DATE_TIME_TYPE = 6;
102 static final byte ZONE_REGION_TYPE = 7;
103 static final byte ZONE_OFFSET_TYPE = 8;
104 static final byte OFFSET_TIME_TYPE = 9;
105 static final byte OFFSET_DATE_TIME_TYPE = 10;
106 static final byte YEAR_TYPE = 11;
107 static final byte YEAR_MONTH_TYPE = 12;
108 static final byte MONTH_DAY_TYPE = 13;
109 static final byte PERIOD_TYPE = 14;
110
111 /** The type being serialized. */
112 private byte type;
113 /** The object being serialized. */
260 case LOCAL_TIME_TYPE: return LocalTime.readExternal(in);
261 case ZONE_DATE_TIME_TYPE: return ZonedDateTime.readExternal(in);
262 case ZONE_OFFSET_TYPE: return ZoneOffset.readExternal(in);
263 case ZONE_REGION_TYPE: return ZoneRegion.readExternal(in);
264 case OFFSET_TIME_TYPE: return OffsetTime.readExternal(in);
265 case OFFSET_DATE_TIME_TYPE: return OffsetDateTime.readExternal(in);
266 case YEAR_TYPE: return Year.readExternal(in);
267 case YEAR_MONTH_TYPE: return YearMonth.readExternal(in);
268 case MONTH_DAY_TYPE: return MonthDay.readExternal(in);
269 case PERIOD_TYPE: return Period.readExternal(in);
270 default:
271 throw new StreamCorruptedException("Unknown serialized type");
272 }
273 }
274
275 /**
276 * Returns the object that will replace this one.
277 *
278 * @return the read object, should never be null
279 */
280 private Object readResolve() {
281 return object;
282 }
283
284 }
|
74 * <p>
75 * In order to serialize the object it writes its byte and then calls back to the appropriate class where
76 * the serialization is performed. In order to deserialize the object it read in the type byte, switching
77 * in order to select which class to call back into.
78 * <p>
79 * The serialization format is determined on a per class basis. In the case of field based classes each
80 * of the fields is written out with an appropriate size format in descending order of the field's size. For
81 * example in the case of {@link LocalDate} year is written before month. Composite classes, such as
82 * {@link LocalDateTime} are serialized as one object.
83 * <p>
84 * This class is mutable and should be created once per serialization.
85 *
86 * @serial include
87 * @since 1.8
88 */
89 final class Ser implements Externalizable {
90
91 /**
92 * Serialization version.
93 */
94 @java.io.Serial
95 private static final long serialVersionUID = -7683839454370182990L;
96
97 static final byte DURATION_TYPE = 1;
98 static final byte INSTANT_TYPE = 2;
99 static final byte LOCAL_DATE_TYPE = 3;
100 static final byte LOCAL_TIME_TYPE = 4;
101 static final byte LOCAL_DATE_TIME_TYPE = 5;
102 static final byte ZONE_DATE_TIME_TYPE = 6;
103 static final byte ZONE_REGION_TYPE = 7;
104 static final byte ZONE_OFFSET_TYPE = 8;
105 static final byte OFFSET_TIME_TYPE = 9;
106 static final byte OFFSET_DATE_TIME_TYPE = 10;
107 static final byte YEAR_TYPE = 11;
108 static final byte YEAR_MONTH_TYPE = 12;
109 static final byte MONTH_DAY_TYPE = 13;
110 static final byte PERIOD_TYPE = 14;
111
112 /** The type being serialized. */
113 private byte type;
114 /** The object being serialized. */
261 case LOCAL_TIME_TYPE: return LocalTime.readExternal(in);
262 case ZONE_DATE_TIME_TYPE: return ZonedDateTime.readExternal(in);
263 case ZONE_OFFSET_TYPE: return ZoneOffset.readExternal(in);
264 case ZONE_REGION_TYPE: return ZoneRegion.readExternal(in);
265 case OFFSET_TIME_TYPE: return OffsetTime.readExternal(in);
266 case OFFSET_DATE_TIME_TYPE: return OffsetDateTime.readExternal(in);
267 case YEAR_TYPE: return Year.readExternal(in);
268 case YEAR_MONTH_TYPE: return YearMonth.readExternal(in);
269 case MONTH_DAY_TYPE: return MonthDay.readExternal(in);
270 case PERIOD_TYPE: return Period.readExternal(in);
271 default:
272 throw new StreamCorruptedException("Unknown serialized type");
273 }
274 }
275
276 /**
277 * Returns the object that will replace this one.
278 *
279 * @return the read object, should never be null
280 */
281 @java.io.Serial
282 private Object readResolve() {
283 return object;
284 }
285
286 }
|