org.coweb.oe
Class HistoryBuffer

java.lang.Object
  extended by org.coweb.oe.HistoryBuffer

public class HistoryBuffer
extends Object


Constructor Summary
HistoryBuffer()
           
 
Method Summary
 void addLocal(Operation op)
          Adds a local operation to the history.
 void addRemote(Operation op)
          Adds a received operation to the history.
 Stack<Operation> getContextSortedOperations()
          Gets all operations in the history buffer sorted by context.
 int getCount()
          Gets the number of operations in the history.
 Stack<Operation> getOpsForDifference(ContextDifference cd)
          Retrieves all of the operations represented by the given context differences from the history buffer.
 Object[] getState()
          Serializes the history buffer contents to seed a remote instance.
 Operation remove(Operation op)
          Removes and returns an operation in the history.
 void setState(Object[] arr)
          Unserializes history buffer contents to initialize this instance.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HistoryBuffer

public HistoryBuffer()
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getState

public Object[] getState()
Serializes the history buffer contents to seed a remote instance.

Returns:
{Object[]} Serialized operations in the history

setState

public void setState(Object[] arr)
Unserializes history buffer contents to initialize this instance.

Parameters:
{Object[]} - arr Array in the format returned by getState

getOpsForDifference

public Stack<Operation> getOpsForDifference(ContextDifference cd)
                                     throws OperationEngineException
Retrieves all of the operations represented by the given context differences from the history buffer. Sorts them by total order, placing any ops with an unknown place in the order (i.e., local ops) at the end sorted by their sequence IDs. Throws an exception when a requested operation is missing from the history.

Parameters:
{ContextDifference} - cd Context difference object
Throws:
OperationEngineException

addLocal

public void addLocal(Operation op)
Adds a local operation to the history.

Parameters:
{Operation} - Local operation to add

addRemote

public void addRemote(Operation op)
               throws OperationEngineException
Adds a received operation to the history. If the operation already exists in the history, simply updates its order attribute. If not, adds it. Throws an exception if the op does not include its place in the total order or if the op with the same key already has an assigned place in the total order.

Parameters:
{Operation} - Received operation to add
Throws:
OperationEngineException

remove

public Operation remove(Operation op)
Removes and returns an operation in the history.

Parameters:
{Operation} - op Operation to locate for removal

getCount

public int getCount()
Gets the number of operations in the history.


getContextSortedOperations

public Stack<Operation> getContextSortedOperations()
Gets all operations in the history buffer sorted by context.



Copyright © 2011-2012 The Dojo Foundation. All Rights Reserved.