1 package com.calipso.reportgenerator.reportcalculator; 2 3 import com.calipso.reportgenerator.reportdefinitions.types.DimensionDefinitionOrderType; 4 import com.calipso.reportgenerator.common.*; 5 6 import java.util.Collection ; 7 import java.util.Vector ; 8 import java.util.Iterator ; 9 import java.util.Map ; 10 11 18 public class TopOperation extends FilterOperation { 19 private float upToValue; 20 private int accum = 0; 21 private Collection values; 22 23 public TopOperation(ReportResult result, ReportQuery reportQuery, ReportFilterSpec filter, int value) { 24 super(); 25 ReportDimensionSpec dimension = reportQuery.getReportSpec().getDimensionFromName(filter.getDimensionName()); 26 Collection values = result.getValuesCollection(dimension.getOrder()==DimensionDefinitionOrderType.A); 27 this.values = new Vector (); 28 Iterator it = values.iterator(); 29 this.upToValue = value; 30 for(int i=0; i < upToValue && it.hasNext(); i++){ 31 Object ob = it.next(); 32 if(ob instanceof DimensionValueNode){ 33 this.values.add(((DimensionValueNode)ob).getValue()); 34 }else if(ob instanceof Map.Entry ){ 35 this.values.add(((Map.Entry )((Map.Entry )ob).getValue()).getKey()); 36 } 37 } 38 } 39 40 45 protected boolean accept(SharedFloat value) { 46 48 return false; 49 } 50 51 public Collection operate(ReportResult result) { 52 return values; 53 } 54 55 } 56 | Popular Tags |