001 /*
002 // $Id: //open/mondrian-release/3.2/src/main/mondrian/olap/Member.java#2 $
003 // This software is subject to the terms of the Eclipse Public License v1.0
004 // Agreement, available at the following URL:
005 // http://www.eclipse.org/legal/epl-v10.html.
006 // Copyright (C) 1999-2002 Kana Software, Inc.
007 // Copyright (C) 2001-2010 Julian Hyde and others
008 // All Rights Reserved.
009 // You must accept the terms of that agreement to use this software.
010 //
011 // jhyde, 2 March, 1999
012 */
013
014 package mondrian.olap;
015
016 import java.util.List;
017
018 /**
019 * A <code>Member</code> is a 'point' on a dimension of a cube. Examples are
020 * <code>[Time].[1997].[January]</code>,
021 * <code>[Customer].[All Customers]</code>,
022 * <code>[Customer].[USA].[CA]</code>,
023 * <code>[Measures].[Unit Sales]</code>.
024 *
025 * <p> Every member belongs to a {@link Level} of a {@link Hierarchy}. Members
026 * except the root member have a parent, and members not at the leaf level
027 * have one or more children.
028 *
029 * <p> Measures are a special kind of member. They belong to their own
030 * dimension, <code>[Measures]</code>.
031 *
032 * <p> There are also special members representing the 'All' value of a
033 * hierarchy, the null value, and the error value.
034 *
035 * <p> Members can have member properties. Their {@link Level#getProperties}
036 * defines which are allowed.
037 */
038 public interface Member extends OlapElement, Comparable, Annotated {
039
040 /**
041 * Returns this member's parent, or null (not the 'null member', as
042 * returned by {@link Hierarchy#getNullMember}) if it has no parent.
043 *
044 * <p>In an access-control context, a member may have no <em>visible</em>
045 * parents, so use {@link SchemaReader#getMemberParent}.
046 */
047 Member getParentMember();
048
049 Level getLevel();
050
051 Hierarchy getHierarchy();
052
053 /**
054 * Returns name of parent member, or empty string (not null) if we are the
055 * root.
056 */
057 String getParentUniqueName();
058
059 /**
060 * Returns the type of member.
061 */
062 MemberType getMemberType();
063
064 boolean isParentChildLeaf();
065
066 enum MemberType {
067 UNKNOWN,
068 REGULAR, // adMemberRegular
069 ALL,
070 MEASURE,
071 FORMULA,
072 /**
073 * This member is its hierarchy's NULL member (such as is returned by
074 * <code>[Gender].[All Gender].PrevMember</code>, for example).
075 */
076 NULL
077 }
078
079 /**
080 * Only allowable if the member is part of the <code>WITH</code> clause of
081 * a query.
082 */
083 void setName(String name);
084
085 /** Returns whether this is the 'all' member. */
086 boolean isAll();
087
088 /** Returns whether this is a member of the measures dimension. */
089 boolean isMeasure();
090
091 /** Returns whether this is the 'null member'. */
092 boolean isNull();
093
094 /**
095 * Returns whether <code>member</code> is equal to, a child, or a
096 * descendent of this <code>Member</code>.
097 */
098 boolean isChildOrEqualTo(Member member);
099
100 /** Returns whether this member is computed using either a <code>with
101 * member</code> clause in an mdx query or a calculated member defined in
102 * cube. */
103 boolean isCalculated();
104
105 /**
106 * Returns whether this member should be evaluated within the Evaluator.
107 *
108 * <p>Normally {@link #isCalculated} and {@link #isEvaluated} should return
109 * the same value, but in situations where mondrian would like to treat the
110 * two concepts separately such in role based security, these values may
111 * differ.
112 *
113 * @return true if evaluated
114 */
115 boolean isEvaluated();
116 int getSolveOrder();
117 Exp getExpression();
118
119 /**
120 * Returns a list of the ancestor members of this member.
121 *
122 * @deprecated Use
123 * {@link SchemaReader#getMemberAncestors(Member, java.util.List)}.
124 */
125 List<Member> getAncestorMembers();
126
127 /**
128 * Returns whether this member is computed from a {@code WITH MEMBER}
129 * clause in an MDX query.
130 */
131 boolean isCalculatedInQuery();
132
133 /**
134 * Returns the value of the property named <code>propertyName</code>.
135 * Name match is case-sensitive.
136 */
137 Object getPropertyValue(String propertyName);
138
139 /**
140 * Returns the value of the property named <code>propertyName</code>,
141 * matching according to the required case-sensitivity.
142 */
143 Object getPropertyValue(String propertyName, boolean matchCase);
144
145 /**
146 * Returns the formatted value of the property named
147 * <code>propertyName</code>.
148 */
149 String getPropertyFormattedValue(String propertyName);
150
151 /**
152 * Sets a property of this member to a given value.
153 */
154 void setProperty(String name, Object value);
155
156 /**
157 * Returns the definitions of the properties this member may have.
158 */
159 Property[] getProperties();
160
161 /**
162 * Returns the ordinal of the member.
163 */
164 int getOrdinal();
165
166 /**
167 * Returns the order key of the member (relative to its siblings);
168 * null if undefined or unavailable.
169 */
170 Comparable getOrderKey();
171
172 /**
173 * Returns whether this member is 'hidden', as per the rules which define
174 * a ragged hierarchy.
175 */
176 boolean isHidden();
177
178 /**
179 * returns the depth of this member, which is not the level's depth
180 * in case of parent child dimensions
181 * @return depth
182 */
183 int getDepth();
184
185 /**
186 * Returns the system-generated data member that is associated with a
187 * nonleaf member of a dimension.
188 *
189 * <p>Returns this member if this member is a leaf member, or if the
190 * nonleaf member does not have an associated data member.</p>
191 */
192 Member getDataMember();
193 }
194
195 // End Member.java