KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > param > PropertyPrefixParamProvider


1 /*
2  * Created on 14.12.2004
3  */

4 package com.tonbeller.jpivot.param;
5
6 import java.util.List JavaDoc;
7
8 import com.tonbeller.jpivot.olap.model.Member;
9 import com.tonbeller.jpivot.olap.model.Property;
10 import com.tonbeller.wcf.param.SessionParam;
11
12 /**
13  * Default implementation for ParameterProvider. It uses the SqlAccess
14  * Extension of the Olap Model.
15  * @see com.tonbeller.jpivot.param.SqlAccess
16  */

17 public class PropertyPrefixParamProvider extends AbstractParamProvider {
18   String JavaDoc propertyPrefix;
19
20   /**
21    * creates a collection of SessionParam from member properties. Every member property,
22    * whose name starts with <code>propertyPrefix</code> will create a SessionParam.
23    * The name of the SessionParam is the rest of the property name after the
24    * prefix, the SQL value is the value of the property, the MDX value will be
25    * the member.
26    *
27    * @see com.tonbeller.jpivot.param.SqlAccess
28    * @see com.tonbeller.wcf.param.SessionParam
29    *
30    * @param propertyPrefix the prefix of the properties that become SessionParam's.
31    */

32   public PropertyPrefixParamProvider(String JavaDoc propertyPrefix) {
33     this.propertyPrefix = propertyPrefix;
34   }
35
36   protected void addMemberParams(List JavaDoc list, SqlAccess sa, Member member) {
37     int prefixLength = propertyPrefix.length();
38     Property[] p = member.getProperties();
39     for (int i = 0; i < p.length; i++) {
40       String JavaDoc propertyName = p[i].getName();
41       if (!propertyName.startsWith(propertyPrefix))
42         continue;
43       String JavaDoc paramName = propertyName.substring(prefixLength);
44       SessionParam sp = sa.createParameter(member, paramName, propertyName);
45       if (sp != null) // !calculated, !all
46
list.add(sp);
47     }
48   }
49
50 }
Popular Tags