1 10 package mondrian.olap.type; 11 12 import mondrian.olap.Dimension; 13 import mondrian.olap.Hierarchy; 14 import mondrian.olap.Level; 15 16 23 public class DimensionType implements Type { 24 private final Dimension dimension; 25 private final String digest; 26 27 public static final DimensionType Unknown = new DimensionType(null); 28 29 35 public DimensionType(Dimension dimension) { 36 this.dimension = dimension; 37 StringBuilder buf = new StringBuilder ("DimensionType<"); 38 if (dimension != null) { 39 buf.append("dimension=").append(dimension.getUniqueName()); 40 } 41 buf.append(">"); 42 this.digest = buf.toString(); 43 } 44 45 public static DimensionType forDimension(Dimension dimension) { 46 return new DimensionType(dimension); 47 } 48 49 public static DimensionType forType(Type type) { 50 return new DimensionType(type.getDimension()); 51 } 52 53 public boolean usesDimension(Dimension dimension, boolean maybe) { 54 return this.dimension == dimension || 55 (maybe && this.dimension == null); 56 } 57 58 public Hierarchy getHierarchy() { 59 return dimension == null ? 60 null : 61 dimension.getHierarchies().length > 1 ? 62 null : 63 dimension.getHierarchies()[0]; 64 } 65 66 public Level getLevel() { 67 return null; 68 } 69 70 public Dimension getDimension() { 71 return dimension; 72 } 73 74 public String toString() { 75 return digest; 76 } 77 } 78 79 | Popular Tags |