openFiles();
return (nextElement = popNext()) != null;
}
private MonitoringData popNext() {
MonitoringData monitoringData = null;
OpenedFile dpSource = null;
ListIterator<OpenedFile> it = openFiles.listIterator();
while (it.hasNext()) {
OpenedFile of = it.next();
MonitoringData nextDp = of.pop();
if (nextDp == null) {
it.remove();
continue;
}
if (monitoringData == null || ((!reverse && nextDp.getTimeStamp().getTime() < monitoringData.getTimeStamp().getTime()) || (reverse && nextDp.getTimeStamp().getTime() > monitoringData.getTimeStamp().getTime()))) {
if (monitoringData != null) {
dpSource.push(monitoringData);
}
dpSource = of;
monitoringData = nextDp;
}
}
if (monitoringData != null) {
currentTimestamp = monitoringData.getTimeStamp().getTime();
if (!files.isEmpty() && ((!reverse && files.get(0).earliestTimestamp < currentTimestamp) || (reverse && files.get(0).latestTimestamp > currentTimestamp))) {
dpSource.push(monitoringData);
openFiles();
return popNext();
}
} else if (!files.isEmpty()) {
currentTimestamp = reverse?files.get(0).latestTimestamp:files.get(0).earliestTimestamp;
openFiles();
return popNext();
}
return monitoringData;
}
@Override
public MonitoringData next() {
if (!hasNext())
throw new NoSuchElementException();
MonitoringData next = nextElement;
nextElement = null;
return next;
}
@Override