1 13 package mondrian.rolap; 14 15 import java.lang.reflect.Constructor ; 16 17 import mondrian.olap.MondrianDef; 18 import mondrian.olap.Property; 19 import mondrian.olap.PropertyFormatter; 20 import mondrian.olap.Util; 21 22 import org.apache.log4j.Logger; 23 24 27 class RolapProperty extends Property { 28 29 private static final Logger LOGGER = Logger.getLogger(RolapProperty.class); 30 31 32 static final RolapProperty[] emptyArray = new RolapProperty[0]; 33 34 private final PropertyFormatter formatter; 35 private final String caption; 36 37 38 private final MondrianDef.Expression exp; 39 40 41 44 RolapProperty( 45 String name, 46 Datatype type, 47 MondrianDef.Expression exp, 48 String formatterDef, 49 String caption) { 50 super(name, type, -1, false, false, false, null); 51 this.exp = exp; 52 this.caption = caption; 53 this.formatter = makePropertyFormatter(formatterDef); 54 55 } 56 private PropertyFormatter makePropertyFormatter(String formatterDef) { 57 if (!Util.isEmpty(formatterDef)) { 58 try { 60 Class <PropertyFormatter> clazz = 61 (Class <PropertyFormatter>) Class.forName(formatterDef); 62 Constructor <PropertyFormatter> ctor = clazz.getConstructor(); 63 return ctor.newInstance(); 64 } catch (Exception e) { 65 StringBuilder buf = new StringBuilder (64); 66 buf.append("RolapProperty.makePropertyFormatter: "); 67 buf.append("Could not create PropertyFormatter from"); 68 buf.append("formatterDef \""); 69 buf.append(formatterDef); 70 buf.append("\""); 71 LOGGER.error(buf.toString(), e); 72 } 73 } 74 return null; 75 } 76 77 MondrianDef.Expression getExp() { 78 return exp; 79 } 80 81 public PropertyFormatter getFormatter() { 82 return formatter; 83 } 84 85 88 public String getCaption() { 89 if (caption == null) { 90 return getName(); 91 } 92 return caption; 93 } 94 } 95 96 | Popular Tags |