001 /* 002 // This software is subject to the terms of the Common Public License 003 // Agreement, available at the following URL: 004 // http://www.opensource.org/licenses/cpl.html. 005 // Copyright (C) 2007-2007 Julian Hyde 006 // All Rights Reserved. 007 // You must accept the terms of that agreement to use this software. 008 */ 009 package mondrian.olap4j; 010 011 import org.olap4j.metadata.Property; 012 import org.olap4j.metadata.Datatype; 013 import org.olap4j.impl.Named; 014 015 import java.util.*; 016 017 /** 018 * Implementation of {@link org.olap4j.metadata.Property} 019 * for the Mondrian OLAP engine, 020 * as a wrapper around a mondrian 021 * {@link mondrian.olap.Property}. 022 * 023 * @author jhyde 024 * @version $Id: //open/mondrian/src/main/mondrian/olap4j/MondrianOlap4jProperty.java#1 $ 025 * @since Nov 12, 2007 026 */ 027 class MondrianOlap4jProperty implements Property, Named { 028 private final mondrian.olap.Property property; 029 030 MondrianOlap4jProperty(mondrian.olap.Property property) { 031 this.property = property; 032 } 033 034 public Datatype getDatatype() { 035 switch (property.getType()) { 036 case TYPE_BOOLEAN: 037 return Datatype.BOOLEAN; 038 case TYPE_NUMERIC: 039 return Datatype.UNSIGNED_INTEGER; 040 case TYPE_STRING: 041 return Datatype.STRING; 042 case TYPE_OTHER: 043 return Datatype.VARIANT; 044 default: 045 throw new RuntimeException("unexpected: " + property.getType()); 046 } 047 } 048 049 public Set<TypeFlag> getType() { 050 return TypeFlag.forMask( 051 property.isCellProperty() 052 ? TypeFlag.CELL.xmlaOrdinal 053 : TypeFlag.MEMBER.xmlaOrdinal); 054 } 055 056 public String getName() { 057 return property.name; 058 } 059 060 public String getUniqueName() { 061 return property.name; 062 } 063 064 public String getCaption(Locale locale) { 065 // todo: i18n 066 return property.getCaption(); 067 } 068 069 public String getDescription(Locale locale) { 070 // todo: i18n 071 return property.getDescription(); 072 } 073 074 public ContentType getContentType() { 075 return ContentType.REGULAR; 076 } 077 } 078 079 // End MondrianOlap4jProperty.java