001/*
002// $Id: Measure.java 482 2012-01-05 23:27:27Z jhyde $
003//
004// Licensed to Julian Hyde under one or more contributor license
005// agreements. See the NOTICE file distributed with this work for
006// additional information regarding copyright ownership.
007//
008// Julian Hyde licenses this file to you under the Apache License,
009// Version 2.0 (the "License"); you may not use this file except in
010// compliance with the License. You may obtain a copy of the License at:
011//
012// http://www.apache.org/licenses/LICENSE-2.0
013//
014// Unless required by applicable law or agreed to in writing, software
015// distributed under the License is distributed on an "AS IS" BASIS,
016// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017// See the License for the specific language governing permissions and
018// limitations under the License.
019*/
020package org.olap4j.metadata;
021
022/**
023 * Data value of primary interest to the user browsing the cube.
024 *
025 * <p>A <code>Measure</code> provides the value of each cell, and is usually
026 * numeric. Every measure is a member of a special dimension called "Measures".
027 *
028 * @author jhyde
029 * @version $Id: Measure.java 482 2012-01-05 23:27:27Z jhyde $
030 * @since Oct 13, 2006
031 */
032public interface Measure extends Member {
033    /**
034     * Returns the Aggregator of this Measure.
035     *
036     * @return Aggregator
037     */
038    Aggregator getAggregator();
039
040    /**
041     * Returns the data type of this Measure.
042     *
043     * @return data type
044     */
045    Datatype getDatatype();
046
047    /**
048     * Returns whether this Measure is visible.
049     *
050     * @return whether this Measure is visible
051     */
052    boolean isVisible();
053
054    /**
055     * Enumeration of the aggregate functions which can be used to derive a
056     * <code>Measure</code>.
057     *
058     * <p>The values are as specified by XMLA.
059     * For example, XMLA specifies MDMEASURE_AGGR_SUM with ordinal 1,
060     * which corresponds to the value {@link #SUM},
061     * whose {@link #xmlaOrdinal} is 1.
062     */
063    enum Aggregator implements XmlaConstant {
064        /**
065         * Identifies that the measure was derived using the
066         * SUM aggregation function.
067         */
068        SUM(1),
069        /**
070         * Identifies that the measure was derived using the
071         * COUNT aggregation function.
072         */
073        COUNT(2),
074        /**
075         * Identifies that the measure was derived using the
076         * MIN aggregation function.
077         */
078        MIN(3),
079        /**
080         * Identifies that the measure was derived using the
081         * MAX aggregation function.
082         */
083        MAX(4),
084        /**
085         * Identifies that the measure was derived using the
086         * AVG aggregation function.
087         */
088        AVG(5),
089        /**
090         * Identifies that the measure was derived using the
091         * VAR aggregation function.
092         */
093        VAR(6),
094        /**
095         * Identifies that the measure was derived using the
096         * STDEV aggregation function.
097         */
098        STD(7),
099        /**
100         * Identifies that the measure was derived from a formula that was not
101         * any single function above.
102         */
103        CALCULATED(127),
104
105        /**
106        * Identifies that the measure was derived from an unknown aggregation
107        * function or formula.
108         */
109        UNKNOWN(0);
110
111        private final int xmlaOrdinal;
112        private static final DictionaryImpl<Aggregator> DICTIONARY =
113            DictionaryImpl.forClass(Aggregator.class);
114
115        /**
116         * Creates an Aggregator.
117         *
118         * @param xmlaOrdinal Ordinal of the aggregator in the XMLA
119         * specification
120         */
121        private Aggregator(int xmlaOrdinal) {
122            this.xmlaOrdinal = xmlaOrdinal;
123        }
124
125        public String xmlaName() {
126            return "MDMEASURE_AGGR_" + name();
127        }
128
129        public String getDescription() {
130            return "";
131        }
132
133        public int xmlaOrdinal() {
134            return xmlaOrdinal;
135        }
136
137        /**
138         * Per {@link org.olap4j.metadata.XmlaConstant}, returns a dictionary
139         * of all values of this enumeration.
140         *
141         * @return Dictionary of all values
142         */
143        public static Dictionary<Aggregator> getDictionary() {
144            return DICTIONARY;
145        }
146    }
147}
148
149// End Measure.java