use of net.sourceforge.processdash.util.EnumerIterator in project processdash by dtuma.
the class ImportedTimeLogManager method getImportedTimeLogEntries.
/**
* Return an iterator of the time log entries mounted at the given prefix.
* If no imported defects are mounted at the given prefix, returns null.
*/
public EnumerIterator getImportedTimeLogEntries(String prefix) throws IOException {
prefix = cleanupPrefix(prefix);
List timeLogIterators = new ArrayList();
Map snapshot;
synchronized (importedLogs) {
snapshot = new HashMap(importedLogs);
}
for (Iterator i = snapshot.entrySet().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
String importedPrefix = (String) e.getKey();
File file = (File) e.getValue();
if (Filter.pathMatches(importedPrefix, prefix)) {
// this set of imported time log data is either (a) mounted
// at the exact prefix requested, or (b) mounted at a prefix
// underneath the one requested. In either case, we should
// return all imported entries.
Iterator content = new TimeLogReader(file);
timeLogIterators.add(content);
} else if (Filter.pathMatches(prefix, importedPrefix)) {
// in this case, the requested prefix identifies a subset of
// the imported time log data. We must filter that imported
// data to return the requested entries.
Iterator content = new TimeLogReader(file);
Iterator filteredContent = new TimeLogIteratorFilter(content, prefix, null, null);
if (filteredContent.hasNext())
timeLogIterators.add(filteredContent);
}
}
if (timeLogIterators.isEmpty())
return null;
else if (timeLogIterators.size() == 1)
return (EnumerIterator) timeLogIterators.get(0);
else
return new IteratorConcatenator(timeLogIterators);
}
Aggregations