001/*
002// $Id: Type.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.type;
021
022import org.olap4j.metadata.*;
023
024/**
025 * Type of an MDX expression.
026 *
027 * <p>All type objects are immutable.
028 *
029 * @author jhyde
030 * @since Feb 17, 2005
031 * @version $Id: Type.java 482 2012-01-05 23:27:27Z jhyde $
032 */
033public interface Type {
034    /**
035     * Returns whether this type contains a given dimension.<p/>
036     *
037     * For example:
038     * <ul>
039     * <li><code>DimensionType([Gender])</code> uses only the
040     *     <code>[Gender]</code> dimension.</li>
041     * <li><code>TupleType(MemberType([Gender]), MemberType([Store]))</code>
042     *     uses <code>[Gender]</code>  and <code>[Store]</code>
043     *     dimensions.</li>
044     * </ul><p/>
045     *
046     * The <code>maybe</code> parameter comes into play when the
047     * dimensional information is incomplete. For example, when applied to
048     * <code>TupleType(MemberType(null), MemberType([Store]))</code>,
049     * <code>usesDimension([Gender], false)</code> returns true because it
050     * is possible that the expression returns a member of the
051     * <code>[Gender]</code> dimension.
052     *
053     * @param dimension Dimension
054     * @param maybe If true, returns true only if this type definitely
055     *    uses the dimension
056     *
057     * @return whether this type definitely (or if <code>maybe</code> is true,
058     * possibly) uses the given dimension
059     */
060    boolean usesDimension(Dimension dimension, boolean maybe);
061
062    /**
063     * Returns the dimension of this type, or null if not known.
064     *
065     * @return dimension of this type
066     */
067    Dimension getDimension();
068
069    /**
070     * Returns the hierarchy of this type. If not applicable, throws.
071     *
072     * @return hierarchy of this type
073     */
074    Hierarchy getHierarchy();
075
076    /**
077     * Returns the level of this type, or null if not known.
078     *
079     * @return level of this type
080     */
081    Level getLevel();
082
083}
084
085// End Type.java