KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > rolap > MemberSource


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/rolap/MemberSource.java#8 $
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) 2001-2002 Kana Software, Inc.
7 // Copyright (C) 2001-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, 21 December, 2001
12 */

13
14 package mondrian.rolap;
15
16 import java.util.List JavaDoc;
17
18 /**
19  * A <code>MemberSource</code> has the basic operations to read the members of a
20  * {@link RolapHierarchy hierarchy}.
21  *
22  * <p>A <code>MemberSource</code> may optionally support writeback to a
23  * {@link MemberCache}. During the initialization of a
24  * <code>MemberSource</code>, the consumer calls {@link #setCache}; the return
25  * value indicates whether the <code>MemberSource</code> supports
26  * cache-writeback.
27  *
28  * <p>A <dfn>custom member reader</dfn> is a user-defined class which implements
29  * the operations to retrieve members. It either implements the
30  * <code>MemberSource</code> interface, or the derived interface
31  * {@link MemberReader}, which has more operations. In addition to the interface
32  * methods, the class must have a constructor which takes parameters
33  * <code>({@link RolapHierarchy}, {@link java.util.Properties})</code> and
34  * throws no exceptions. To declare a hierarchy based upon the class, use the
35  * <code>memberReaderClass</code> attribute of the
36  * <code>&lt;Hierarchy&gt;</code> element in your XML schema file; the
37  * <code>properties</code> constructor parameter is populated from any
38  * <ocde>&lt;Param name="..." value="..."&gt;</code> child elements.
39  *
40  * @see MemberReader
41  * @see MemberCache
42  *
43  * @author jhyde
44  * @since 21 December, 2001
45  * @version $Id: //open/mondrian/src/main/mondrian/rolap/MemberSource.java#8 $
46  */

47 public interface MemberSource {
48     /**
49      * Returns the hierarchy that this source is reading for.
50      */

51     RolapHierarchy getHierarchy();
52     /**
53      * Sets the cache which this <code>MemberSource</code> will write to.
54      *
55      * <p>Cache-writeback is optional (for example, {@link SqlMemberSource}
56      * supports it, and {@link ArrayMemberSource} does not), and the return
57      * value from this method indicates whether this object supports it.
58      *
59      * <p>If this method returns <code>true</code>, the {@link #getMembers},
60      * {@link #getRootMembers} and {@link #getMemberChildren} methods must
61      * write to the cache, in addition to returning members as a return value.
62      *
63      * @param cache The <code>MemberCache</code> which the caller would like
64      * this <code>MemberSource</code> to write to.
65      * @return Whether this <code>MemberSource</code> supports cache-writeback.
66      */

67     boolean setCache(MemberCache cache);
68     /**
69      * Returns all members of this hierarchy, sorted by ordinal.
70      *
71      * <p>If this object {@link #setCache supports cache-writeaback}, also
72      * writes these members to the cache.
73      */

74     RolapMember[] getMembers();
75     /**
76      * Returns all members of this hierarchy which do not have a parent,
77      * sorted by ordinal.
78      *
79      * <p>If this object {@link #setCache supports cache-writeback}, also
80      * writes these members to the cache.
81      *
82      * @return {@link List} of {@link RolapMember}s
83      */

84     List JavaDoc<RolapMember> getRootMembers();
85
86     /**
87      * Writes all children <code>parentMember</code> to <code>children</code>.
88      *
89      * <p>If this object {@link #setCache supports cache-writeback}, also
90      * writes these members to the cache.
91      */

92     void getMemberChildren(
93         RolapMember parentMember,
94         List JavaDoc<RolapMember> children);
95
96     /**
97      * Returns all members which are a child of one of the members in
98      * <code>parentMembers</code>, sorted by ordinal.
99      *
100      * <p>If this object {@link #setCache supports cache-writeaback}, also
101      * writes these members to the cache.
102      */

103     void getMemberChildren(
104         List JavaDoc<RolapMember> parentMembers,
105         List JavaDoc<RolapMember> children);
106
107     /**
108      * Returns an estimate of number of members in this hierarchy.
109      */

110     int getMemberCount();
111
112     /**
113      * Finds a member based upon its unique name.
114      */

115     RolapMember lookupMember(String JavaDoc[] uniqueNameParts, boolean failIfNotFound);
116 }
117
118 // End MemberSource.java
119
Popular Tags