001 /*
002 // $Id: //open/mondrian-release/3.1/src/main/mondrian/olap/Member.java#3 $
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-2009 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 enum MemberType {
065 UNKNOWN,
066 REGULAR, // adMemberRegular
067 ALL,
068 MEASURE,
069 FORMULA,
070 /**
071 * This member is its hierarchy's NULL member (such as is returned by
072 * <code>[Gender].[All Gender].PrevMember</code>, for example).
073 */
074 NULL
075 }
076
077 /**
078 * Only allowable if the member is part of the <code>WITH</code> clause of
079 * a query.
080 */
081 void setName(String name);
082
083 /** Returns whether this is the 'all' member. */
084 boolean isAll();
085
086 /** Returns whether this is a member of the measures dimension. */
087 boolean isMeasure();
088
089 /** Returns whether this is the 'null member'. */
090 boolean isNull();
091
092 /**
093 * Returns whether <code>member</code> is equal to, a child, or a
094 * descendent of this <code>Member</code>.
095 */
096 boolean isChildOrEqualTo(Member member);
097
098 /** Returns whether this member is computed using either a <code>with
099 * member</code> clause in an mdx query or a calculated member defined in
100 * cube. */
101 boolean isCalculated();
102
103 /**
104 * Returns whether this member should be evaluated within the Evaluator.
105 *
106 * <p>Normally {@link #isCalculated} and {@link #isEvaluated} should return
107 * the same value, but in situations where mondrian would like to treat the
108 * two concepts separately such in role based security, these values may
109 * differ.
110 *
111 * @return true if evaluated
112 */
113 boolean isEvaluated();
114 int getSolveOrder();
115 Exp getExpression();
116
117 /**
118 * Returns a list of the ancestor members of this member.
119 */
120 List<Member> getAncestorMembers();
121
122 /**
123 * Returns whether this member is computed from a {@code WITH MEMBER}
124 * clause in an MDX query.
125 */
126 boolean isCalculatedInQuery();
127
128 /**
129 * Returns the value of the property named <code>propertyName</code>.
130 * Name match is case-sensitive.
131 */
132 Object getPropertyValue(String propertyName);
133
134 /**
135 * Returns the value of the property named <code>propertyName</code>,
136 * matching according to the required case-sensitivity.
137 */
138 Object getPropertyValue(String propertyName, boolean matchCase);
139
140 /**
141 * Returns the formatted value of the property named
142 * <code>propertyName</code>.
143 */
144 String getPropertyFormattedValue(String propertyName);
145
146 /**
147 * Sets a property of this member to a given value.
148 */
149 void setProperty(String name, Object value);
150
151 /**
152 * Returns the definitions of the properties this member may have.
153 */
154 Property[] getProperties();
155
156 /**
157 * Returns the ordinal of the member.
158 */
159 int getOrdinal();
160
161 /**
162 * Returns the order key of the member (relative to its siblings);
163 * null if undefined or unavailable.
164 */
165 Comparable getOrderKey();
166
167 /**
168 * Returns whether this member is 'hidden', as per the rules which define
169 * a ragged hierarchy.
170 */
171 boolean isHidden();
172
173 /**
174 * returns the depth of this member, which is not the level's depth
175 * in case of parent child dimensions
176 * @return depth
177 */
178 int getDepth();
179
180 /**
181 * Returns the system-generated data member that is associated with a
182 * nonleaf member of a dimension.
183 *
184 * <p>Returns this member if this member is a leaf member, or if the
185 * nonleaf member does not have an associated data member.</p>
186 */
187 Member getDataMember();
188 }
189
190 // End Member.java