mondrian.olap.type
Class MemberType

java.lang.Object
  extended by mondrian.olap.type.MemberType
All Implemented Interfaces:
Type

public class MemberType
extends Object
implements Type

The type of an expression which represents a member.

Since:
Feb 17, 2005
Author:
jhyde
 

Field Summary
static MemberType Unknown
           
 
Constructor Summary
MemberType(Dimension dimension, Hierarchy hierarchy, Level level, Member member)
          Creates a type representing a member.
 
Method Summary
 Type computeCommonType(Type type, int[] conversionCount)
          Returns a Type which is more general than this and the given Type.
static MemberType forDimension(Dimension dimension)
           
static MemberType forHierarchy(Hierarchy hierarchy)
           
static MemberType forLevel(Level level)
           
static MemberType forMember(Member member)
           
static MemberType forType(Type type)
           
 Dimension getDimension()
          Returns the Dimension of this Type, or null if not known.
 Hierarchy getHierarchy()
          Returns the Hierarchy of this Type, or null if not known.
 Level getLevel()
          Returns the Level of this Type, or null if not known.
 Member getMember()
           
 Type getValueType()
           
 String toString()
           
 boolean usesDimension(Dimension dimension, boolean definitely)
          Returns whether this type contains a given dimension.

For example: DimensionType([Gender]) uses only the [Gender] dimension. TupleType(MemberType([Gender]), MemberType([Store])) uses [Gender] and [Store] dimensions.

The definitely parameter comes into play when the dimensional information is incomplete.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Unknown

public static final MemberType Unknown
Constructor Detail

MemberType

public MemberType(Dimension dimension,
                  Hierarchy hierarchy,
                  Level level,
                  Member member)
Creates a type representing a member.

Parameters:
dimension - Dimension the member belongs to, or null if not known
hierarchy - Hierarchy the member belongs to, or null if not known
level - Level the member belongs to, or null if not known
member - The precise member, or null if not known
Method Detail

forDimension

public static MemberType forDimension(Dimension dimension)

forHierarchy

public static MemberType forHierarchy(Hierarchy hierarchy)

forLevel

public static MemberType forLevel(Level level)

forMember

public static MemberType forMember(Member member)

toString

public String toString()
Overrides:
toString in class Object

getHierarchy

public Hierarchy getHierarchy()
Description copied from interface: Type
Returns the Hierarchy of this Type, or null if not known. If not applicable, throws.

Specified by:
getHierarchy in interface Type
Returns:
the Hierarchy of this type, or null if not known

getLevel

public Level getLevel()
Description copied from interface: Type
Returns the Level of this Type, or null if not known. If not applicable, throws.

Specified by:
getLevel in interface Type
Returns:
the Level of this Type

getMember

public Member getMember()

usesDimension

public boolean usesDimension(Dimension dimension,
                             boolean definitely)
Description copied from interface: Type
Returns whether this type contains a given dimension.

For example:

The definitely parameter comes into play when the dimensional information is incomplete. For example, when applied to TupleType(MemberType(null), MemberType([Store])), usesDimension([Gender], false) returns true because it is possible that the expression returns a member of the [Gender] dimension; but usesDimension([Gender], true) returns true because it is possible that the expression returns a member of the [Gender] dimension.

Specified by:
usesDimension in interface Type
Parameters:
dimension - Dimension
definitely - If true, returns true only if this type definitely uses the dimension
Returns:
whether this Type uses the given Dimension

getValueType

public Type getValueType()

getDimension

public Dimension getDimension()
Description copied from interface: Type
Returns the Dimension of this Type, or null if not known. If not applicable, throws.

Specified by:
getDimension in interface Type
Returns:
the Dimension of this Type, or null if not known.

forType

public static MemberType forType(Type type)

computeCommonType

public Type computeCommonType(Type type,
                              int[] conversionCount)
Description copied from interface: Type
Returns a Type which is more general than this and the given Type. The type returned is broad enough to hold any value of either type, but no broader. If there is no such type, returns null.

Some examples:

If conversionCount is not null, implicit conversions such as HierarchyType to DimensionType are considered; the parameter is incremented by the number of conversions performed.

Some examples:

One use of common types is to determine the types of the arguments to the Iif function. For example, the call

Iif(1 > 2, [Measures].[Unit Sales], 5)
has type ScalarType, because DecimalType(-1, 0) is a subtype of ScalarType, and MeasureType can be converted implicitly to ScalarType.

Specified by:
computeCommonType in interface Type
Parameters:
type - Type
conversionCount - Number of conversions; output parameter that is incremented each time a conversion is performed; if null, conversions are not considered
Returns:
More general type

SourceForge.net_Logo