01: /**
02: * Copyright 2008 Jens Dietrich Licensed under the Apache License, Version 2.0 (the "License");
03: * you may not use this file except in compliance with the License.
04: * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
05: * Unless required by applicable law or agreed to in writing, software distributed under the
06: * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
07: * either express or implied. See the License for the specific language governing permissions
08: * and limitations under the License.
09: */package nz.org.take.nscript;
10:
11: import java.util.Map;
12: import nz.org.take.AggregationFunction;
13: import nz.org.take.Function;
14:
15: /**
16: * Factory for functions. Uses the AbstractFactory pattern.
17: * To register additional functions, install a new instance.
18: * It is recommended to subclass the default factory and call super
19: * first in overridden methods.
20: * @author <a href="http://www-ist.massey.ac.nz/JBDietrich/">Jens Dietrich</a>
21: */
22:
23: public abstract class FunctionFactory {
24: protected static FunctionFactory defaultInstance = new DefaultFunctionFactory();
25:
26: public void install() {
27: defaultInstance = this ;
28: }
29:
30: public abstract Function createFunction(String name,
31: Map<String, AggregationFunction> aggregationFunctions,
32: Class... termTypes);
33:
34: public static FunctionFactory getDefaultInstance() {
35: return defaultInstance;
36: }
37: }
|