KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > olap > query > QuaxUti


1 /*
2  * ====================================================================
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) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13
14 package com.tonbeller.jpivot.olap.query;
15
16 import mondrian.olap.Exp;
17
18 import java.util.List JavaDoc;
19
20 import com.tonbeller.jpivot.olap.model.Dimension;
21 import com.tonbeller.jpivot.olap.model.Hierarchy;
22 import com.tonbeller.jpivot.olap.model.Level;
23 import com.tonbeller.jpivot.olap.model.Member;
24
25 public interface QuaxUti {
26   static final int FUNTYPE_FUNCTION = 0;
27   static final int FUNTYPE_PROPERTY = 1;
28   static final int FUNTYPE_BRACES = 2;
29   static final int FUNTYPE_TUPLE = 3;
30   static final int FUNTYPE_INFIX = 4;
31
32   /**
33    * @param oExp
34    * @return true if oExp is a member expression
35    */

36   boolean isMember(Object JavaDoc oExp);
37
38   /**
39    * @param oExp
40    * @return true if oExp is a FunCall expression
41    */

42   boolean isFunCall(Object JavaDoc oExp);
43
44   /**
45    * @param oExp
46    * @param member
47    * @return true if oExp is equal to member
48    */

49   boolean equalMember(Object JavaDoc oExp, Member member);
50
51   /**
52    * @param oExp
53    * @param function
54    * @return true if oExp is a specific function call
55    */

56   boolean isFunCallTo(Object JavaDoc oExp, String JavaDoc function);
57
58   /**
59     * check, whether member is parent of other member
60     * @param pMember (parent)
61     * @param cMember (child)
62     * @return true if cMember (2.arg) is child of pMember (1.arg)
63     */

64    boolean checkParent(Member pMember, Object JavaDoc cMembObj);
65
66    /**
67     * check, whether member is child of other member
68     * @param pMember (child)
69     * @param cMember (parent)
70     * @return true if cMember (1.arg) is child of pMember (2.arg)
71     */

72    boolean checkChild(Member cMember, Object JavaDoc pMembObj);
73
74   /**
75    * check, whether member is descendant of other member
76    * @param aMember (ancestor)
77    * @param dMember (descendant)
78    * @return true if dMember (2.arg) is descendant of aMember (1.arg)
79    */

80   boolean checkDescendantM(Member aMember, Member dMember);
81
82
83   /**
84    * check, whether member object is descendant of member
85    * @param aMember (ancestor)
86    * @param oMember (descendant member object)
87    * @return true if 2.arg is descendant of 1.arg
88    */

89   boolean checkDescendantO(Member aMember, Object JavaDoc oMember);
90
91   /**
92    * check, whether funcall set contains member
93    * @param f
94    * @param m
95    * @return true if FunCall contains member
96    */

97   boolean isMemberInFunCall(Object JavaDoc oExp, Member member) throws Quax.CannotHandleException;
98
99   /**
100    * check, whether a funcall set contains any child of a specific member
101    * @param oExp - funcall
102    * @param member
103    * @return true, if FunCall contains member's child
104    * @throws Quax.CannotHandleException
105    */

106   boolean isChildOfMemberInFunCall(Object JavaDoc oExp, Member member) throws Quax.CannotHandleException;
107
108   /**
109    * check, whether funcall set contains descendant of a specific member
110    * @param f
111    * @param m
112    * @return true if FunCall contains descendant of member
113    */

114   boolean isDescendantOfMemberInFunCall(Object JavaDoc oExp, Member member)
115     throws Quax.CannotHandleException;
116
117   /**
118    * check whether a Funcall does NOT resolve to top level of hierarchy
119    * @param oExp - FunCall Exp
120    * @return true, if any member of the set defined by funcall is NOT top level
121    */

122   boolean isFunCallNotTopLevel(Object JavaDoc oExp) throws Quax.CannotHandleException;
123
124   /**
125    * check, whether a member is on top level (has no parent);
126    * @param m - member to be checked
127    * @return true - if member is on top level
128    */

129   boolean isMemberOnToplevel(Object JavaDoc oMem);
130
131   /**
132     * check a Funcall expression whether we can handle it.
133     * currently we can basically handle following FunCalls
134     * member.children, member.descendants, level.members
135     */

136   boolean canHandle(Object JavaDoc oExp);
137
138   Member getParentMember(Object JavaDoc oExp);
139   Member memberForObj(Object JavaDoc oExp);
140
141   Hierarchy hierForMember(Member member);
142   Dimension dimForMember(Member member);
143   StringBuffer JavaDoc funString(Object JavaDoc oExp);
144   String JavaDoc getMemberUniqueName(Object JavaDoc oExp);
145
146   /**
147    * Expression Object for member
148    * @param member
149    * @return Expression Object
150    */

151   Object JavaDoc objForMember(Member member);
152
153   /**
154    * Expression Object for Dimension
155    * @param member
156    * @return Expression Object
157    */

158   Object JavaDoc objForDim(Dimension dim);
159
160   String JavaDoc memberString(Member[] mPath);
161
162   /**
163     * generate an object for a list of members
164     * @param mList list of members
165     * @return null for empty lis, single member or set function otherwise
166     */

167   Object JavaDoc createMemberSet(List JavaDoc mList);
168
169
170   /**
171    * level depth for member
172    * @param oExp - member
173    * @return depth
174    */

175   int levelDepthForMember(Object JavaDoc oExp);
176
177   /**
178    * @param oExp
179    * @return hierarchy for Exp
180    * @throws Quax.CannotHandleException
181    */

182   Hierarchy hierForExp(Object JavaDoc oExp) throws Quax.CannotHandleException;
183
184   /**
185    * @param hier - the Hierarchy
186    * @param expandAllMember - if true, an "All" member will be expanded
187    * @return a set for the top level members of an hierarchy
188    */

189   Object JavaDoc topLevelMembers(Hierarchy hier, boolean expandAllMember );
190
191   /**
192    * generation of FunCalls
193    * @param function name
194    * @param args arguments
195    * @param funType FUNTYPE
196    * @return function object
197    */

198    Object JavaDoc createFunCall(String JavaDoc function, Object JavaDoc[] args, int funType);
199
200   /**
201    * get number of funCall arguments
202    * @param oFun funcall expression
203    * @return number of args
204    */

205   int funCallArgCount(Object JavaDoc oFun);
206
207   /**
208    * get funcall name
209    * @param oFun funcall expression
210    * @return function name
211    */

212   String JavaDoc funCallName (Object JavaDoc oFun);
213
214   /**
215    * get funcall argument
216    * @param oFun funcall expression
217    * @param i - index of argument
218    * @return argument object
219    */

220   Object JavaDoc funCallArg(Object JavaDoc oExp, int index);
221
222   /**
223    * determine the children of a member object
224    * @param oMember
225    * @return
226    */

227   Object JavaDoc[] getChildren(Object JavaDoc oMember);
228
229   /**
230    * get the members of a level
231    */

232   Object JavaDoc[] getLevelMembers(Level level);
233
234   void addMemberUncles(List JavaDoc list, Member m, int[] maxLevel);
235   void addMemberSiblings(List JavaDoc list, Member m, int[] maxLevel);
236   void addMemberChildren(List JavaDoc list, Member m, int[] maxLevel);
237   void addMemberDescendants(List JavaDoc list, Member m, Level lev, int[] maxLevel);
238   void addLevelMembers(List JavaDoc list, Level lev, int[] maxLevel);
239   Level LevelForObj(Object JavaDoc oLevel);
240   Level getParentLevel(Level lev);
241
242   /**
243    * Converts an object to an expression.
244    * In particular, adds expression wrappers ({@link mondrian.mdx.MemberExpr},
245    * etc.) to olap elements ({@link Member}, etc.).
246    *
247    * @param o Object, which may or may not be an expression
248    * @return An expression
249    */

250   Exp toExp(Object JavaDoc o);
251
252 } // QuaxUti
253
Popular Tags