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