}
void collectVals(BucketMap map, boolean sum) throws JRException
{
ListIterator totalIt = entries.listIterator();
MapEntry totalItEntry = totalIt.hasNext() ? (MapEntry) totalIt.next() : null;
Iterator it = map.entryIterator();
Map.Entry entry = it.hasNext() ? (Map.Entry) it.next() : null;
while(entry != null)
{
Bucket key = (Bucket) entry.getKey();
int compare = totalItEntry == null ? -1 : key.compareTo(totalItEntry.key);
if (compare <= 0)
{
Object addVal = null;
if (last)
{
if (sum)
{
MeasureValue[] totalVals = compare == 0 ? (MeasureValue[]) totalItEntry.value : null;
if (totalVals == null)
{
totalVals = initMeasureValues();
addVal = totalVals;
}
sumVals(totalVals, (MeasureValue[]) entry.getValue());
}
}
else
{
BucketListMap nextTotals = compare == 0 ? (BucketListMap) totalItEntry.value : null;
if (nextTotals == null)
{
nextTotals = createCollectBucketMap(level + 1);
addVal = nextTotals;
}
nextTotals.collectVals((BucketMap) entry.getValue(), sum);
}
if (compare < 0)
{
if (totalItEntry != null)
{
totalIt.previous();
}
totalIt.add(new MapEntry(key, addVal));
entryMap.put(key, addVal);
if (totalItEntry != null)
{
totalIt.next();
}
}
entry = it.hasNext() ? (Map.Entry) it.next() : null;
}
if (compare >= 0)
{
totalItEntry = totalIt.hasNext() ? (MapEntry) totalIt.next() : null;
}
}
}