001 /*
002 // $Id: SetType.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 */
020 package org.olap4j.type;
021
022 import org.olap4j.metadata.*;
023
024 /**
025 * Set type.
026 *
027 * @author jhyde
028 * @since Feb 17, 2005
029 * @version $Id: SetType.java 482 2012-01-05 23:27:27Z jhyde $
030 */
031 public class SetType implements Type {
032
033 private final Type elementType;
034
035 /**
036 * Creates a type representing a set of elements of a given type.
037 *
038 * @param elementType The type of the elements in the set, or null if not
039 * known
040 */
041 public SetType(Type elementType) {
042 assert elementType instanceof MemberType
043 || elementType instanceof TupleType;
044 this.elementType = elementType;
045 }
046
047 /**
048 * Returns the type of the elements of this set.
049 *
050 * @return element type
051 */
052 public Type getElementType() {
053 return elementType;
054 }
055
056 public boolean usesDimension(Dimension dimension, boolean maybe) {
057 if (elementType == null) {
058 return maybe;
059 }
060 return elementType.usesDimension(dimension, maybe);
061 }
062
063 public Dimension getDimension() {
064 return elementType == null
065 ? null
066 : elementType.getDimension();
067 }
068
069 public Hierarchy getHierarchy() {
070 return elementType == null
071 ? null
072 : elementType.getHierarchy();
073 }
074
075 public Level getLevel() {
076 return elementType == null
077 ? null
078 : elementType.getLevel();
079 }
080 }
081
082 // End SetType.java