KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportcalculator > DataTreeSubItem


1 package com.calipso.reportgenerator.reportcalculator;
2
3 import com.calipso.reportgenerator.reportcalculator.SharedFloat;
4
5 import java.io.Serializable JavaDoc;
6
7 /**
8  * Representa una hoja del arbol <code>DataTree</code>
9  */

10
11 public class DataTreeSubItem implements Serializable JavaDoc{
12   String JavaDoc[] nonGroupingDimensionValues;
13   SharedFloat[] metricValues;
14   private SharedFloat[] accumulableMetricValues;
15   private int[] adjMetricIndexes;
16
17   /**
18    * Inicializa una instancia de <code>DataTreeSubItem</code>
19    * @param nonGroupingDimensionValues
20    * @param metricValues
21    */

22   public DataTreeSubItem(String JavaDoc[] nonGroupingDimensionValues, int metricCount){//, SharedFloat[] metricValues/*, CubeFloat[] accumulableMetricValues*/) {
23
this.nonGroupingDimensionValues = nonGroupingDimensionValues;
24     this.metricValues = new SharedFloat[metricCount];
25     //this.accumulableMetricValues = accumulableMetricValues;
26
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   /**
36    * Devuelve los valores de las dimensiones que no agrupan.
37    * @return
38    */

39   public String JavaDoc[] getNonGroupingDimensionValues() {
40     return nonGroupingDimensionValues;
41   }
42
43   /**
44    * Devuelve un array con los valores de las metricas.
45    * @return
46    */

47   public SharedFloat[] getMetricValues() {
48     return metricValues;
49   }
50
51   /**
52    * Asigna un array que contiene las metricas acumulables.
53    * @param accumulableMetricValues
54    */

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   /**
64    * Devuelve un array que contiene los valores
65    * de las metricas acumulables.
66    * @return
67    */

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 JavaDoc[] 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