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