1 package com.calipso.reportgenerator.reportcalculator; 2 3 import com.calipso.reportgenerator.reportcalculator.SharedFloat; 4 5 import java.io.Serializable ; 6 7 10 11 public class DataTreeSubItem implements Serializable { 12 String [] nonGroupingDimensionValues; 13 SharedFloat[] metricValues; 14 private SharedFloat[] accumulableMetricValues; 15 private int[] adjMetricIndexes; 16 17 22 public DataTreeSubItem(String [] nonGroupingDimensionValues, int metricCount){ this.nonGroupingDimensionValues = nonGroupingDimensionValues; 24 this.metricValues = new SharedFloat[metricCount]; 25 initialize(); 27 } 28 29 private void initialize() { 30 for (int i = 0; i < metricValues.length; i++) { 31 metricValues[i] = SharedFloat.newFrom(0); 32 } 33 } 34 35 39 public String [] getNonGroupingDimensionValues() { 40 return nonGroupingDimensionValues; 41 } 42 43 47 public SharedFloat[] getMetricValues() { 48 return metricValues; 49 } 50 51 55 public void setAccumulableMetricValues(SharedFloat[] accumulableMetricValues) { 56 this.accumulableMetricValues = accumulableMetricValues; 57 } 58 59 public void setAdjMetricIndexes(int[] adjMetricIndexes){ 60 this.adjMetricIndexes = adjMetricIndexes; 61 } 62 63 68 public SharedFloat[] getAccumulableMetricValues() { 69 if (accumulableMetricValues == null) { 70 return new SharedFloat[0]; 71 } 72 return accumulableMetricValues; 73 } 74 75 public int getMetricIndex(int index) { 76 if (adjMetricIndexes != null && adjMetricIndexes.length > index ){ 77 return adjMetricIndexes[index]; 78 } 79 else { 80 return index; 81 } 82 83 } 84 85 public boolean matches(String [] noGroupDimValues) { 86 for(int i=0; i<noGroupDimValues.length && i<nonGroupingDimensionValues.length; i++){ 87 if(!nonGroupingDimensionValues[i].equalsIgnoreCase(noGroupDimValues[i])){ 88 return false; 89 } 90 } 91 return true; 92 } 93 94 public void updateMetricValues(SharedFloat[] newMetricValues) { 95 for (int i = 0; i < metricValues.length; i++) { 96 metricValues[i] = metricValues[i].add(newMetricValues[i]); 97 } 98 } 99 100 } 101 | Popular Tags |