001    /*
002    // $Id: Type.java 229 2009-05-08 19:11:29Z jhyde $
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) 2005-2008 Julian Hyde
007    // All Rights Reserved.
008    // You must accept the terms of that agreement to use this software.
009    */
010    package org.olap4j.type;
011    
012    import org.olap4j.metadata.Dimension;
013    import org.olap4j.metadata.Hierarchy;
014    import org.olap4j.metadata.Level;
015    
016    /**
017     * Type of an MDX expression.
018     *
019     * <p>All type objects are immutable.
020     *
021     * @author jhyde
022     * @since Feb 17, 2005
023     * @version $Id: Type.java 229 2009-05-08 19:11:29Z jhyde $
024     */
025    public interface Type {
026        /**
027         * Returns whether this type contains a given dimension.<p/>
028         *
029         * For example:
030         * <ul>
031         * <li><code>DimensionType([Gender])</code> uses only the
032         *     <code>[Gender]</code> dimension.</li>
033         * <li><code>TupleType(MemberType([Gender]), MemberType([Store]))</code>
034         *     uses <code>[Gender]</code>  and <code>[Store]</code>
035         *     dimensions.</li>
036         * </ul><p/>
037         *
038         * The <code>maybe</code> parameter comes into play when the
039         * dimensional information is incomplete. For example, when applied to
040         * <code>TupleType(MemberType(null), MemberType([Store]))</code>,
041         * <code>usesDimension([Gender], false)</code> returns true because it
042         * is possible that the expression returns a member of the
043         * <code>[Gender]</code> dimension.
044         *
045         * @param dimension Dimension
046         * @param maybe If true, returns true only if this type definitely
047         *    uses the dimension
048         *
049         * @return whether this type definitely (or if <code>maybe</code> is true,
050         * possibly) uses the given dimension
051         */
052        boolean usesDimension(Dimension dimension, boolean maybe);
053    
054        /**
055         * Returns the dimension of this type, or null if not known.
056         *
057         * @return dimension of this type
058         */
059        Dimension getDimension();
060    
061        /**
062         * Returns the hierarchy of this type. If not applicable, throws.
063         *
064         * @return hierarchy of this type
065         */
066        Hierarchy getHierarchy();
067    
068        /**
069         * Returns the level of this type, or null if not known.
070         *
071         * @return level of this type
072         */
073        Level getLevel();
074    
075    }
076    
077    // End Type.java