Package io.keikai.doc.collab.structs
Class Item
- java.lang.Object
-
- io.keikai.doc.collab.structs.AbstractStruct
-
- io.keikai.doc.collab.structs.Item
-
public class Item extends AbstractStruct
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(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)AbstractContentgetContent()intgetInfo()IDgetLastId()Computes the last content address of this item.AbstractStructgetLeft()booleangetMarker()Checks if the item is marked as a fast-search marker.java.lang.IntegergetMissing(Transaction transaction, StructStore store)Returns the client ID of the missing operation or defines missing items and returns null.ItemgetNext()Returns the next non-deleted item.IDgetOrigin()java.lang.ObjectgetParent()java.lang.StringgetParentSub()ItemgetPrev()Returns the previous non-deleted item.IDgetRedone()AbstractStructgetRight()IDgetRightOrigin()voidintegrate(Transaction transaction, int offset)Integrates this item into the document.booleanisCountable()Checks if the item is countable.booleanisDeleted()Checks if the item is deleted.static booleanisDeletedByUndoStack(java.util.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 voidkeepItem(Item item, boolean keep)Ensures that neither the item nor any of its parents is ever deleted.voidmarkDeleted()Marks 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, java.util.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.voidsetParent(java.lang.Object parent)voidsetParentSub(java.lang.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 Detail
-
Item
public Item(ID id, Item left, ID origin, Item right, ID rightOrigin, java.lang.Object parent, java.lang.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 Detail
-
getOrigin
public ID getOrigin()
-
getLeft
public AbstractStruct getLeft()
-
setLeft
public void setLeft(AbstractStruct left)
-
getRight
public AbstractStruct getRight()
-
setRight
public void setRight(AbstractStruct right)
-
getRightOrigin
public ID getRightOrigin()
-
getParent
public java.lang.Object getParent()
-
setParent
public void setParent(java.lang.Object parent)
-
getParentSub
public java.lang.String getParentSub()
-
setParentSub
public void setParentSub(java.lang.String parentSub)
-
getRedone
public ID getRedone()
-
getContent
public AbstractContent 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
public java.lang.Integer getMissing(Transaction transaction, StructStore store)
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
public void integrate(Transaction transaction, int offset)
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
public Item getNext()
Returns the next non-deleted item.- Returns:
- The next non-deleted item, or null if none exists.
-
getPrev
public Item getPrev()
Returns the previous non-deleted item.- Returns:
- The previous non-deleted item, or null if none exists.
-
getLastId
public ID getLastId()
Computes the last content address of this item.- Returns:
- The last ID of this item.
-
mergeWith
public boolean mergeWith(AbstractStruct right)
Try to merge two items- Overrides:
mergeWithin classAbstractStruct- Parameters:
right-- Returns:
- boolean
-
delete
public void delete(Transaction transaction)
Mark this Item as deleted.- Parameters:
transaction-
-
gc
public void gc(StructStore store, boolean parentGCd)
- Parameters:
store-parentGCd-
-
write
public void write(UpdateEncoder encoder, int offset)
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
public static ItemResult followRedone(StructStore store, ID id)
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
public static void keepItem(Item item, boolean keep)
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
public static Item splitItem(Transaction transaction, Item leftItem, int diff)
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
public static boolean isDeletedByUndoStack(java.util.List<StackItem> stack, ID id)
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, java.util.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
public static AbstractContent readItemContent(UpdateDecoder decoder, int info)
Reads the content of an item from the decoder.- Parameters:
decoder- The decoder to read from.info- The info byte.- Returns:
- The abstract content.
-
-