mondrian.olap.type
Interface Type

All Known Implementing Classes:
BooleanType, CubeType, DateTimeType, DecimalType, DimensionType, EmptyType, HierarchyType, LevelType, MemberType, NullType, NumericType, ScalarType, SetType, StringType, SymbolType, TupleType

public interface Type

Type of an MDX expression.

Since:
Feb 17, 2005
Version:
$Id: //open/mondrian/src/main/mondrian/olap/type/Type.java#11 $
Author:
jhyde

Method Summary
 Type computeCommonType(Type type, int[] conversionCount)
          Returns a Type which is more general than this and the given 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.
 boolean isInstance(Object value)
          Returns whether a value is valid for a type.
 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.

 boolean usesHierarchy(Hierarchy hierarchy, boolean definitely)
          Returns whether this type contains a given hierarchy.

For example: HierarchyType([Customer].[Gender]) uses only the [Customer].[Gender] hierarchy. TupleType(MemberType([Customer].[Gender]), MemberType([Store].[Store])) uses [Gender] and [Store] dimensions.

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

 

Method Detail

usesDimension

boolean usesDimension(Dimension dimension,
                      boolean definitely)
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.

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

usesHierarchy

boolean usesHierarchy(Hierarchy hierarchy,
                      boolean definitely)
Returns whether this type contains a given hierarchy.

For example:

The definitely parameter comes into play when the dimensional information is incomplete. For example, when applied to TupleType(MemberType([Customer]), MemberType([Store])), usesDimension([Customer].[Gender], false) returns true because the expression returns a member of one hierarchy of the [Customer] dimension and that might be a member of the [Customer].[Gender] hierarchy; but usesDimension([Customer].[Gender], true) returns false because might return a member of a different hierarchy, such as [Customer].[State].

Parameters:
hierarchy - Hierarchy
definitely - If true, returns true only if this type definitely uses the hierarchy
Returns:
whether this Type uses the given Hierarchy

getDimension

Dimension getDimension()
Returns the Dimension of this Type, or null if not known. If not applicable, throws.

Returns:
the Dimension of this Type, or null if not known.

getHierarchy

Hierarchy getHierarchy()
Returns the Hierarchy of this Type, or null if not known. If not applicable, throws.

Returns:
the Hierarchy of this type, or null if not known

getLevel

Level getLevel()
Returns the Level of this Type, or null if not known. If not applicable, throws.

Returns:
the Level of this Type

computeCommonType

Type computeCommonType(Type type,
                       int[] conversionCount)
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.

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

isInstance

boolean isInstance(Object value)
Returns whether a value is valid for a type.

Parameters:
value - Value
Returns:
Whether value is valid for this type

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads