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) 2006-2010 Pentaho 008// All Rights Reserved. 009*/ 010package mondrian.olap; 011 012import mondrian.olap.type.Type; 013 014/** 015 * Parameter to a Query. 016 * 017 * <p>A parameter is not an expression; see {@link mondrian.mdx.ParameterExpr}. 018 * 019 * @author jhyde 020 * @since Jul 22, 2006 021 */ 022public interface Parameter { 023 /** 024 * Returns the scope where this parameter is defined. 025 * 026 * @return Scope of the parameter 027 */ 028 Scope getScope(); 029 030 /** 031 * Returns the type of this Parameter. 032 * 033 * @return Type of the parameter 034 */ 035 Type getType(); 036 037 /** 038 * Returns the expression which provides the default value for this 039 * Parameter. Never null. 040 * 041 * @return Default value expression of the parameter 042 */ 043 Exp getDefaultExp(); 044 045 /** 046 * Returns the name of this Parameter. 047 * 048 * @return Name of the parameter 049 */ 050 String getName(); 051 052 /** 053 * Returns the description of this Parameter. 054 * 055 * @return Description of the parameter 056 */ 057 String getDescription(); 058 059 /** 060 * Returns whether the value of this Parameter can be modified in a query. 061 * 062 * @return Whether parameter is modifiable 063 */ 064 boolean isModifiable(); 065 066 /** 067 * Returns the value of this parameter. 068 * 069 * <p>If {@link #setValue(Object)} has not been called, returns the default 070 * value of this parameter. 071 * 072 * <p>The type of the value is (depending on the type of the parameter) 073 * a {@link String}, {@link Number}, or {@link Member}. 074 * 075 * @return The value of this parameter 076 */ 077 Object getValue(); 078 079 /** 080 * Sets the value of this parameter. 081 * 082 * @param value Value of the parameter; must be a {@link String}, 083 * a {@link Double}, or a {@link mondrian.olap.Member} 084 */ 085 void setValue(Object value); 086 087 /** 088 * Returns whether the value of this parameter has been set. 089 * 090 * <p>If the value has not been set, this parameter will return its default 091 * value. 092 * 093 * <p>Setting a parameter to {@code null} is not equivalent to unsetting it. 094 * To unset a parameter, call {@link #unsetValue}. 095 * 096 * @return Whether this parameter has been assigned a value 097 */ 098 boolean isSet(); 099 100 /** 101 * Unsets the value of this parameter. 102 * 103 * <p>After calling this method, the parameter will revert to its default 104 * value, as if {@link #setValue(Object)} had not been called, and 105 * {@link #isSet()} will return {@code false}. 106 */ 107 void unsetValue(); 108 109 /** 110 * Scope where a parameter is defined. 111 */ 112 enum Scope { 113 System, 114 Schema, 115 Connection, 116 Statement 117 } 118} 119 120// End Parameter.java