001/* 002// This software is subject to the terms of the Eclipse Public License v1.0 003// Agreement, available at the following URL: 004// http://www.eclipse.org/legal/epl-v10.html. 005// You must accept the terms of that agreement to use this software. 006// 007// Copyright (C) 2001-2005 Julian Hyde 008// Copyright (C) 2005-2011 Pentaho and others 009// All Rights Reserved. 010*/ 011package mondrian.rolap; 012 013import mondrian.olap.MondrianDef; 014import mondrian.olap.Property; 015import mondrian.spi.PropertyFormatter; 016 017import org.apache.log4j.Logger; 018 019/** 020 * <code>RolapProperty</code> is the definition of a member property. 021 * 022 * @author jhyde 023 */ 024class RolapProperty extends Property { 025 026 private static final Logger LOGGER = Logger.getLogger(RolapProperty.class); 027 028 /** Array of RolapProperty of length 0. */ 029 static final RolapProperty[] emptyArray = new RolapProperty[0]; 030 031 private final PropertyFormatter formatter; 032 private final String caption; 033 private final boolean dependsOnLevelValue; 034 035 /** The column or expression which yields the property's value. */ 036 private final MondrianDef.Expression exp; 037 038 039 /** 040 * Creates a RolapProperty. 041 * 042 * @param name Name of property 043 * @param type Datatype 044 * @param exp Expression for property's value; often a literal 045 * @param formatter A property formatter, or null 046 * @param caption Caption 047 * @param dependsOnLevelValue Whether the property is functionally dependent 048 * on the level with which it is associated 049 * @param internal Whether property is internal 050 */ 051 RolapProperty( 052 String name, 053 Datatype type, 054 MondrianDef.Expression exp, 055 PropertyFormatter formatter, 056 String caption, 057 Boolean dependsOnLevelValue, 058 boolean internal, 059 String description) 060 { 061 super(name, type, -1, internal, false, false, description); 062 this.exp = exp; 063 this.caption = caption; 064 this.formatter = formatter; 065 this.dependsOnLevelValue = 066 dependsOnLevelValue != null && dependsOnLevelValue; 067 } 068 069 MondrianDef.Expression getExp() { 070 return exp; 071 } 072 073 public PropertyFormatter getFormatter() { 074 return formatter; 075 } 076 077 /** 078 * @return Returns the caption. 079 */ 080 public String getCaption() { 081 if (caption == null) { 082 return getName(); 083 } 084 return caption; 085 } 086 087 /** 088 * @return <p>Returns the dependsOnLevelValue setting (if unset, 089 * returns false). This indicates whether the property is 090 * functionally dependent on the level with which it is 091 * associated.</p> 092 * 093 * <p>If true, then the property column can be eliminated from 094 * the GROUP BY clause for queries on certain databases such 095 * as MySQL.</p> 096 */ 097 public boolean dependsOnLevelValue() { 098 return dependsOnLevelValue; 099 } 100} 101 102// End RolapProperty.java