Package io.keikai.doc.collab.utils
Class Snapshot
java.lang.Object
io.keikai.doc.collab.utils.Snapshot
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DoccreateDocFromSnapshot(Doc originDoc, Snapshot snapshot) Create a document from a snapshot.static DoccreateDocFromSnapshot(Doc originDoc, Snapshot snapshot, Doc newDoc) Create a document from a snapshot.static SnapshotcreateSnapshot(DeleteSet ds, Map<Integer, Integer> sm) Create a new snapshot.static SnapshotdecodeSnapshot(Uint8Array buf) Decode a snapshot using DSDecoderV1.static SnapshotdecodeSnapshot(Uint8Array buf, DSDecoder decoder) Decode a snapshot using the specified decoder.static SnapshotDecode a snapshot using DSDecoderV2.static SnapshotCreate an empty snapshot.static Uint8ArrayencodeSnapshot(Snapshot snapshot) Encode a snapshot using DSEncoderV1.static Uint8ArrayencodeSnapshotV2(Snapshot snapshot, io.keikai.doc.collab.utils.DSEncoder encoder) Encode a snapshot using DSEncoderV2.static booleanequalSnapshots(Snapshot snap1, Snapshot snap2) Compare two snapshots for equality.Get the DeleteSet associated with this snapshot.Get the state map.static booleanCheck if an item is visible within a given snapshot.static SnapshotCreate a snapshot from a document's current state.static booleansnapshotContainsUpdate(Snapshot snapshot, Uint8Array update) Check if a snapshot contains a given update using UpdateDecoderV1.static booleansnapshotContainsUpdateV2(Snapshot snapshot, Uint8Array update, Class<? extends UpdateDecoder> yDecoder) Check if a snapshot contains a given update using a specific decoder.static voidsplitSnapshotAffectedStructs(Transaction transaction, Snapshot snapshot) Split snapshot-affected structs in a transaction.
-
Constructor Details
-
Snapshot
Constructor for the Snapshot class.- Parameters:
ds- The DeleteSet associated with this snapshot.sv- The state map.
-
-
Method Details
-
getDeleteSet
Get the DeleteSet associated with this snapshot.- Returns:
- The DeleteSet.
-
getStateMap
Get the state map.- Returns:
- The state map.
-
equalSnapshots
Compare two snapshots for equality.- Parameters:
snap1- First snapshot.snap2- Second snapshot.- Returns:
- true if the snapshots are equal, false otherwise.
-
encodeSnapshotV2
public static Uint8Array encodeSnapshotV2(Snapshot snapshot, io.keikai.doc.collab.utils.DSEncoder encoder) Encode a snapshot using DSEncoderV2.- Parameters:
snapshot- The snapshot to encode.encoder- The encoder to use (either DSEncoderV1 or DSEncoderV2).- Returns:
- An Uint8Array representing the encoded snapshot.
-
encodeSnapshot
Encode a snapshot using DSEncoderV1.- Parameters:
snapshot- The snapshot to encode.- Returns:
- An Uint8Array representing the encoded snapshot.
-
decodeSnapshot
Decode a snapshot using the specified decoder.- Parameters:
buf- The byte array to decode.decoder- The decoder to use (either DSDecoderV1 or DSDecoderV2).- Returns:
- The decoded snapshot.
-
decodeSnapshot
Decode a snapshot using DSDecoderV1.- Parameters:
buf- The byte array to decode.- Returns:
- The decoded snapshot.
-
decodeSnapshotV2
Decode a snapshot using DSDecoderV2.- Parameters:
buf- The byte array to decode.- Returns:
- The decoded snapshot.
-
createSnapshot
Create a new snapshot.- Parameters:
ds- The DeleteSet to include in the snapshot.sm- The state map to include in the snapshot.- Returns:
- The created snapshot.
-
emptySnapshot
Create an empty snapshot.- Returns:
- An empty snapshot.
-
snapshot
Create a snapshot from a document's current state.- Parameters:
doc- The document to create the snapshot from.- Returns:
- The created snapshot.
-
isVisible
Check if an item is visible within a given snapshot.- Parameters:
item- The item to check.snapshot- The snapshot to check against (optional).- Returns:
- true if the item is visible, false otherwise.
-
splitSnapshotAffectedStructs
Split snapshot-affected structs in a transaction.- Parameters:
transaction- The transaction to operate on.snapshot- The snapshot to split.
-
createDocFromSnapshot
Create a document from a snapshot.- Parameters:
originDoc- The original document.snapshot- The snapshot to restore from.- Returns:
- The restored document.
-
createDocFromSnapshot
Create a document from a snapshot.- Parameters:
originDoc- The original document.snapshot- The snapshot to restore from.newDoc- An optional new document to restore into.- Returns:
- The restored document.
-
snapshotContainsUpdateV2
public static boolean snapshotContainsUpdateV2(Snapshot snapshot, Uint8Array update, Class<? extends UpdateDecoder> yDecoder) Check if a snapshot contains a given update using a specific decoder.- Parameters:
snapshot- The snapshot to check against.update- The update to check.yDecoder- The decoder to use (either UpdateDecoderV1 or UpdateDecoderV2).- Returns:
- true if the snapshot contains the update, false otherwise.
-
snapshotContainsUpdate
Check if a snapshot contains a given update using UpdateDecoderV1.- Parameters:
snapshot- The snapshot to check against.update- The update to check.- Returns:
- true if the snapshot contains the update, false otherwise.
-