Coverage Report - ar.com.fdvs.dj.domain.DjBaseMMValueFormatter
 
Classes in this File Line Coverage Branch Coverage Complexity
DjBaseMMValueFormatter
30%
4/13
0%
0/6
1.8
 
 1  
 package ar.com.fdvs.dj.domain;
 2  
 
 3  
 import ar.com.fdvs.dj.core.DJException;
 4  
 
 5  
 import java.util.Map;
 6  
 
 7  
 /**
 8  
  * FDV Solutions
 9  
  * User: Juan Lagostena
 10  
  * Date: 12/20/11
 11  
  */
 12  
 
 13  
 /**
 14  
  * This class is like a ValueFormatter but with some tricks to get the values and names
 15  
  * of all propertyMeasures in a crosstab
 16  
  */
 17  1
 public abstract class DjBaseMMValueFormatter implements DJValueFormatter {
 18  
 
 19  
     private String[] propertyMeasures;
 20  
 
 21  
     public Object evaluate(Object value, Map fields, Map variables, Map parameters) {
 22  54
         return innerEvaluate((Object[]) value, fields, variables, parameters);
 23  
     }
 24  
 
 25  
     public String[] getPropertyMeasures() {
 26  0
         return propertyMeasures;
 27  
     }
 28  
 
 29  
     public void setPropertyMeasures(String[] propertyMeasures) {
 30  9
         this.propertyMeasures = propertyMeasures;
 31  9
     }
 32  
 
 33  
     public <T> T getValueFor(Object[] values, String propertyMeasure) {
 34  0
         String measureName = null;
 35  0
         int idx = 0;
 36  0
         while (!propertyMeasure.equals(measureName) && idx < this.getPropertyMeasures().length) {
 37  0
             measureName = this.getPropertyMeasures()[idx];
 38  0
             idx++;
 39  
         }
 40  0
         if (!propertyMeasure.equals(measureName)) {
 41  0
             throw new DJException("The measure " + propertyMeasure + " does not exist");
 42  
         }
 43  0
         return (T) values[--idx];
 44  
     }
 45  
 
 46  
     protected abstract Object innerEvaluate(Object[] value, Map fields, Map variables, Map parameters);
 47  
 
 48  
 
 49  
 }