1 13 14 package mondrian.olap; 15 16 import mondrian.resource.MondrianResource; 17 18 25 public abstract class DimensionBase 26 extends OlapElementBase 27 implements Dimension { 28 29 protected final String name; 30 protected final String uniqueName; 31 protected final String description; 32 protected final int globalOrdinal; 33 protected Hierarchy[] hierarchies; 34 protected DimensionType dimensionType; 35 36 protected DimensionBase( 37 String name, 38 int globalOrdinal, 39 DimensionType dimensionType) 40 { 41 this.name = name; 42 this.uniqueName = Util.makeFqName(name); 43 this.description = null; 44 this.globalOrdinal = globalOrdinal; 45 this.dimensionType = dimensionType; 46 } 47 48 public String getUniqueName() { 49 return uniqueName; 50 } 51 52 public String getName() { 53 return name; 54 } 55 56 public String getDescription() { 57 return description; 58 } 59 60 public Hierarchy[] getHierarchies() { 61 return hierarchies; 62 } 63 64 public Hierarchy getHierarchy() { 65 return hierarchies[0]; 66 } 67 68 public Dimension getDimension() { 69 return this; 70 } 71 72 public DimensionType getDimensionType() { 73 return dimensionType; 74 } 75 76 public String getQualifiedName() { 77 return MondrianResource.instance().MdxDimensionName.str(getUniqueName()); 78 } 79 80 public boolean isMeasures() { 81 return getUniqueName().equals(MEASURES_UNIQUE_NAME); 82 } 83 84 public boolean usesDimension(Dimension dimension) { 85 return dimension == this; 86 } 87 88 public OlapElement lookupChild(SchemaReader schemaReader, String s) 89 { 90 return lookupChild(schemaReader, s, MatchType.EXACT); 91 } 92 93 public OlapElement lookupChild( 94 SchemaReader schemaReader, String s, MatchType matchType) 95 { 96 OlapElement oe = lookupHierarchy(s); 97 98 if ((oe == null) || oe.getName().equalsIgnoreCase(getName()) ) { 103 OlapElement oeLevel = 104 getHierarchy().lookupChild(schemaReader, s, matchType); 105 if (oeLevel != null) 106 oe = oeLevel; } 108 109 if (getLogger().isDebugEnabled()) { 110 StringBuilder buf = new StringBuilder (64); 111 buf.append("DimensionBase.lookupChild: "); 112 buf.append("name="); 113 buf.append(getName()); 114 buf.append(", childname="); 115 buf.append(s); 116 if (oe == null) { 117 buf.append(" returning null"); 118 } else { 119 buf.append(" returning elementname="+oe.getName()); 120 } 121 getLogger().debug(buf.toString()); 122 } 123 124 return oe; 125 } 126 127 private Hierarchy lookupHierarchy(String s) { 128 for (Hierarchy hierarchy : hierarchies) { 129 if (hierarchy.getName().equalsIgnoreCase(s)) { 130 return hierarchy; 131 } 132 } 133 return null; 134 } 135 } 136 137 138 | Popular Tags |