KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > olap > fun > SimpleResolver


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/fun/SimpleResolver.java#15 $
3 // This software is subject to the terms of the Common Public License
4 // Agreement, available at the following URL:
5 // http://www.opensource.org/licenses/cpl.html.
6 // Copyright (C) 2002-2002 Kana Software, Inc.
7 // Copyright (C) 2002-2006 Julian Hyde and others
8 // All Rights Reserved.
9 // You must accept the terms of that agreement to use this software.
10 //
11 // jhyde, 3 March, 2002
12 */

13 package mondrian.olap.fun;
14
15 import mondrian.olap.*;
16
17 /**
18  * A <code>SimpleResolver</code> resolves a single, non-overloaded function.
19  *
20  * @author jhyde
21  * @since 3 March, 2002
22  * @version $Id: //open/mondrian/src/main/mondrian/olap/fun/SimpleResolver.java#15 $
23  */

24 class SimpleResolver implements Resolver {
25     private final FunDef funDef;
26
27     SimpleResolver(FunDef funDef) {
28         this.funDef = funDef;
29     }
30
31     public FunDef getFunDef() {
32         return funDef;
33     }
34
35     public String JavaDoc getName() {
36         return funDef.getName();
37     }
38
39     public String JavaDoc getDescription() {
40         return funDef.getDescription();
41     }
42
43     public String JavaDoc getSignature() {
44         return funDef.getSignature();
45     }
46
47     public Syntax getSyntax() {
48         return funDef.getSyntax();
49     }
50
51     public String JavaDoc[] getReservedWords() {
52         return FunUtil.emptyStringArray;
53     }
54
55     public FunDef resolve(
56             Exp[] args, Validator validator, int[] conversionCount) {
57         int[] parameterTypes = funDef.getParameterCategories();
58         if (parameterTypes.length != args.length) {
59             return null;
60         }
61         for (int i = 0; i < args.length; i++) {
62             if (!validator.canConvert(
63                     args[i], parameterTypes[i], conversionCount)) {
64                 return null;
65             }
66         }
67         return funDef;
68     }
69
70     public boolean requiresExpression(int k) {
71         int[] parameterTypes = funDef.getParameterCategories();
72         return ((k >= parameterTypes.length) ||
73                (parameterTypes[k] != Category.Set));
74     }
75 }
76
77 // End SimpleResolver.java
78
Popular Tags