org.apache.jackrabbit.jcr2spi.state
Class ChangeLog

java.lang.Object
  extended by org.apache.jackrabbit.jcr2spi.state.ChangeLog

public class ChangeLog
extends Object

Registers changes made to states and references and consolidates empty changes.


Method Summary
 void added(ItemState state)
          A state has been added
 Iterator addedStates()
          Return an iterator over all added states.
 void addOperation(Operation operation)
          Add the given operation to the list of operations to be recorded within the current update cycle of this ChangeLog.
 void checkIsSelfContained()
          Make sure that this ChangeLog is totally 'self-contained' and independant; items within the scope of this update operation must not have 'external' dependencies; (e.g.
 void collectOperations(Iterator operations)
          Populates this ChangeLog with operations that are within the scope of this change set.
 boolean containsDeletedState(ItemState state)
          Returns true, if this change log contains the given ItemState in the set of transiently removed states.
 void deleted(ItemState state)
          A state has been deleted.
 Iterator deletedStates()
          Return an iterator over all deleted states.
 Iterator getOperations()
           
 ItemState getTarget()
           
 boolean isEmpty()
           
 void modified(ItemState state)
          A state has been modified.
 Iterator modifiedStates()
          Return an iterator over all modified states.
 void persisted()
          Call this method when this change log has been sucessfully persisted.
 void removeAll(ChangeLog subChangeLog)
          Removes the subset of this changelog represented by the given ChangeLog from this changelog.
 void reset()
          Reset this change log, removing all members inside the maps we built.
 void statusChanged(ItemState state, int previousStatus)
          Adjust this ChangeLog according to the status change with the given ItemState: Remove all entries and operation related to the given ItemState, that are not used any more (respecting the status change).
 String toString()
          Returns a string representation of this change log for diagnostic purposes.
 void undo()
          Revert the changes listed within this changelog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

addOperation

public void addOperation(Operation operation)
Add the given operation to the list of operations to be recorded within the current update cycle of this ChangeLog.

Parameters:
operation -

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 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 remove it from the modified states collection and add it to the deleted states collection.

Parameters:
state - state that has been deleted

persisted

public void persisted()
Call this method when this change log has been sucessfully persisted. This implementation will call ItemState.refresh(this) on the target item of this change log.


undo

public void undo()
          throws RepositoryException
Revert the changes listed within this changelog

Throws:
RepositoryException

getTarget

public ItemState getTarget()
Returns:

isEmpty

public boolean isEmpty()
Returns:

getOperations

public Iterator getOperations()
Returns:

addedStates

public Iterator addedStates()
Return an iterator over all added states.

Returns:
iterator over all added states.

modifiedStates

public Iterator modifiedStates()
Return an iterator over all modified states.

Returns:
iterator over all modified states.

deletedStates

public Iterator deletedStates()
Return an iterator over all deleted states.

Returns:
iterator over all deleted states.

containsDeletedState

public boolean containsDeletedState(ItemState state)
Returns true, if this change log contains the given ItemState in the set of transiently removed states.

Parameters:
state -
Returns:

removeAll

public void removeAll(ChangeLog subChangeLog)
Removes the subset of this changelog represented by the given ChangeLog from this changelog.

Parameters:
subChangeLog - remove all entries (states, operations) present in the given changelog from this changelog.

statusChanged

public void statusChanged(ItemState state,
                          int previousStatus)
Adjust this ChangeLog according to the status change with the given ItemState: Remove all entries and operation related to the given ItemState, that are not used any more (respecting the status change).

Parameters:
state -

checkIsSelfContained

public void checkIsSelfContained()
                          throws ConstraintViolationException
Make sure that this ChangeLog is totally 'self-contained' and independant; items within the scope of this update operation must not have 'external' dependencies; (e.g. moving a node requires that the target node including both old and new parents are saved)

Throws:
ConstraintViolationException

collectOperations

public void collectOperations(Iterator operations)
Populates this ChangeLog with operations that are within the scope of this change set.

Parameters:
operations - an Iterator of Operations which are the candidates to be included in this ChangeLog.

reset

public void reset()
Reset this change log, removing all members inside the maps we built.


toString

public String toString()
Returns a string representation of this change log for diagnostic purposes.

Overrides:
toString in class Object
Returns:
a string representation of this change log


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.