-
public final class ProvisioningCodecCustom binary codec for ProvisioningInfo, replacing
{@code ObjectInputStream}/{@code ObjectOutputStream}on the disk-cache hot path.Format: a tagged TLV stream. Each field is written as
{@code [uint16 fieldId][uint8 typeTag][value]}, terminated by{@code fieldId=FIELD_END=0}. Unknown field ids encountered by an older reader are skipped using the type tag — providing forward compatibility. Missing field ids leave the ProvisioningInfo default in place — providing backward compatibility.Adding a new field: assign the next unused FIELD_* constant, emit it in write, decode it in read. Never reuse a removed id.
The format starts with a 4-byte magic (MAGIC) and 4-byte version int so legacy Java-serialized files (which start with
{@code 0xAC 0xED}) can be distinguished and migrated via tryReadProvisioningInfo.
-
-
Field Summary
Fields Modifier and Type Field Description public final static intMAGICpublic final static intCURRENT_VERSION
-
Method Summary
Modifier and Type Method Description static voidwrite(DataOutput out, ProvisioningInfo info)Serializes {@code info}as a tagged TLV stream prefixed with the codec magic and version.static ProvisioningInforead(DataInput in)Reads a TLV stream produced by write. static ProvisioningInfotryReadProvisioningInfo(InputStream in)Reads a ProvisioningInfo from {@code in}.-
-
Method Detail
-
write
static void write(DataOutput out, ProvisioningInfo info)
Serializes
{@code info}as a tagged TLV stream prefixed with the codec magic and version.
-
read
static ProvisioningInfo read(DataInput in)
-
tryReadProvisioningInfo
static ProvisioningInfo tryReadProvisioningInfo(InputStream in)
Reads a ProvisioningInfo from
{@code in}. If the stream begins with the codec magic(MAGIC), reads via read. Otherwise falls back to ObjectInputStream, supporting one-time migration from the legacy Java-serializedformat. The returned object should immediately be re-saved via write so the legacyread path is not hit again.- Parameters:
in- stream positioned at the start of the file
-
-
-
-