001 /* 002 // $Id: //open/mondrian/src/main/mondrian/olap4j/MondrianOlap4jMember.java#3 $ 003 // This software is subject to the terms of the Common Public License 004 // Agreement, available at the following URL: 005 // http://www.opensource.org/licenses/cpl.html. 006 // Copyright (C) 2007-2008 Julian Hyde 007 // All Rights Reserved. 008 // You must accept the terms of that agreement to use this software. 009 */ 010 package mondrian.olap4j; 011 012 import org.olap4j.metadata.*; 013 import org.olap4j.OlapException; 014 import org.olap4j.impl.Named; 015 import org.olap4j.impl.AbstractNamedList; 016 import org.olap4j.mdx.ParseTreeNode; 017 018 import java.util.List; 019 import java.util.Locale; 020 021 import mondrian.rolap.RolapMeasure; 022 023 /** 024 * Implementation of {@link Member} 025 * for the Mondrian OLAP engine, 026 * as a wrapper around a mondrian 027 * {@link mondrian.olap.Member}. 028 * 029 * @author jhyde 030 * @version $Id: //open/mondrian/src/main/mondrian/olap4j/MondrianOlap4jMember.java#3 $ 031 * @since May 25, 2007 032 */ 033 class MondrianOlap4jMember implements Member, Named { 034 final mondrian.olap.Member member; 035 private final MondrianOlap4jSchema olap4jSchema; 036 037 MondrianOlap4jMember( 038 MondrianOlap4jSchema olap4jSchema, 039 mondrian.olap.Member mondrianMember) 040 { 041 assert mondrianMember != null; 042 assert mondrianMember instanceof RolapMeasure 043 == this instanceof MondrianOlap4jMeasure; 044 this.olap4jSchema = olap4jSchema; 045 this.member = mondrianMember; 046 } 047 048 public boolean equals(Object obj) { 049 return obj instanceof MondrianOlap4jMember && 050 member.equals(((MondrianOlap4jMember) obj).member); 051 } 052 053 public int hashCode() { 054 return member.hashCode(); 055 } 056 057 public NamedList<MondrianOlap4jMember> getChildMembers() { 058 final List<mondrian.olap.Member> children = 059 olap4jSchema.schemaReader.getMemberChildren( 060 member); 061 return new AbstractNamedList<MondrianOlap4jMember>() { 062 protected String getName(MondrianOlap4jMember member) { 063 return member.getName(); 064 } 065 066 public MondrianOlap4jMember get(int index) { 067 return new MondrianOlap4jMember(olap4jSchema, children.get(index)); 068 } 069 070 public int size() { 071 return children.size(); 072 } 073 }; 074 } 075 076 public int getChildMemberCount() { 077 return olap4jSchema.schemaReader.getMemberChildren(member).size(); 078 } 079 080 public MondrianOlap4jMember getParentMember() { 081 final mondrian.olap.Member parentMember = member.getParentMember(); 082 if (parentMember == null) { 083 return null; 084 } 085 return new MondrianOlap4jMember(olap4jSchema, parentMember); 086 } 087 088 public Level getLevel() { 089 return new MondrianOlap4jLevel(olap4jSchema, member.getLevel()); 090 } 091 092 public Hierarchy getHierarchy() { 093 return new MondrianOlap4jHierarchy( 094 olap4jSchema, member.getHierarchy()); 095 } 096 097 public Dimension getDimension() { 098 return new MondrianOlap4jDimension( 099 olap4jSchema, member.getDimension()); 100 } 101 102 public Type getMemberType() { 103 return Type.valueOf(member.getMemberType().name()); 104 } 105 106 public boolean isAll() { 107 return member.isAll(); 108 } 109 110 public boolean isChildOrEqualTo(Member member) { 111 throw new UnsupportedOperationException(); 112 } 113 114 public boolean isCalculated() { 115 return getMemberType() == Type.FORMULA; 116 } 117 118 public int getSolveOrder() { 119 throw new UnsupportedOperationException(); 120 } 121 122 public ParseTreeNode getExpression() { 123 throw new UnsupportedOperationException(); 124 } 125 126 public List<Member> getAncestorMembers() { 127 throw new UnsupportedOperationException(); 128 } 129 130 public boolean isCalculatedInQuery() { 131 throw new UnsupportedOperationException(); 132 } 133 134 public Object getPropertyValue(Property property) { 135 return member.getPropertyValue(property.getName()); 136 } 137 138 public String getPropertyFormattedValue(Property property) { 139 return member.getPropertyFormattedValue(property.getName()); 140 } 141 142 public void setProperty(Property property, Object value) throws OlapException { 143 member.setProperty(property.getName(), value); 144 } 145 146 public NamedList<Property> getProperties() { 147 return getLevel().getProperties(); 148 } 149 150 public int getOrdinal() { 151 final Number ordinal = 152 (Number) member.getPropertyValue( 153 Property.StandardMemberProperty.MEMBER_ORDINAL.getName()); 154 return ordinal.intValue(); 155 } 156 157 public boolean isHidden() { 158 throw new UnsupportedOperationException(); 159 } 160 161 public int getDepth() { 162 throw new UnsupportedOperationException(); 163 } 164 165 public Member getDataMember() { 166 throw new UnsupportedOperationException(); 167 } 168 169 public String getName() { 170 return member.getName(); 171 } 172 173 public String getUniqueName() { 174 return member.getUniqueName(); 175 } 176 177 public String getCaption(Locale locale) { 178 throw new UnsupportedOperationException(); 179 } 180 181 public String getDescription(Locale locale) { 182 throw new UnsupportedOperationException(); 183 } 184 } 185 186 // End MondrianOlap4jMember.java