DiffTracker tracker,
boolean doPrint)
throws Exception {
List<MismatchedRegion> regions = tracker.getDiffRegions();
Cursor localCursor = null;
Cursor remoteCursor = null;
try {
localCursor = localDb.openCursor(null, null);
remoteCursor = remoteDb.openCursor(null, null);
for (MismatchedRegion region : regions) {
if (region.isLocalAdditional()) {
printLocalAdditional(localCursor, region, doPrint);
continue;
}
if (region.isRemoteAdditional()) {
HashSet<Record> records =
getDiffArea(remoteCursor, region.getRemoteBeginKey(),
region.getRemoteBeginData(),
region.getRemoteDiffSize());
if (doPrint) {
printAdditional(records, true);
}
records.clear();
continue;
}
HashSet<Record> localRecords =
getDiffArea(localCursor, region.getLocalBeginKey(),
region.getLocalBeginData(),
region.getLocalDiffSize());
HashSet<Record> remoteRecords =
getDiffArea(remoteCursor, region.getRemoteBeginKey(),
region.getRemoteBeginData(),
region.getRemoteDiffSize());
if (doPrint) {
printDiffs(localRecords, remoteRecords);
}
localRecords.clear();
remoteRecords.clear();
}
} finally {
if (localCursor != null) {
localCursor.close();
}
if (remoteCursor != null) {
remoteCursor.close();
}
}
}