Package io.keikai.doc.collab.structs
Class Item
java.lang.Object
io.keikai.doc.collab.structs.AbstractStruct
io.keikai.doc.collab.structs.Item
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(Transaction transaction) Mark this Item as deleted.static ItemResultfollowRedone(StructStore store, ID id) Follows the redone chain to find the final item.voidgc(StructStore store, boolean parentGCd) intgetInfo()Computes the last content address of this item.getLeft()booleanChecks if the item is marked as a fast-search marker.getMissing(Transaction transaction, StructStore store) Returns the client ID of the missing operation or defines missing items and returns null.getNext()Returns the next non-deleted item.getPrev()Returns the previous non-deleted item.getRight()voidintegrate(Transaction transaction, int offset) Integrates this item into the document.booleanChecks if the item is countable.booleanChecks if the item is deleted.static booleanisDeletedByUndoStack(List<StackItem> stack, ID id) Checks if an ID is deleted by the undo stack.booleanisKeep()Checks if the item should be kept and not garbage collected.static voidEnsures that neither the item nor any of its parents is ever deleted.voidMarks this item as deleted.booleanmergeWith(AbstractStruct right) Try to merge two itemsstatic AbstractContentreadItemContent(UpdateDecoder decoder, int info) Reads the content of an item from the decoder.static ItemredoItem(Transaction transaction, Item item, Set<Item> redoItems, DeleteSet itemsToDelete, boolean ignoreRemoteMapChanges, UndoManager undoManager) Redoes the effect of an operation.voidsetDeleted(boolean doDelete) Sets the item as deleted.voidsetKeep(boolean doKeep) Sets whether the item should be kept and not garbage collected.voidsetLeft(AbstractStruct left) voidsetMarker(boolean isMarked) Marks or unmarks this item as a fast-search marker.voidvoidsetParentSub(String parentSub) voidsetRight(AbstractStruct right) static ItemsplitItem(Transaction transaction, Item leftItem, int diff) Splits the left item into two items.voidwrite(UpdateEncoder encoder, int offset) Transform the properties of this type to binary and write it to a BinaryEncoder.Methods inherited from class io.keikai.doc.collab.structs.AbstractStruct
getId, length, setLength, write
-
Constructor Details
-
Item
public Item(ID id, Item left, ID origin, Item right, ID rightOrigin, Object parent, String parentSub, AbstractContent content) Constructor for the Item class.- Parameters:
id- The ID of this item.left- The item to the left of this item.origin- The original ID of the left item.right- The item to the right of this item.rightOrigin- The original ID of the right item.parent- The parent of this item, which can be a type or an ID.parentSub- A string that represents the parent key.content- The content of this item.
-
-
Method Details
-
getOrigin
-
getLeft
-
setLeft
-
getRight
-
setRight
-
getRightOrigin
-
getParent
-
setParent
-
getParentSub
-
setParentSub
-
getRedone
-
getContent
-
getInfo
public int getInfo() -
setMarker
public void setMarker(boolean isMarked) Marks or unmarks this item as a fast-search marker.- Parameters:
isMarked- Whether to mark the item.
-
getMarker
public boolean getMarker()Checks if the item is marked as a fast-search marker.- Returns:
- true if the item is marked, otherwise false.
-
isKeep
public boolean isKeep()Checks if the item should be kept and not garbage collected.- Returns:
- true if the item should be kept, otherwise false.
-
setKeep
public void setKeep(boolean doKeep) Sets whether the item should be kept and not garbage collected.- Parameters:
doKeep- Whether to keep the item.
-
isCountable
public boolean isCountable()Checks if the item is countable.- Returns:
- true if the item is countable, otherwise false.
-
isDeleted
public boolean isDeleted()Checks if the item is deleted.- Overrides:
isDeletedin classAbstractStruct- Returns:
- true if the item is deleted, otherwise false.
-
setDeleted
public void setDeleted(boolean doDelete) Sets the item as deleted.- Parameters:
doDelete- Whether to mark the item as deleted.
-
markDeleted
public void markDeleted()Marks this item as deleted. -
getMissing
Returns the client ID of the missing operation or defines missing items and returns null.- Parameters:
transaction- The current transaction.store- The store to retrieve the state from.- Returns:
- The client ID of the missing operation or null if none is missing.
-
integrate
Integrates this item into the document.- Overrides:
integratein classAbstractStruct- Parameters:
transaction- The transaction in which to integrate this item.offset- The offset at which to integrate this item.
-
getNext
Returns the next non-deleted item.- Returns:
- The next non-deleted item, or null if none exists.
-
getPrev
Returns the previous non-deleted item.- Returns:
- The previous non-deleted item, or null if none exists.
-
getLastId
Computes the last content address of this item.- Returns:
- The last ID of this item.
-
mergeWith
Try to merge two items- Overrides:
mergeWithin classAbstractStruct- Parameters:
right-- Returns:
- boolean
-
delete
Mark this Item as deleted.- Parameters:
transaction-
-
gc
- Parameters:
store-parentGCd-
-
write
Transform the properties of this type to binary and write it to a BinaryEncoder. This is called when this Item is sent to a remote peer.- Overrides:
writein classAbstractStruct- Parameters:
encoder- The encoder to use.offset- The offset at which to start encoding.
-
followRedone
Follows the redone chain to find the final item.- Parameters:
store- The StructStore instance.id- The ID of the item to follow.- Returns:
- A Result containing the final item and the difference in clocks.
-
keepItem
Ensures that neither the item nor any of its parents is ever deleted.- Parameters:
item- The item to keep.keep- Whether to keep the item.
-
splitItem
Splits the left item into two items.- Parameters:
transaction- The current transaction.leftItem- The item to split.diff- The difference in the clock.- Returns:
- The new right item.
-
isDeletedByUndoStack
Checks if an ID is deleted by the undo stack.- Parameters:
stack- The undo stack.id- The ID to check.- Returns:
- true if the ID is deleted by the undo stack, otherwise false.
-
redoItem
public static Item redoItem(Transaction transaction, Item item, Set<Item> redoItems, DeleteSet itemsToDelete, boolean ignoreRemoteMapChanges, UndoManager undoManager) Redoes the effect of an operation.- Parameters:
transaction- The transaction instance.item- The item to redo.redoItems- The set of items to redo.itemsToDelete- The set of items to delete.ignoreRemoteMapChanges- Whether to ignore remote map changes.undoManager- The undo manager.- Returns:
- The redone item, or null if the item could not be redone.
-
readItemContent
Reads the content of an item from the decoder.- Parameters:
decoder- The decoder to read from.info- The info byte.- Returns:
- The abstract content.
-