Package org.apache.jackrabbit.core.state
Class ChangeLog
- java.lang.Object
-
- org.apache.jackrabbit.core.state.ChangeLog
-
public class ChangeLog extends Object
Registers changes made to states and references and consolidates empty changes.
-
-
Constructor Summary
Constructors Constructor Description ChangeLog()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadded(ItemState state)A state has been addedIterable<ItemState>addedStates()Return the added states in this change log.booleandeleted(ItemId id)Return a flag indicating whether a given item state is marked as deleted in this log.voiddeleted(ItemState state)A state has been deleted.Iterable<ItemState>deletedStates()Return the deleted states in this change log.voiddisconnect()Disconnect all states in the change log from their overlaid states.ItemStateget(ItemId id)Return an item state given its id.NodeReferencesgetReferencesTo(NodeId id)Return a node references object given the target node id.longgetUpdateSize()Returns the update size of the change log.booleanhas(ItemId id)Return a flag indicating whether a given item state exists.booleanhasUpdates()Checks whether this change log contains any changes.booleanisAdded(ItemId id)Return a flag indicating whether a given item state is marked as added in this log.booleanisModified(ItemId id)Returns a flag indicating whether a given item state is marked as modified in this log.voidmerge(ChangeLog other)Merge another change log with this change logvoidmodified(ItemState state)A state has been modified.voidmodified(NodeReferences refs)A references has been modifiedIterable<NodeReferences>modifiedRefs()Return the modified references in this change log.Iterable<ItemState>modifiedStates()Return the modified states in this change log.voidpersisted()After the states have actually been persisted, update their internal states and notify listeners.voidpush()Push all states contained in the various maps of items we have.voidremoveReferencesEntry(NodeId targetId)Removes the references entry with the given target node id.voidreset()Reset this change log, removing all members inside the maps we built.voidsetUpdateSize(long updateSize)Sets the update size of the change log.StringtoString()Returns a string representation of this change log for diagnostic purposes.voidundo(ItemStateManager parent)Undo changes made to items in the change log.
-
-
-
Method Detail
-
hasUpdates
public boolean hasUpdates()
Checks whether this change log contains any changes. This method is used to avoid extra work on updates that contain no changes.- Returns:
trueif this log contains at least one change,falseotherwise- Since:
- Apache Jackrabbit 1.5
- See Also:
- JCR-1813
-
added
public void added(ItemState state)
A state has been added- Parameters:
state- state that has been added
-
modified
public void modified(ItemState state)
A state has been modified. If the state is not a new state (not in the collection of added ones), then disconnect the local state from its underlying shared state and add it to the modified states collection.- Parameters:
state- state that has been modified
-
deleted
public void deleted(ItemState state)
A state has been deleted. If the state is not a new state (not in the collection of added ones), then disconnect the local state from its underlying shared state, remove it from the modified states collection and add it to the deleted states collection.- Parameters:
state- state that has been deleted
-
modified
public void modified(NodeReferences refs)
A references has been modified- Parameters:
refs- refs that has been modified
-
removeReferencesEntry
public void removeReferencesEntry(NodeId targetId)
Removes the references entry with the given target node id. This method is called byVersionItemStateManagerto drop references to virtual nodes.- Parameters:
targetId- target node id
-
get
public ItemState get(ItemId id) throws NoSuchItemStateException
Return an item state given its id. Returnsnullif the item state is neither in the added nor in the modified section. Throws aNoSuchItemStateExceptionif the item state is in the deleted section.- Returns:
- item state or
null - Throws:
NoSuchItemStateException- if the item has been deleted
-
has
public boolean has(ItemId id)
Return a flag indicating whether a given item state exists.- Returns:
trueif item state exists within this log;falseotherwise
-
deleted
public boolean deleted(ItemId id)
Return a flag indicating whether a given item state is marked as deleted in this log.- Returns:
trueif item state is marked as deleted in this log;falseotherwise
-
isAdded
public boolean isAdded(ItemId id)
Return a flag indicating whether a given item state is marked as added in this log.- Returns:
trueif item state is marked as added in this log;falseotherwise
-
isModified
public boolean isModified(ItemId id)
Returns a flag indicating whether a given item state is marked as modified in this log.- Parameters:
id- the id of the item.- Returns:
trueif the item state is marked as modified in this log;falseotherwise.
-
getReferencesTo
public NodeReferences getReferencesTo(NodeId id)
Return a node references object given the target node id. Returnsnullif the node reference is not in the modified section.- Returns:
- node references or
null
-
addedStates
public Iterable<ItemState> addedStates()
Return the added states in this change log.- Returns:
- added states
-
modifiedStates
public Iterable<ItemState> modifiedStates()
Return the modified states in this change log.Note that this change log must not be modified while iterating through the returned states.
- Returns:
- modified states
-
deletedStates
public Iterable<ItemState> deletedStates()
Return the deleted states in this change log.Note that this change log must not be modified while iterating through the returned states.
- Returns:
- deleted states
-
modifiedRefs
public Iterable<NodeReferences> modifiedRefs()
Return the modified references in this change log.Note that this change log must not be modified while iterating through the returned states.
- Returns:
- modified references
-
merge
public void merge(ChangeLog other)
Merge another change log with this change log- Parameters:
other- other change log
-
push
public void push()
Push all states contained in the various maps of items we have.
-
persisted
public void persisted()
After the states have actually been persisted, update their internal states and notify listeners.
-
reset
public void reset()
Reset this change log, removing all members inside the maps we built.
-
disconnect
public void disconnect()
Disconnect all states in the change log from their overlaid states.
-
undo
public void undo(ItemStateManager parent)
Undo changes made to items in the change log. Discards added items, refreshes modified and resurrects deleted items.- Parameters:
parent- parent manager that will hold current data
-
getUpdateSize
public long getUpdateSize()
Returns the update size of the change log.- Returns:
- The update size.
-
setUpdateSize
public void setUpdateSize(long updateSize)
Sets the update size of the change log.- Parameters:
updateSize- The update size.
-
-