APIdia Launch Partner
Top Description Fields Constructors Methods
java.time

pack-priv final Class Ser

extends Object
implements Externalizable
Class Inheritance
All Implemented Interfaces
java.io.Externalizable, java.io.Serializable
Imports
java.io.Externalizable, .IOException, .InvalidClassException, .ObjectInput, .ObjectOutput, .Serializable, .StreamCorruptedException

The shared serialization delegate for this package.

Implementation Note

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 LOCAL_DATE_TYPE_VERSION_2 = 21.

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

The serialization 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 serialized as one object.

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

Since
1.8

Field Summary

Modifier and TypeField and Description
pack-priv static final byte
pack-priv static final byte
pack-priv static final byte
pack-priv static final byte
pack-priv static final byte
pack-priv static final byte
private Serializable
object

The object being serialized.

pack-priv static final byte
pack-priv static final byte
pack-priv static final byte
private static final long
serialVersionUID

Serialization version.

private byte
type

The type being serialized.

pack-priv static final byte
pack-priv static final byte
pack-priv static final byte
pack-priv static final byte
pack-priv static final byte

Constructor Summary

AccessConstructor and Description
public
Ser()

Constructor for deserialization.

pack-priv
Ser(byte
the type
type
,
Serializable
the object
object
)

Creates an instance for serialization.

Method Summary

Modifier and TypeMethod and Description
pack-priv static Serializable
public void
readExternal(ObjectInput
the data to read, not null
in
)

Implements java.io.Externalizable.readExternal.

Implements the Externalizable interface to read the object.

private static Serializable
readInternal(byte type, ObjectInput in)

private Object

Returns:

the read object, should never be null
readResolve
()

Returns the object that will replace this one.

public void
writeExternal(ObjectOutput
the data stream to write to, not null
out
)

Implements java.io.Externalizable.writeExternal.

Implements the Externalizable interface to write the object.

pack-priv static void
writeInternal(byte type, Object object, ObjectOutput out)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DURATION_TYPEback to summary
pack-priv static final byte DURATION_TYPE
INSTANT_TYPEback to summary
pack-priv static final byte INSTANT_TYPE
LOCAL_DATE_TIME_TYPEback to summary
pack-priv static final byte LOCAL_DATE_TIME_TYPE
LOCAL_DATE_TYPEback to summary
pack-priv static final byte LOCAL_DATE_TYPE
LOCAL_TIME_TYPEback to summary
pack-priv static final byte LOCAL_TIME_TYPE
MONTH_DAY_TYPEback to summary
pack-priv static final byte MONTH_DAY_TYPE
objectback to summary
private Serializable object

The object being serialized.

OFFSET_DATE_TIME_TYPEback to summary
pack-priv static final byte OFFSET_DATE_TIME_TYPE
OFFSET_TIME_TYPEback to summary
pack-priv static final byte OFFSET_TIME_TYPE
PERIOD_TYPEback to summary
pack-priv static final byte PERIOD_TYPE
serialVersionUIDback to summary
private static final long serialVersionUID

Serialization version.

Annotations
@Serial
typeback to summary
private byte type

The type being serialized.

YEAR_MONTH_TYPEback to summary
pack-priv static final byte YEAR_MONTH_TYPE
YEAR_TYPEback to summary
pack-priv static final byte YEAR_TYPE
ZONE_DATE_TIME_TYPEback to summary
pack-priv static final byte ZONE_DATE_TIME_TYPE
ZONE_OFFSET_TYPEback to summary
pack-priv static final byte ZONE_OFFSET_TYPE
ZONE_REGION_TYPEback to summary
pack-priv static final byte ZONE_REGION_TYPE

Constructor Detail

Serback to summary
public Ser()

Constructor for deserialization.

Serback to summary
pack-priv Ser(byte type, Serializable object)

Creates an instance for serialization.

Parameters
type:byte

the type

object:Serializable

the object

Method Detail

readback to summary
pack-priv static Serializable read(ObjectInput in) throws IOException, ClassNotFoundException
readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Implements java.io.Externalizable.readExternal.

Implements the Externalizable interface to read the object.

Parameters
in:ObjectInput

the data to read, not null

Exceptions
IOException:

Doc from java.io.Externalizable.readExternal.

if I/O errors occur

ClassNotFoundException:

Doc from java.io.Externalizable.readExternal.

If the class for an object being restored cannot be found.

Serial data
The streamed type and parameters defined by the type's writeReplace method are read and passed to the corresponding static factory for the type to create a new instance. That instance is returned as the de-serialized Ser object.
  • Duration - Duration.ofSeconds(seconds, nanos);
  • Instant - Instant.ofEpochSecond(seconds, nanos);
  • LocalDate - LocalDate.of(year, month, day);
  • LocalDateTime - LocalDateTime.of(date, time);
  • LocalTime - LocalTime.of(hour, minute, second, nano);
  • MonthDay - MonthDay.of(month, day);
  • OffsetTime - OffsetTime.of(time, offset);
  • OffsetDateTime - OffsetDateTime.of(dateTime, offset);
  • Period - Period.of(years, months, days);
  • Year - Year.of(year);
  • YearMonth - YearMonth.of(year, month);
  • ZonedDateTime - ZonedDateTime.ofLenient(dateTime, offset, zone);
  • ZoneId - ZoneId.of(id);
  • ZoneOffset - (offsetByte == 127 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(offsetByte * 900));
readInternalback to summary
private static Serializable readInternal(byte type, ObjectInput in) throws IOException, ClassNotFoundException
readResolveback to summary
private Object readResolve()

Returns the object that will replace this one.

Returns:Object

the read object, should never be null

Annotations
@Serial
writeExternalback to summary
public void writeExternal(ObjectOutput out) throws IOException

Implements java.io.Externalizable.writeExternal.

Implements the Externalizable interface to write the object.

Parameters
out:ObjectOutput

the data stream to write to, not null

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Externalizable.writeExternal.

Includes any I/O exceptions that may occur

Serial data
Each serializable class is mapped to a type that is the first byte in the stream. Refer to each class writeReplace serialized form for the value of the type and sequence of values for the type.
writeInternalback to summary
pack-priv static void writeInternal(byte type, Object object, ObjectOutput out) throws IOException