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) 2005-2005 Julian Hyde
008// Copyright (C) 2005-2011 Pentaho
009// All Rights Reserved.
010*/
011package mondrian.olap.type;
012
013import mondrian.olap.*;
014
015/**
016 * The type of an expression which represents a Cube or Virtual Cube.
017 *
018 * @author jhyde
019 * @since Feb 17, 2005
020 */
021public class CubeType implements Type {
022    private final Cube cube;
023
024    /**
025     * Creates a type representing a cube.
026     */
027    public CubeType(Cube cube) {
028        this.cube = cube;
029    }
030
031    /**
032     * Returns the cube.
033     *
034     * @return Cube
035     */
036    public Cube getCube() {
037        return cube;
038    }
039
040    public boolean usesDimension(Dimension dimension, boolean definitely) {
041        return false;
042    }
043
044    public boolean usesHierarchy(Hierarchy hierarchy, boolean definitely) {
045        return false;
046    }
047
048    public Dimension getDimension() {
049        return null;
050    }
051
052    public Hierarchy getHierarchy() {
053        return null;
054    }
055
056    public Level getLevel() {
057        return null;
058    }
059
060    public int hashCode() {
061        return cube.hashCode();
062    }
063
064    public boolean equals(Object obj) {
065        if (obj instanceof CubeType) {
066            CubeType that = (CubeType) obj;
067            return this.cube.equals(that.cube);
068        } else {
069            return false;
070        }
071    }
072
073    public Type computeCommonType(Type type, int[] conversionCount) {
074        return this.equals(type)
075            ? this
076            : null;
077    }
078
079    public boolean isInstance(Object value) {
080        return value instanceof Cube;
081    }
082
083    public int getArity() {
084        // not meaningful; cube cannot be used in an expression
085        throw new UnsupportedOperationException();
086    }
087}
088
089// End CubeType.java