001 // $Id: //open/mondrian/src/main/mondrian/olap/fun/CustomizedFunctionTable.java#2 $ 002 package mondrian.olap.fun; 003 004 import java.util.*; 005 006 import mondrian.olap.*; 007 008 /** 009 * Interface to build a customized function table, selecting functions from the set of 010 * supported functions in BuiltInFunTable instance. 011 * 012 * @author Rushan Chen 013 * @version $Id: //open/mondrian/src/main/mondrian/olap/fun/CustomizedFunctionTable.java#2 $ 014 */ 015 public class CustomizedFunctionTable extends FunTableImpl { 016 017 Set<String> supportedBuiltInFunctions; 018 Set<FunDef> specialFunctions; 019 020 public CustomizedFunctionTable(Set<String> buildInFunctions) { 021 supportedBuiltInFunctions = buildInFunctions; 022 this.specialFunctions = new HashSet<FunDef>(); 023 } 024 025 public CustomizedFunctionTable(Set<String> buildInFunctions, Set<FunDef> specialFunctions) { 026 supportedBuiltInFunctions = buildInFunctions; 027 this.specialFunctions = specialFunctions; 028 } 029 030 protected void defineFunctions() { 031 final FunTable builtinFunTable = BuiltinFunTable.instance(); 032 033 // Includes all the keywords form builtin function table 034 for (String reservedWord : builtinFunTable.getReservedWords()) { 035 defineReserved(reservedWord); 036 } 037 038 // Add supported builtin functions 039 for (Resolver resolver : builtinFunTable.getResolvers()) { 040 if (supportedBuiltInFunctions.contains(resolver.getName())) { 041 define(resolver); 042 } 043 } 044 045 // Add special function definitions 046 for (FunDef funDef : specialFunctions) { 047 define(funDef); 048 } 049 } 050 } 051 052 // End CustomizedFunctionTable.java