|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.priha.util.ChangeStore
public class ChangeStore
Provides a list of changes, which can be both played back one by one, as well as searched rapidly.
Internally, this class stores both a List of Change objects, as well as a HashMap pointing at the latest change. It can be iterated both forwards (using peek() and remove() and iterator()) as well as backwards (using values()).
In addition, it stores a separate reference to all the changes relating to a particular parent path (making it fairly fast to filter based on a path).
Nested Class Summary | |
---|---|
static class |
ChangeStore.Change
Stores a single change. |
Constructor Summary | |
---|---|
ChangeStore()
Create a ChangeStore without the HashMap. |
Method Summary | |
---|---|
boolean |
add(ChangeStore.Change c)
Adds a whole Change object at the end of the Change List. |
void |
add(ItemState newState,
ItemImpl ii)
Adds a new Item with given ItemState to the end of the Change List. |
int |
clear()
Clears the changes. |
void |
dump()
Dumps the store contents for debugging to System.out. |
ChangeStore.Change |
getLatestChange(Path path)
Finds the latest change. |
java.util.List<ChangeStore.Change> |
getLatestChanges()
Get all the latest changes, ignoring any duplicate changes. |
java.util.List<ChangeStore.Change> |
getLatestChangesForParent(Path parent)
Returns a list of Changes filtered by a parent path. |
ItemImpl |
getLatestItem(Path path)
Returns the newest ItemImpl that corresponds to the Path given. |
boolean |
isEmpty()
Returns true, if there are no changes. |
java.util.Iterator<ChangeStore.Change> |
iterator()
Returns a forward iterator for the Changes. |
ChangeStore.Change |
peek()
Gets the first change from the change list. |
ChangeStore.Change |
remove()
Removes the first change from the change list. |
java.lang.String |
toString()
Outputs a human-readable description of the contents of the ChangeStore. |
java.util.Iterator<ItemImpl> |
values()
Returns a backward iterator for the Items in the change list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ChangeStore()
Method Detail |
---|
public ItemImpl getLatestItem(Path path)
path
- Path to search for
public ChangeStore.Change getLatestChange(Path path)
path
- Path to search for
public java.util.List<ChangeStore.Change> getLatestChanges()
public java.util.List<ChangeStore.Change> getLatestChangesForParent(Path parent)
parent
- The path to filter against
public void add(ItemState newState, ItemImpl ii)
newState
- New stateii
- The Itempublic boolean add(ChangeStore.Change c)
c
- The Change to add
public ChangeStore.Change peek()
public ChangeStore.Change remove()
public int clear()
public java.util.Iterator<ChangeStore.Change> iterator()
iterator
in interface java.lang.Iterable<ChangeStore.Change>
public java.util.Iterator<ItemImpl> values()
public final boolean isEmpty()
public void dump()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |