1 13 14 package mondrian.olap; 15 16 import mondrian.resource.MondrianResource; 17 18 25 public abstract class LevelBase 26 extends OlapElementBase 27 implements Level { 28 29 protected final Hierarchy hierarchy; 30 protected final String name; 31 protected final String uniqueName; 32 protected String description; 33 protected final int depth; 34 protected final LevelType levelType; 35 protected MemberFormatter memberFormatter; 36 protected int approxRowCount; 37 38 protected LevelBase( 39 Hierarchy hierarchy, 40 String name, 41 int depth, 42 LevelType levelType) { 43 this.hierarchy = hierarchy; 44 this.name = name; 45 this.uniqueName = Util.makeFqName(hierarchy, name); 46 this.depth = depth; 47 this.levelType = levelType; 48 } 49 50 54 public void setApproxRowCount(int approxRowCount) { 55 this.approxRowCount = approxRowCount; 56 } 57 58 public String getQualifiedName() { 60 return MondrianResource.instance().MdxLevelName.str(getUniqueName()); 61 } 62 63 public LevelType getLevelType() { 64 return levelType; 65 } 66 67 public String getUniqueName() { 68 return uniqueName; 69 } 70 71 public String getName() { 72 return name; 73 } 74 75 public String getDescription() { 76 return description; 77 } 78 79 public Hierarchy getHierarchy() { 80 return hierarchy; 81 } 82 83 public Dimension getDimension() { 84 return hierarchy.getDimension(); 85 } 86 87 public int getDepth() { 88 return depth; 89 } 90 91 public Level getChildLevel() { 92 int childDepth = depth + 1; 93 Level[] levels = hierarchy.getLevels(); 94 return (childDepth < levels.length) 95 ? levels[childDepth] 96 : null; 97 } 98 99 public Level getParentLevel() { 100 int parentDepth = depth - 1; 101 Level[] levels = hierarchy.getLevels(); 102 return (parentDepth >= 0) 103 ? levels[parentDepth] 104 : null; 105 } 106 107 public abstract boolean isAll(); 108 109 public boolean isMeasure() { 110 return hierarchy.getName().equals("Measures"); 111 } 112 113 public OlapElement lookupChild(SchemaReader schemaReader, String s) { 114 return lookupChild(schemaReader, s, MatchType.EXACT); 115 } 116 117 public OlapElement lookupChild( 118 SchemaReader schemaReader, String s, MatchType matchType) 119 { 120 return areMembersUnique() 121 ? Util.lookupHierarchyRootMember( 122 schemaReader, hierarchy, s, matchType) 123 : null; 124 } 125 126 129 public MemberFormatter getMemberFormatter() { 130 return memberFormatter; 131 } 132 } 133 134 135 | Popular Tags |