Java Reference
In-Depth Information
Hashtable temp
#
(Hashtable) inputObject.readObject();
Iterator iterator
#
temp.entrySet().iterator();
while
(iterator.hasNext()) {
Map.Entry entry
#
(Map.Entry) iterator.next();
Trackable target
#
((Trackable)objectList.get(entry.getKey()));
target.restore((Trackable)entry.getValue());
}
inputObject.close();
inputFile.close();
// loads the saved sequence of entries
inputFile
#
new
FileInputStream
("trackerPhysical.log");
inputObject
#
new
ObjectInputStream(inputFile);
entryList.removeAll(entryList);
Entry entry
#
null
;
// builds the list of Entry objects
while
((entry
#
(Entry)inputObject.readObject()) !
#
null
)
entryList.add(entry);
inputObject.close();
inputFile.close();
}
catch
(Exception e) {
System.out.println("*** end of file ***");
currentEntry
#
0;
}
}
public static void
redoUntil(
int
entryID) {
if
(entryID
##
currentEntry
||
entryID > entryList.size())
return
;
// in the case of undo operation, the application state
// is restored to the last saved stable state;
if
(entryID < currentEntry)
restore()
// it redos all of the operations loaded from the log
// file up to the current entry
while
(entryID > currentEntry){
Entry entry
#
(Entry) entryList.get(currentEntry);
Trackable target
#
(Trackable) objectList.get
(entry.getTargetRef());
target.restore(entry.getTarget());
currentEntry
!!
;
}
}