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