1 13 package com.tonbeller.jpivot.mondrian; 14 15 import org.apache.log4j.Logger; 16 17 import com.tonbeller.jpivot.olap.model.NumberFormat; 18 import com.tonbeller.jpivot.olap.model.impl.CellBase; 19 import com.tonbeller.jpivot.util.NumSeparators; 20 21 24 public class MondrianCell extends CellBase { 25 26 static Logger logger = Logger.getLogger(MondrianModel.class); 27 28 private mondrian.olap.Cell monCell; 29 private MondrianModel model; 30 31 private boolean isGrouping = false; 32 private boolean isPercent = false; 33 private int fractionDigits = 0; 34 35 38 protected MondrianCell(mondrian.olap.Cell monCell, MondrianModel model) { 39 this.monCell = monCell; 40 this.model = model; 41 42 65 } 66 67 70 public Object getValue() { 71 return monCell.getValue(); 72 } 73 74 77 public boolean isNull() { 78 return monCell.isNull(); 79 } 80 81 84 public NumberFormat getFormat() { 85 if (monCell.isNull()) 86 return null; 87 88 Object o = monCell.getValue(); 89 if (o instanceof Number ) { 90 } else 92 return null; 93 94 isPercent = formattedValue.indexOf('%') >= 0; 95 NumSeparators sep = NumSeparators.instance(model.getLocale()); 96 97 fractionDigits = 0; 98 if (formattedValue.indexOf(sep.thouSep) >= 0) 99 isGrouping = true; 100 int i = formattedValue.indexOf(sep.decimalSep); 101 if (i > 0) { 102 while (++i < formattedValue.length() && Character.isDigit(formattedValue.charAt(i))) 103 ++fractionDigits; 104 } 105 106 return new NumberFormat() { 107 public boolean isGrouping() { 108 return isGrouping; 109 } 110 111 public int getFractionDigits() { 112 return fractionDigits; 113 } 114 115 public boolean isPercent() { 116 return isPercent; 117 } 118 }; 119 120 } 121 122 125 public mondrian.olap.Cell getMonCell() { 126 return this.monCell; 127 } 128 } | Popular Tags |