diff --git a/build.xml b/build.xml
index 4f597f0..5fda06e 100644
--- a/build.xml
+++ b/build.xml
@@ -14,7 +14,7 @@
olap4j Functional Specification
Version: 0.6-dev (draft)
Revision: $Id: $
(log)
-Last modified: October 11th, 2006.
Metadata is at the heart of olap4j. You can browse the cubes, dimensions, hierarchies, members in an OLAP schema, and an MDX parse tree and query result are tied back to the same metadata objects. There is also a type -system for describing scalar expressions.
+system for describing expressions.olap4j makes it possible to write an OLAP client without starting from scratch. In addition to the MDX parser, and operations on the MDX parse tree, there is a higher-level query model, which includes operations to transform queries (also called 'navigations'), and facilities to layout multidimensional results as HTML tables.
-At this point, you may be saying: what about XML/A? XML/A was here first, is an open standard, and is supported by a number of servers. Is olap4j an attempt to @@ -207,7 +271,37 @@
If a web-services based application needs these functions, it can use the XML/A provider to connect to the underlying data source, execute queries, and browse metadata, but can still use olap4j's features for MDX parsing, query -models and layout.
+models and layout. +Where possible, olap4j leverages existing standards. This has several +advantages. First, an end-user familiar with the existing standards can come up +to speed with olap4j quickly. For instance, creating a connection and executing +a statement should be straightforward to anyone familiar with JDBC connections, +statements and result sets work.
+If an OLAP server implementor has already implemented a driver for one +standard, then it should be less work to implement an olap4j driver. This +clearly applies to the MDX language (borrowed from XML/A and OLE DB for OLAP). +Implementation schema result sets should be straightforward if the server +already supports XML/A schema rowsets.
+If olap4j is sufficiently similar to an existing standard, tools designed for +use with that standard may be applicable to olap4j also. For instance, one goal +of olap4j is that people will be able to use connection-pooling libraries such +as Jakarta Commons DBCP, +C3P0. (This presents some +challenges because olap4j extends some of the JDBC interfaces, but we hope to +solve them.)
+Lastly, reusing an existing standard is less work for the authors of the new +standard!
+Sometimes the standards conflict. ADOMD exposes its metadata through an +object model, whereas JDBC and XML/A expose metadata relationally, via what +XML/A calls rowsets and what we and JDBC call result sets. In this case, we +chose to do both, because of the diversity of needs of olap4j clients. Metadata +objects allow you to integrate query results with metadata using much fewer +code: positions can reference members, and you can navigate from a member to its +hierarchy, and so forth. Likewise, metadata objects can be used in building MDX +parse trees. But if a client tool wants to maintain its own metadata cache, +schema rowsets are more flexible and efficient.
Classes:
Same functionality as JDBC.
Here is an example of registering an olap4j driver:
-Same functionality as JDBC.
@@ -276,14 +370,14 @@In the above examples, a statement was created from a string. As we shall see, a statement can also be created from an MDX parse tree.
-Package name: org.olap4j
Package name: org.olap4j
-OlapConnection is a +
+OlapConnection (extends + +java.sql.Connection) is a connection to an OLAP data source.
-olap4j extends various JDBC interfaces:
-olap4j class | -extends JDBC class | -created by | -
---|---|---|
org.olap4j.OlapConnection |
- java.sql.Connection |
- Connection DriverManager.createConnection() |
-
org.olap4j.OlapStatement |
- java.sql.Statement |
- Statement Connection.createStatement() |
-
org.olap4j.PreparedOlapStatement |
- java.sql.PreparedStatement |
- PreparedStatement Connection.prepareStatement() |
-
org.olap4j.OlapResultSet |
- java.sql.ResultSet |
- ResultSet Statement.executeQuery(String) |
-
One would expect that it would be safe to downcast the result of a factory +
Look again at the code samples in the previous section. One would expect that it would be safe to downcast the result of a factory
method to the desired result. For example, if you invoke an OlapConnection
's
createStatement()
method, the result should be an
OlapStatement
.
However, this will not be the case if you are using a connection-pooling -library, common examples of which include Jakarta Commons DBCP and C3P0. Every -connection-pooling library tracks connections by wrapping them in another class, +
But if you you are using a connection-pooling
+library (common examples of which include Jakarta Commons DBCP
+and
+C3P0), this is not so. Every
+connection-pooling library tracks connections by wrapping them in another class,
and this class will implement java.sql.Connection
but not
-OlapConnection
. To access methods of the OlapConnection
, the
+OlapConnection. To access methods of the OlapConnection
, the
client application must first strip away the wrapper object.
The problem is not restricted to connections: some connection pools also wrap
-Statement
, PreparedStatement
, ResultSet
-and DatabaseMetaData
objects. But the good news is that you don't
-need to access OlapConnection
, OlapStatement
or
-PreparedOlapStatement
very often, because they do do not have many
-methods
+
If you are using a connection-pooling library, olap4j provides a helper class to access the object underneath a wrapped +connection, statement, prepared statement or result set. For instance,
+ +The
+
+Olap4j.convert(Connection) method returns an OlapConnection
. It
+works with common connection pools, and the resulting object is instrumented so
+that any statements or prepared statements created from that connection also
+work with the connection pool.
The problem does not just affect connections: some connection pools also wrap
+Statement
, PreparedStatement
, ResultSet
+and DatabaseMetaData
objects, so there are convert()
+methods for these too.
Hopefully this problem will only be temporary. As olap4j gains popularity, we +expect connection pools to add support for the extended interfaces, and it will +be sufficient merely to cast the objects returned from factory methods.
OlapStatement (extends -java.sql.Statement) -is an object used to execute a static MDX statement and return the result it +
OlapStatement (extends +java.sql.Statement) +is an object used to execute a static MDX statement and return the result it produces.
-PreparedOlapStatement (extends - + java.sql.PreparedStatement) represents a precompiled MDX statement.
-An MDX statement is precompiled and stored in a PreparedOlapStatement
-object. This object can then be used to efficiently execute this statement
+
An MDX statement is precompiled and stored in a PreparedOlapStatement
+object. This object can then be used to efficiently execute this statement
multiple times.
The method - -PreparedStatement.getParameterMetaData() returns a description of the + +PreparedStatement.getParameterMetaData() returns a description of the parameters, as in JDBC. The result is an OlapParameterMetaData.
-To set values of parameters, use the setType(int, type)
-methods. If a parameter is a member, use the setObject(int, Object)
-method; throws an exception if the object is not a member, or is a member of the
+
To set values of parameters, use the setType(int, type)
+methods. If a parameter is a member, use the setObject(int, Object)
+method; throws an exception if the object is not a member, or is a member of the
wrong hierarchy.
Unlike JDBC, it is not necessary to assign a value to every parameter. This -is because OLAP parameters have a default value. Parameters have their default -value until they are set, and then retain their new values for each subsequent +
Unlike JDBC, it is not necessary to assign a value to every parameter. This
+is because OLAP parameters have a default value. Parameters have their default
+value until they are set, and then retain their new values for each subsequent
execution of this PreparedOlapStatement
.
[How to find out what cube a prepared statement relates to?]
+OlapParameterMetaData
(extends
-
+
java.sql.ParameterMetaData) describes parameters of a
PreparedOlapStatement
.
OlapResultSet (extends
-
-java.sql.ResultSet) is the result of executing a OlapStatement
-or PreparedOlapStatement
.
It extends ResultSet, but since most of these methods are concerned with rows -and columns, few of ResultSet's methods are applicable. The following methods +
OlapResultSet (extends + +java.sql.ResultSet) is the result of executing an OlapStatement +or PreparedOlapStatement.
+It extends ResultSet, but since most of these methods are concerned with rows +and columns, few of ResultSet's methods are applicable. The following methods are applicable:
-
- clearWarnings()
-
- close()
-
- getConcurrency()
-
- getStatement()
-
- getType()
-
- getWarnings()
Additional methods to retrieve the axes of the multidimensional result.
-[tbd]
[access positions by index (i.e. a list) and by scrolling (i.e. an iterator)]
-[tbd]
-[tbd]
Package name: org.olap4j.mdx.type
Represents the types of nodes in an MDX query model.
Here are some examples:
@@ -531,7 +610,7 @@[Store].[USA].[CA]
Since MDX is a late-binding language, some expressions will have unknown +
Since MDX is a late-binding language, some expressions will have unknown types, or only partial type information. For example, the expression
will have type Level<dimension=[Store], level=unknown>
. The
-validator knows that the <hierarchy>.Levels(<string expr>)
function
-returns a level, but exactly which level is not known until the expression is
+
will have type Level<dimension=[Store], level=unknown>
. The
+validator knows that the <hierarchy>.Levels(<string expr>)
function
+returns a level, but exactly which level is not known until the expression is
evaluated at runtime.
Package name: org.olap4j.mdx.type
Classes:
+Type is the base class for all types.
+Scalar types:
NumericType
) represents a fixed-point numeric expression. It
+ is a subclass of NumericType
, and has precision and scale. An
+ integer expression would have scale 0.ASC
+ keyword in the expression Order(Gender.MEMBERS, Measures.[Unit Sales],
+ ASC)
is a symbol. Symbol types are rarely used except if you are
+ manipulating a parse tree.Metadata types:
+A metadata type may be constrained to a particular part of the schema. For
+example, LevelType(hierarchy=[Time])
indicates that the expression
+must evaluate to one of the levels of the [Time]
hierarchy, that
+is, one of the values [Time].[Year]
, [Time].[Quarter]
,
+or [Time].[Month]
.
Composite types
+
+ {[Store].[USA].Children}
is Set(Member(level=[Store].[Store
+ State])
.
+ CrossJoin({[Gender].[F], [Gender].[M]}, [Store].Members)
is
+ Set(Tuple(Member(level=[Gender].[Gender]), Member(hierarchy=[Store]))
.Package name: org.olap4j.metamodel
The components of the OLAP model are available as read-only Java classes, and -also via schema rowsets.
- +Package name: + +org.olap4j.metamodel
+Metadata are the objects which describe the structure of an OLAP schema: +cubes, dimensions, members, properties and so forth.
+olap4j exposes metadata in two very different ways:
+A user's view of metadata may be subject to access control. For example, a -user may not have read access to certain hierarchies within a cube, or to -certain members within a hierarchy. The API methods must behave consistently +
A user's view of metadata may be subject to access control. For example, a +user may not have read access to certain hierarchies within a cube, or to +certain members within a hierarchy. The API methods must behave consistently with access control.
--Example: If Fred does not have access to the
[Nation]
+Example: If Fred does not have access to the
[Nation]
level of the[Store]
hierarchy, then theMember.getParentMember()
method will return null if applied to- [Store].[USA].[CA]
, because the 'real' parent member[Store].[USA]
+ [Store].[USA].[CA], because the 'real' parent member[Store].[USA]
is invisible to him.
2.6.2. Schema rowsets
+[Diagram of object model, showing relationships between Schema, Cube, +Dimension, etc.]
++MetadataElement is the base class for Cube, Dimension, Hierarchy, Level, Member, Property; provides +name and unique-name properties (not localized), and localized caption and +description.
+Schema ...
+Cube ...
+Dimension +...
+Hierarchy +...
+Level ...
+Meaure ...
+Member ...
+Property +...
+Schema rowsets are specified as in [XML for Analysis +specification]. Here is a table of the XML/A methods and the corresponding +olap4j method.
+ +XML for Analysis schema rowset | +OlapDatabaseMetaData method | +
---|---|
DISCOVER_DATASOURCES | ++ + getDatasources | +
DISCOVER_ENUMERATORS | +not supported | +
DISCOVER_KEYWORDS | ++ + getMdxKeywords | +
DISCOVER_LITERALS | ++ + getLiterals | +
DISCOVER_PROPERTIES | ++ + getDatabaseProperties | +
DISCOVER_SCHEMA_ROWSETS | +not supported | +
MDSCHEMA_ACTIONS | ++ + getActions | +
MDSCHEMA_CUBES | ++ + getCubes | +
MDSCHEMA_DIMENSIONS | ++ + getDimensions | +
MDSCHEMA_FUNCTIONS | ++ + getFunctions | +
MDSCHEMA_HIERARCHIES | ++ + getHierarchies | +
MDSCHEMA_INPUT_DATASOURCES | +not supported | +
MDSCHEMA_KPIS | +not supported | +
MDSCHEMA_LEVELS | ++ + getLevels | +
MDSCHEMA_MEASURES | ++ + getMeasures | +
MDSCHEMA_MEMBERS | ++ + getMembers | +
MDSCHEMA_PROPERTIES | ++ + getProperties | +
MDSCHEMA_SETS | ++ + getSets | +
The rows returned in the result set returned from the metadata +methods are structured according to the result set column layouts detailed in this +section.
+All columns noted in the following result sets are required, and
+they must be returned in the order shown. However, additional columns (which
+should be ignored by clients not expecting thxem) can be added at the end, and
+some columns can contain null data for info
+xxx The following sections describe the columns in each rowset. Each
+section includes a table that provides the following information for each
+column. [Need to clean up data types in the following tables. Types should all be
+JDBC types.] [Need to clean up column names in the following tables. Columns should be
+UPPER_CASE, not CamelCase.] [It would be useful to define enum types for the various attributes, such as
+the ProviderType and AuthenticationMode attributes of getDatasources, and the
+DIMENSION_TYPE attribute of getDimensions. In some cases those enums already
+exist, but need to be extended.] Specified by the The returned result set contains the following columns. A string containing any additional information required
+ to connect to the data source. This can include the Initial Catalog
+ property or other information for the provider. Example: The name of the provider behind the data source. Example: The types of data supported by the
+ provider. May include one or more of the following types. Example
+ follows this table. Returns
+information about the standard and provider-specific properties supported by an
+olap4j provider. Properties that are not supported by a provider are
+not listed in the return result set. Specified by the The returned result set contains the following columns. [Is VALUE a JDBC reserved word? If so, change it.] Retrieves a list of information on supported literals, including data types
+and values. Specified by the The returned result set contains the following columns. The name of the literal described in the row. Example: DBLITERAL_LIKE_PERCENT Contains the actual literal value. Example, if LiteralName is
+ DBLITERAL_LIKE_PERCENT and the percent character (%) is used to match
+ zero or more characters in a LIKE clause, this column’s value would be
+ "%". The characters, in the literal, that are not valid. For example, if table names can contain anything other
+ than a numeric character, this string would be "0123456789". Describes the structure of cubes within a database. Specified by the The returned result set contains the following columns. The rowset is sorted on CATALOG_NAME,
+ SCHEMA_NAME, CUBE_NAME. Retrieves a result set describing the shared and private dimensions within a database. Specified by the The returned result set contains the following columns. TRUE if the dimension is
+ write-enabled. The result set is sorted on CATALOG_NAME,
+ SCHEMA_NAME, CUBE_NAME, DIMENSION_NAME. Retrieves a result set describing the functions available to client
+ applications connected to the database. Specified by the The returned result set contains the following columns. The group name for Multidimensional
+ Expressions (MDX) functions. Returns
+ VT_NULL for MDX functions. Returns VT_NULL for MDX
+ functions. Returns VT_NULL for
+ user-defined functions, or non-property MDX
+ functions. The rowset is sorted on ORIGIN, INTERFACE_NAME,
+ FUNCTION_NAME. Retrieves a result set describing each hierarchy within a particular
+dimension. Specified by the The returned result set contains the following columns. Returns TRUE
+ if the Write Back to dimension column that
+ represents this hierarchy is enabled. Returns TRUE if the hierarchy
+ is visible; otherwise, FALSE. A parent/child attribute hierarchy is both
+ MD_USER_DEFINED and MD_SYSTEM_ENABLED. The rowset is sorted on CATALOG_NAME,
+ SCHEMA_NAME, CUBE_NAME, DIMENSION_UNIQUE_NAME,
+ HIERARCHY_NAME. Retrieves a result set describing each level within a particular hierarchy. Specified by the The returned result set contains the following columns. The key is always unique in Microsoft SQL Server
+ 2005 Analysis Services (SSAS). The name will be
+ unique if the setting on the attribute is
+ UniqueInDimension or UniqueInAttribute Always returns True. If the level is not
+ visible, it will not be included in the schema
+ rowset. Null
+ if concatenated keys are used as the member key
+ column. The rowset is sorted on CATALOG_NAME,
+ SCHEMA_NAME, CUBE_NAME, DIMENSION_UNIQUE_NAME,
+ HIERARCHY_UNIQUE_NAME, LEVEL_NUMBER. Retrieves a result set describing each measure within a cube. Specified by the The returned result set contains the following columns. The rowset is sorted on CATALOG_NAME,
+ SCHEMA_NAME, CUBE_NAME, MEASURE_NAME. Retrieves a result set describing the members within a database. Specified by the The returned result set contains the following columns. It is valid only if the
+ MDX Compatibility property has been set to 1.
+ Returns True if the member is a data
+ member. This applies to ragged
+ hierarchies where tree operators could return
+ members from different levels (for example, if the
+ prior level contains holes and parent on members is
+ requested). The rowset is sorted on CATALOG_NAME,
+ SCHEMA_NAME, CUBE_NAME, DIMENSION_UNIQUE_NAME,
+ HIERARCHY_UNIQUE_NAME, LEVEL_UNIQUE_NAME,
+ LEVEL_NUMBER, MEMBER_ORDINAL. Retrieves a list of descriptions of member and cell Properties. Specified by the The returned result set contains the following columns. Zero
+ indicates there is no defined maximum length. Returns NULL for all other data types.
+ Zero indicates there is no defined maximum length. Returns NULL for all other data types. Returns NULL for all
+ other data types. Returns NULL for
+ all other data types. TRUE if the property is visible;
+ otherwise, FALSE. This schema rowset is not sorted. Retrieves a result set describing any sets that are currently defined in a
+database, including session-scoped sets. Specified by the The returned result set contains the following columns. The rowset is sorted on CATALOG_NAME,
+ SCHEMA_NAME, CUBE_NAME. OlapDatabaseMetaData extends Classes: A transform is an operation which maps a query model to a new query model. It
-is usually triggered by a gesture within the user-interface. For example,
+ A transform is an operation which maps a query model to a new query model. It
+is usually triggered by a gesture within the user-interface. For example,
clicking on the Unit Sales column transforms the query into one with sorting: The layout package provides data models for graphical OLAP applications. In
+ The layout package provides data models for graphical OLAP applications. In
particular, the GridModel class provides, for OLAP data, what Swing's
-
+
TableModel provides for SQL data. Package name: The API described above is a set of interfaces which must be implemented by
-any compliant provider. The olap4j project also contains some components which
+ The API described above is a set of interfaces which must be implemented by
+any compliant provider. The olap4j project also contains some components which
are not part of the API. The olap4j project contains a TCK (Test Compatability Kit). The TCK is a suite
-of tests which can be used to verify the compliance of an implementation of the
+ The olap4j project contains a TCK (Test Compatability Kit). The TCK is a suite
+of tests which can be used to verify the compliance of an implementation of the
API. The XML/A provider is an implementation of the olap4j API which talks to a
+ The XML/A provider is an implementation of the olap4j API which talks to a
generic XML/A provider. Since there are many XML/A providers, and some of them require requests in a
-particular format and/or produce idiosyncratic responses, the XML/A provider
+ Since there are many XML/A providers, and some of them require requests in a
+particular format and/or produce idiosyncratic responses, the XML/A provider
will come in several flavors. Here are some of the areas of functionality which will not be part of
+ Here are some of the areas of functionality which will not be part of
the olap4j project: The Mondrian project will contain an implementation of the olap4j API based on
+ The Mondrian project will contain an implementation of the olap4j API based on
the Mondrian OLAP server. JPivot currently based on two data sources: the Mondrian server, and a
+ JPivot currently based on two data sources: the Mondrian server, and a
generic XML/A data source. We intend to convert JPivot to run solely on the olap4j API. Connectivity to
-Mondrian and XML/A sources will be achieved by choosing the appropriate olap4j
+ We intend to convert JPivot to run solely on the olap4j API. Connectivity to
+Mondrian and XML/A sources will be achieved by choosing the appropriate olap4j
provider. In principle, providers could be created to other OLAP data sources. This
-would be particularly straightforward for servers which already have a native
+ In principle, providers could be created to other OLAP data sources. This
+would be particularly straightforward for servers which already have a native
Java API. The following are features which have been suggested for inclusion in the
-olap4j specification, but which are not part of the current version. They may be
+ The following are features which have been suggested for inclusion in the
+olap4j specification, but which are not part of the current version. They may be
included in future revisions of the specification. Include support for Date and Time values. The package org.olap4j.mdx.type
+ Include support for Date and Time values. The package org.olap4j.mdx.type
could have additional classes DateType and TimeType. (Richard Emberson, 2006/8/14) Add a mechanism for the client to detect that the schema has been modified
-(for instance, that a cube has been added). Not necessarily to find out what
+ Add a mechanism for the client to detect that the schema has been modified
+(for instance, that a cube has been added). Not necessarily to find out what
those changes are. (Richard Emberson, 2006/8/15) Specify how clients can write cell values back to the database. Useful for
+budgeting applications and 'what if?' analysis. (PALO, 2006/10/14) [Discuss thread safety of connections, statements, result sets.] 1. XMLA: XML for
+Analysis Specification, version 1.1 Connection pools typically work by creating wrapped versions of
+ * connection, statement, prepared statement, result set, and metadata objects.
+ * These are problematic for olap4j, because olap4j extends the JDBC interfaces,
+ * and the wrapped objects will not implement those interfaces. The following
+ * table lists the interfaces extended by olap4j: If you are using a connection pool, you cannot safely cast a
+ * {@link Connection} to an {@link OlapConnection}, or a {@link Statement} to
+ * a {@link OlapStatement}. Use the appropriate
+ * {@link #convert(java.sql.Connection)} method, and the resulting object will
+ * implement the necessary interface and also implement the behavior required
+ * by the connection pool in order to manage sub-objects safely.
+ *
+ * We plan to support common connection-pooling libraries:
+ * The connection produced by an olap4j driver will already implement the
+ * The statement produced by an olap4j driver will already implement the
+ * The prepared statement produced by an olap4j driver will already
+ * implement the The result set eproduced by an olap4j driver will already
+ * implement the The Methods are provided to query the metadata catalog of the database.
+ * There is a method for each metadata class, and each method takes zero or more
+ * parameters to qualify the instances should be returned, and returns a JDBC
+ * {@link java.sql.ResultSet}.
+ *
+ * For example, {@link #getCubes} returns the description of a cube.
+ *
+ * @author jhyde
+ * @version $Id: $
+ * @since Oct 12, 2006
+ */
+public interface OlapDatabaseMetaData extends DatabaseMetaData {
+
+ /**
+ * Retrieves a list of descriptions of an Action.
+ *
+ * Specification as for XML/A MDSCHEMA_ACTIONS schema rowset.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getActions() throws SQLException;
+
+ /**
+ * Retrives a list of olap4j data sources that are available on the server.
+ *
+ * Specification as for XML/A DISCOVER_DATASOURCES schema rowset.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getDatasources(
+ String dataSourceName) throws SQLException;
+
+ /**
+ * Retrieves a list of information on supported literals, including data
+ * types and values.
+ *
+ * Specification as for XML/A DISCOVER_LITERALS schema rowset.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getLiterals() throws SQLException;
+
+ /**
+ * Retrieves a list of the standard and provider-specific properties
+ * supported by an olap4j provider. Properties that are not supported by a
+ * provider are not listed in the return result set.
+ *
+ * Specification as for XML/A DISCOVER_PROPERTIES schema rowset.
+ *
+ * Not to be confused with {@link #getProperties()}.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getDatabaseProperties(
+ String dataSourceName) throws SQLException;
+
+ /**
+ * Retrieves a list of descriptions of member and cell Properties.
+ *
+ * Specification as for XML/A MDSCHEMA_PROPERTIES schema rowset.
+ *
+ * Not to be confused with {@link #getDatabaseProperties(String)}.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getProperties() throws SQLException;
+
+ /**
+ * Retrieves a comma-separated list of all of this database's MDX keywords.
+ *
+ * @return the list of this database's MDX keywords
+ * @exception java.sql.SQLException if a database access error occurs
+ */
+ String getMdxKeywords() throws SQLException;
+
+ /**
+ * Retrieves a description of a cube.
+ *
+ * @param catalog a catalog name; must match the catalog name as it
+ * is stored in the database; "" retrieves those without a catalog;
+ * Specification as for XML/A MDSCHEMA_DIMENSIONS schema rowset.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getDimensions() throws SQLException;
+
+ /**
+ * Retrieves a result set describing the functions available to client
+ * applications connected to the database.
+ *
+ * Specification as for XML/A MDSCHEMA_FUNCTIONS schema rowset.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getFunctions() throws SQLException;
+
+ /**
+ * Retrieves a result set describing each hierarchy within a particular
+ * dimension.
+ *
+ * Specification as for XML/A MDSCHEMA_HIERARCHIES schema rowset.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getHierarchies() throws SQLException;
+
+ /**
+ * Retrieves a result set describing each measure within a cube.
+ *
+ * Specification as for XML/A MDSCHEMA_MEASURES schema rowset.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getMeasures() throws SQLException;
+
+ /**
+ * Retrieves a result set describing the members within a database.
+ *
+ * Specification as for XML/A MDSCHEMA_MEMBERS schema rowset.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getMembers() throws SQLException;
+
+ /**
+ * Retrieves a result set describing each level within a particular
+ * hierarchy.
+ *
+ * Specification as for XML/A MDSCHEMA_LEVELS schema rowset.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getLevels() throws SQLException;
+
+ /**
+ * Retrieves a result set describing each calculated set.
+ *
+ * Specification as for XML/A MDSCHEMA_SETS schema rowset.
+ *
+ * todo: document parameters and result set columns
+ */
+ ResultSet getSets() throws SQLException;
+}
+
+// End OlapDatabaseMetaData.java
diff --git a/src/org/olap4j/OlapStatement.java b/src/org/olap4j/OlapStatement.java
index ad2d981..a49f0f4 100644
--- a/src/org/olap4j/OlapStatement.java
+++ b/src/org/olap4j/OlapStatement.java
@@ -41,7 +41,6 @@ public interface OlapStatement extends Statement {
* @return Result
*/
OlapResultSet executeOlapQuery(Query query);
-
}
// End OlapStatement.java
diff --git a/src/org/olap4j/metadata/Cube.java b/src/org/olap4j/metadata/Cube.java
index 7f883ad..04a430b 100644
--- a/src/org/olap4j/metadata/Cube.java
+++ b/src/org/olap4j/metadata/Cube.java
@@ -16,7 +16,8 @@
* @version $Id$
* @since Aug 22, 2006
*/
-public interface Cube {
+public interface Cube extends MetadataElement {
+ Schema getSchema();
NamedList Never returns null. Never returns null.
+ * Result is always the same as Never returns null. Result is always the same as
+ * Never returns null. In regular hierarchies, this is as the same as the level's depth,
+ * but in parent-child and ragged hierarchies the value may be
+ * different. Examples: The largest value is 10 ^ (precision - scale). Hence the largest
+ * An instance of this class means a scalar value of unknown type.
+ * Usually one of the derived classes {@link NumericType},
+ * {@link StringType}, {@link BooleanType} is used instead.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/ScalarType.java#3 $
+ */
+public class ScalarType implements Type {
+ public boolean usesDimension(Dimension dimension, boolean maybe) {
+ return false;
+ }
+
+ public Hierarchy getHierarchy() {
+ return null;
+ }
+
+ public Level getLevel() {
+ return null;
+ }
+
+ public Dimension getDimension() {
+ return null;
+ }
+}
+
+// End ScalarType.java
diff --git a/src/org/olap4j/type/SetType.java b/src/org/olap4j/type/SetType.java
new file mode 100755
index 0000000..1a68213
--- /dev/null
+++ b/src/org/olap4j/type/SetType.java
@@ -0,0 +1,69 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/SetType.java#4 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+import org.olap4j.metadata.Dimension;
+import org.olap4j.metadata.Hierarchy;
+import org.olap4j.metadata.Level;
+
+/**
+ * Set type.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/SetType.java#4 $
+ */
+public class SetType implements Type {
+
+ private final Type elementType;
+
+ /**
+ * Creates a type representing a set of elements of a given type.
+ *
+ * @param elementType The type of the elements in the set, or null if not
+ * known
+ */
+ public SetType(Type elementType) {
+ assert elementType instanceof MemberType ||
+ elementType instanceof TupleType;
+ this.elementType = elementType;
+ }
+
+ /**
+ * Returns the type of the elements of this set.
+ */
+ public Type getElementType() {
+ return elementType;
+ }
+
+ public boolean usesDimension(Dimension dimension, boolean maybe) {
+ if (elementType == null) {
+ return maybe;
+ }
+ return elementType.usesDimension(dimension, maybe);
+ }
+
+ public Dimension getDimension() {
+ return elementType == null ? null :
+ elementType.getDimension();
+ }
+
+ public Hierarchy getHierarchy() {
+ return elementType == null ? null :
+ elementType.getHierarchy();
+ }
+
+ public Level getLevel() {
+ return elementType == null ? null :
+ elementType.getLevel();
+ }
+}
+
+// End SetType.java
diff --git a/src/org/olap4j/type/StringType.java b/src/org/olap4j/type/StringType.java
new file mode 100755
index 0000000..fe3e76f
--- /dev/null
+++ b/src/org/olap4j/type/StringType.java
@@ -0,0 +1,32 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/StringType.java#2 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+import org.olap4j.metadata.Dimension;
+import org.olap4j.metadata.Hierarchy;
+
+/**
+ * The type of a string expression.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/StringType.java#2 $
+ */
+public class StringType extends ScalarType {
+
+ /**
+ * Creates a string type.
+ */
+ public StringType() {
+ }
+
+}
+
+// End StringType.java
diff --git a/src/org/olap4j/type/SymbolType.java b/src/org/olap4j/type/SymbolType.java
new file mode 100755
index 0000000..948a75c
--- /dev/null
+++ b/src/org/olap4j/type/SymbolType.java
@@ -0,0 +1,29 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/SymbolType.java#2 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+/**
+ * The type of a symbolic expression.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/SymbolType.java#2 $
+ */
+public class SymbolType extends ScalarType {
+
+ /**
+ * Creates a symbol type.
+ */
+ public SymbolType() {
+ }
+
+}
+
+// End SymbolType.java
diff --git a/src/org/olap4j/type/TupleType.java b/src/org/olap4j/type/TupleType.java
new file mode 100755
index 0000000..5002e35
--- /dev/null
+++ b/src/org/olap4j/type/TupleType.java
@@ -0,0 +1,68 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/TupleType.java#3 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+import org.olap4j.metadata.Dimension;
+import org.olap4j.metadata.Hierarchy;
+import org.olap4j.metadata.Level;
+
+/**
+ * Tuple type.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/TupleType.java#3 $
+ */
+public class TupleType implements Type {
+ public final Type[] elementTypes;
+
+ /**
+ * Creates a type representing a tuple whose fields are the given types.
+ */
+ public TupleType(Type[] elementTypes) {
+ assert elementTypes != null;
+ this.elementTypes = elementTypes.clone();
+ }
+
+ public boolean usesDimension(Dimension dimension, boolean maybe) {
+ for (Type elementType : elementTypes) {
+ if (elementType.usesDimension(dimension, maybe)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Dimension getDimension() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Hierarchy getHierarchy() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Level getLevel() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Type getValueType() {
+ for (Type elementType : elementTypes) {
+ if (elementType instanceof MemberType) {
+ MemberType memberType = (MemberType) elementType;
+ if (memberType.getDimension().getDimensionType() == Dimension.Type.Measures) {
+ return memberType.getValueType();
+ }
+ }
+ }
+ return new ScalarType();
+ }
+}
+
+// End TupleType.java
diff --git a/src/org/olap4j/type/Type.java b/src/org/olap4j/type/Type.java
index 1407528..58fc3aa 100644
--- a/src/org/olap4j/type/Type.java
+++ b/src/org/olap4j/type/Type.java
@@ -1,22 +1,66 @@
/*
-// $Id: $
+// $Id: //open/mondrian/src/main/org.olap4j.type/Type.java#3 $
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
-// Copyright (C) 2006-2006 Julian Hyde
+// Copyright (C) 2005-2005 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package org.olap4j.type;
+import org.olap4j.metadata.Dimension;
+import org.olap4j.metadata.Hierarchy;
+import org.olap4j.metadata.Level;
+
/**
- * The rules are as follows:
+
+
+
+ Column heading
+ Contents
+
+
+ Column name
+ The name of the column in the output rowset.
+
+
+ Type
+ A description of the data type for the column.
+
+
+ Description
+ A brief description of the purpose of the column.
+
+
+
+ Restriction
+
+ Indicates whether the column can be used to restrict the
+ returned rowset by inclusion in the Restrictions
+ parameter of the Discover method.
+ Yes means that the column is available to
+ use as a Restrictions item to filter results
+ by this field.
+
+
+
+Nullable
+
+ Indicates whether the data must be returned or if a null
+ string is allowed if the column does not apply. Yes
+ means nulls are allowed, and the data is optional.
+ No means that the data is required.
+ 2.6.3.1. getDatasources
+DISCOVER_DATASOURCES
XML for Analysis method.
+
+
+
+
+ Column name
+ Type
+ Description
+ Nullable
+
+
+ DataSourceName
+ string
+ The name of the data source, such as
+ FoodMart 2000.
+ No
+
+
+
+ DataSourceDescription
+
+ string
+
+ A description of the data source, as entered by the
+ publisher.
+
+ Yes
+
+
+
+ URL
+
+ string
+
+ The unique path that shows where to invoke the XML for
+ Analysis methods for that data source.
+
+ Yes
+
+
+
+ DataSourceInfo
+ string
+
+
+ "Provider=MSOLAP;Data Source=Local;"
Yes
+
+
+ ProviderName
+ string
+
+
+ "MSDASQL"
Yes
+
+
+
+ ProviderType
+
+ array
+
+
+
+
+
+ No
+
+
+
+AuthenticationMode
+
+ EnumString
+
+
+ Specification of what type of
+ security mode the data source uses. Values can be one of the following:
+
+
+
+
+ No
+ 2.6.3.2. getDatabaseProperties
+
+DISCOVER_PROPERTIES
XML for Analysis method.
+
+
+
+
+ Column name
+ Type
+ Description
+ Nullable
+
+
+ PROPERTY_NAME
+ string
+ The name of the property.
+ No
+
+
+ PROPERTY_DESCRIPTION
+
+ string
+
+ A localizable text description of the property.
+
+ Yes
+
+
+
+ PROPERTY_TYPE
+
+ string
+
+ The XML data type of the property.
+
+ Yes
+
+
+
+ PROPERTY_ACCESS_TYPE
+
+ EnumString
+
+ Access for the property. The value can be Read, Write,
+ or ReadWrite.
+
+ No
+
+
+
+ IS_REQUIRED
+
+ boolean
+
+ True if a property is required,
+ false if it is not required.
+
+ Yes
+
+
+
+VALUE
+
+ string
+
+ The current value of the property.
+
+ Yes
+ 2.6.3.3 getLiterals
+DISCOVER_LITERALS
XML for Analysis method.
+
+
+
+
+ Column name
+ Type
+ Description
+ Restriction
+ Nullable
+
+
+ LiteralName
+ string
+
+ Yes, as an array
+ No
+
+
+ LiteralValue
+ string
+
+
+
+ No
+
+ Yes
+
+
+
+ LiteralInvalidChars
+
+ string
+
+
+
+ No
+
+ Yes
+
+
+
+ LiteralInvalidStartingChars
+
+ string
+
+ The characters that are not valid as the first character
+ of the literal. If the literal can start with any valid character, this
+ is null.
+
+ No
+
+ Yes
+
+
+
+LiteralMaxLength
+
+ integer
+
+ The maximum number of characters in the literal. If
+ there is no maximum or the maximum is unknown, the value is –1.
+
+ No
+
+ Yes
+ 2.6.3.4. getCubes
+
+ MDSCHEMA_CUBES
XML for Analysis method.
+
+
+
+
+Column name
+ Type indicator
+ Description
+
+
+CATALOG_NAME
+ DBTYPE_WSTR
+ The name of the database.
+
+
+SCHEMA_NAME
+ DBTYPE_WSTR
+ Not supported.
+
+
+CUBE_NAME
+ DBTYPE_WSTR
+ The name of the cube or dimension. Dimension
+ names are prefaced by a dollar sign ($) symbol.
+
+
+CUBE_TYPE
+ DBTYPE_WSTR
+ The type of the cube. Valid values are:
+
+
+
+
+CUBE_GUID
+ DBTYPE_GUID
+ Not supported.
+
+
+CREATED_ON
+ DBTYPE_DBTIMESTAMP
+ Not supported.
+
+
+LAST_SCHEMA_UPDATE
+ DBTYPE_DBTIMESTAMP
+ The time that the cube was last processed.
+
+
+SCHEMA_UPDATED_BY
+ DBTYPE_WSTR
+ Not supported.
+
+
+LAST_DATA_UPDATE
+ DBTYPE_DBTIMESTAMP
+ The time that the cube was last processed.
+
+
+DATA_UPDATED_BY
+ DBTYPE_WSTR
+ Not supported.
+
+
+DESCRIPTION
+ DBTYPE_WSTR
+ A user-friendly description of the cube.
+
+
+IS_DRILLTHROUGH_ENABLED
+ DBTYPE_BOOL
+ A Boolean that always returns true.
+
+
+IS_LINKABLE
+ DBTYPE_BOOL
+ A Boolean that indicates whether a cube can be
+ used in a linked cube.
+
+
+IS_WRITE_ENABLED
+ DBTYPE_BOOL
+ A Boolean that indicates whether a cube is
+ write-enabled.
+
+
+IS_SQL_ENABLED
+ DBTYPE_BOOL
+ A Boolean that indicates whether SQL can be used
+ on the cube.
+
+
+CUBE_CAPTION
+ DBTYPE_WSTR
+ The caption of the cube.
+
+
+BASE_CUBE_NAME
+ DBTYPE_WSTR
+ The name of the source cube if this cube is a
+ perspective cube.
+
+
+ANNOTATIONS
+ DBTYPE_WSTR
+ (Optional) A set of notes, in XML format.
+2.6.3.5. getDimensions
+
+MDSCHEMA_DIMENSIONS
XML for Analysis method.
+
+
+
+
+Column name
+ Type indicator
+ Description
+
+
+CATALOG_NAME
+ DBTYPE_WSTR
+ The name of the database.
+
+
+SCHEMA_NAME
+ DBTYPE_WSTR
+ Not supported.
+
+
+CUBE_NAME
+ DBTYPE_WSTR
+ The name of the cube.
+
+
+DIMENSION_NAME
+ DBTYPE_WSTR
+ The name of the dimension. If a dimension is
+ part of more than one cube or measure group, then
+ there is one row for each unique combination of
+ dimension, measure group, and cube.
+
+
+DIMENSION_UNIQUE_NAME
+ DBTYPE_WSTR
+ The unique name of the dimension.
+
+
+DIMENSION_GUID
+ DBTYPE_GUID
+ Not supported.
+
+
+DIMENSION_CAPTION
+ DBTYPE_WSTR
+ The caption of the dimension. This should be
+ used when displaying the name of the dimension to
+ the user, such as in the user interface or reports.
+
+
+DIMENSION_ORDINAL
+ DBTYPE_UI4
+ The position of the dimension within the cube.
+
+
+DIMENSION_TYPE
+ DBTYPE_I2
+ The type of the dimension. Valid values include:
+
+
+
+
+DIMENSION_CARDINALITY
+ DBTYPE_UI4
+ The number of members in the key attribute.
+
+
+DEFAULT_HIERARCHY
+ DBTYPE_WSTR
+ A hierarchy from the dimension. Preserved for
+ backwards compatibility.
+
+
+DESCRIPTION
+ DBTYPE_WSTR
+ A user-friendly description of the dimension.
+
+
+IS_VIRTUAL
+ DBTYPE_BOOL
+ Always FALSE.
+
+
+IS_READWRITE
+ DBTYPE_BOOL
+ A Boolean that indicates whether the dimension
+ is write-enabled.
+
+
+DIMENSION_UNIQUE_SETTINGS
+ DBTYPE_I4
+ A bitmap that specifies which columns contain
+ unique values if the dimension contains only members
+ with unique names. The following bit value constants
+ are defined in Msmd.h for this bitmap:
+
+
+
+
+
+DIMENSION_MASTER_UNIQUE_NAME
+ DBTYPE_WSTR
+ Always NULL.
+
+
+DIMENSION_IS_VISIBLE
+ DBTYPE_BOOL
+ Always TRUE.
+2.6.3.6. getFunctions
+
+MDSCHEMA_FUNCTIONS
XML for Analysis method.
+
+
+
+
+ Column name
+ Type indicator
+ Description
+
+
+ FUNCTION_NAME
+ DBTYPE_WSTR
+ The name of the function.
+
+
+ DESCRIPTION
+ DBTYPE_WSTR
+ A description of the function.
+
+
+ PARAMETER_LIST
+ DBTYPE_WSTR
+ A comma delimited list of parameters formatted
+ as in Microsoft Visual Basic. For example, a
+ parameter might be Name as String.
+
+
+ RETURN_TYPE
+ DBTYPE_I4
+ The VARTYPE of the return data type of
+ the function.
+
+
+ ORIGIN
+ DBTYPE_I4
+ The origin of the function:
+
+
+
+
+ INTERFACE_NAME
+ DBTYPE_WSTR
+ The name of the interface for user-defined
+ functions
+
+
+ LIBRARY_NAME
+ DBTYPE_WSTR
+ The name of the type library for user-defined
+ functions. NULL for MDX functions.
+
+
+ DLL_NAME
+ DBTYPE_WSTR
+ (Optional) The name of the assembly that
+ implements the user-defined function.
+
+
+ HELP_FILE
+ DBTYPE_WSTR
+ (Optional) The name of the file that contains
+ the help documentation for the user-defined
+ function.
+
+
+ HELP_CONTEXT
+ DBTYPE_I4
+ (Optional) Returns the Help context ID for this
+ function.
+
+
+ OBJECT
+ DBTYPE_WSTR
+ (Optional) The generic name of the object class
+ to which a property applies. For example, the rowset
+ corresponding to the <level_name>.Members function
+ returns "Level".
+
+
+CAPTION
+ DBTYPE_WSTR
+ The display caption for the function.
+ 2.6.3.7. getHierarchies
+MDSCHEMA_HIERARCHIES
XML for Analysis method.
+
+
+
+
+Column name
+ Type indicator
+ Description
+
+
+CATALOG_NAME
+ DBTYPE_WSTR
+ The name of the catalog to which this hierarchy
+ belongs. NULL if the provider does not
+ support catalogs.
+
+
+SCHEMA_NAME
+ DBTYPE_WSTR
+ Not supported
+
+
+CUBE_NAME
+ DBTYPE_WSTR
+ (Required) The name of the cube to which this
+ hierarchy belongs.
+
+
+DIMENSION_UNIQUE_NAME
+ DBTYPE_WSTR
+ The unique name of the dimension to which this
+ hierarchy belongs. For providers that generate
+ unique names by qualification, each component of
+ this name is delimited.
+
+
+HIERARCHY_NAME
+ DBTYPE_WSTR
+ The name of the hierarchy. Blank if there is
+ only a single hierarchy in the dimension. This will
+ always have a value in Microsoft SQL Server 2005
+ Analysis Services (SSAS).
+
+
+HIERARCHY_UNIQUE_NAME
+ DBTYPE_WSTR
+ The unique name of the hierarchy.
+
+
+HIERARCHY_GUID
+ DBTYPE_GUID
+ Not supported
+
+
+HIERARCHY_CAPTION
+ DBTYPE_WSTR
+ A label or a caption associated with the
+ hierarchy. Used primarily for display purposes. If a
+ caption does not exist, HIERARCHY_NAME is
+ returned. If the dimension either does not contain a
+ hierarchy or has just one hierarchy, this column
+ will contain the name of the dimension.
+
+
+DIMENSION_TYPE
+ DBTYPE_I2
+ The type of the dimension. Valid values include
+ the following values:
+
+
+
+
+HIERARCHY_CARDINALITY
+ DBTYPE_UI4
+ The number of members in the hierarchy.
+
+
+DEFAULT_MEMBER
+ DBTYPE_WSTR
+ The default member for this hierarchy. This is a
+ unique name. Every hierarchy must have a default
+ member.
+
+
+ALL_MEMBER
+ DBTYPE_WSTR
+ The member at the highest level of the rollup.
+
+
+DESCRIPTION
+ DBTYPE_WSTR
+ A human-readable description of the hierarchy.
+ NULL if no description exists.
+
+
+STRUCTURE
+ DBTYPE_I2
+ The structure of the hierarchy. Valid values
+ include the following values:
+
+
+
+
+IS_VIRTUAL
+ DBTYPE_BOOL
+ Always returns False.
+
+
+IS_READWRITE
+ DBTYPE_BOOL
+ A Boolean that indicates whether the Write Back
+ to dimension column is enabled.
+
+
+DIMENSION_UNIQUE_SETTINGS
+ DBTYPE_I4
+ Always returns MDDIMENSIONS_MEMBER_KEY_UNIQUE
+ (1).
+
+
+DIMENSION_MASTER_UNIQUE_NAME
+ DBTYPE_WSTR
+ Always returns NULL.
+
+
+DIMENSION_IS_VISIBLE
+ DBTYPE_BOOL
+ Always returns true. If the dimension is
+ not visible, it will not appear in the schema
+ rowset.
+
+
+HIERARCHY_ORDINAL
+ DBTYPE_UI4
+ The ordinal number of the hierarchy across all
+ hierarchies of the cube.
+
+
+DIMENSION_IS_SHARED
+ DBTYPE_BOOL
+ Always returns TRUE.
+
+
+HIERARCHY_IS_VISIBLE
+ DBTYPE_BOOL
+ A Boolean that indicates whether the hieararchy
+ is visible.
+
+
+HIERARCHY_ORIGIN
+ DBTYPE_UI2
+ A bit mask that determines the source of the
+ hierarchy:
+
+
+
+
+HIERARCHY_DISPLAY_FOLDER
+ DBTYPE_WSTR
+ The path to be used when displaying the
+ hierarchy in the user interface. Folder names will
+ be separated by a semicolon (;). Nested folders are
+ indicated by a backslash (\).
+
+
+INSTANCE_SELECTION
+ DBTYPE_UI2
+ A hint to the client application on how to show
+ the hierarchy. Valid values include the following
+ values:
+
+
+ 2.6.3.8. getLevels
+MDSCHEMA_LEVELS
XML for Analysis method.
+
+
+
+
+Column name
+ Type indicator
+ Description
+
+
+CATALOG_NAME
+ DBTYPE_WSTR
+ The name of the catalog to which this level
+ belongs. NULL if the provider does not
+ support catalogs.
+
+
+SCHEMA_NAME
+ DBTYPE_WSTR
+ The name of the schema to which this level
+ belongs. NULL if the provider does not
+ support schemas.
+
+
+CUBE_NAME
+ DBTYPE_WSTR
+ The name of the cube to which this level
+ belongs.
+
+
+DIMENSION_UNIQUE_NAME
+ DBTYPE_WSTR
+ The unique name of the dimension to which this
+ level belongs. For providers that generate unique
+ names by qualification, each component of this name
+ is delimited.
+
+
+HIERARCHY_UNIQUE_NAME
+ DBTYPE_WSTR
+ The unique name of the hierarchy. If the level
+ belongs to more than one hierarchy, there is one row
+ for each hierarchy to which it belongs. For
+ providers that generate unique names by
+ qualification, each component of this name is
+ delimited.
+
+
+LEVEL_NAME
+ DBTYPE_WSTR
+ The name of the level.
+
+
+LEVEL_UNIQUE_NAME
+ DBTYPE_WSTR
+ The properly escaped unique name of the level.
+
+
+LEVEL_GUID
+ DBTYPE_GUID
+ Not supported.
+
+
+LEVEL_CAPTION
+ DBTYPE_WSTR
+ A label or caption associated with the
+ hierarchy. Used primarily for display purposes. If a
+ caption does not exist, LEVEL_NAME is
+ returned.
+
+
+LEVEL_NUMBER
+ DBTYPE_UI4
+ The distance of the level from the root of the
+ hierarchy. Root level is zero (0).
+
+
+LEVEL_CARDINALITY
+ DBTYPE_UI4
+ The number of members in the level.
+
+
+LEVEL_TYPE
+ DBTYPE_I4
+ Type of the level:
+
+
+
+
+DESCRIPTION
+ DBTYPE_WSTR
+ A human-readable description of the level. NULL
+ if no description exists.
+
+
+CUSTOM_ROLLUP_SETTINGS
+ DBTYPE_I4
+ A bitmap that specifies the custom rollup
+ options:
+
+
+
+
+LEVEL_UNIQUE_SETTINGS
+ DBTYPE_I4
+ A bitmap that specifies which columns contain
+ unique values, if the level only has members with
+ unique names or keys. The Msmd.h file defines the
+ following bit value constants for this bitmap:
+
+
+
+
+
+LEVEL_IS_VISIBLE
+ DBTYPE_BOOL
+ A Boolean that indicates whether the level is
+ visible.
+
+
+LEVEL_ORDERING_PROPERTY
+ DBTYPE_WSTR
+ The ID of the attribute that the level is sorted
+ on.
+
+
+LEVEL_DBTYPE
+ DBTYPE_I4
+ The DBTYPE enumeration of the member key
+ column that is used for the level attribute.
+
+
+LEVEL_MASTER_UNIQUE_NAME
+ DBTYPE_WSTR
+ Always returns NULL.
+
+
+LEVEL_NAME_SQL_COLUMN_NAME
+ DBTYPE_WSTR
+ The SQL representation of the level member
+ names.
+
+
+LEVEL_KEY_SQL_COLUMN_NAME
+ DBTYPE_WSTR
+ The SQL representation of the level member key
+ values.
+
+
+LEVEL_UNIQUE_NAME_SQL_COLUMN_NAME
+ DBTYPE_WSTR
+ The SQL representation of the member unique
+ names.
+
+
+LEVEL_ATTRIBUTE_HIERARCHY_NAME
+ DBTYPE_WSTR
+ The name of the attribute hierarchy providing
+ the source of the level.
+
+
+LEVEL_KEY_CARDINALITY
+ DBTYPE_UI2
+ The number of columns in the level key.
+
+
+LEVEL_ORIGIN
+ DBTYPE_UI2
+ A bit map that defines how the level was
+ sourced:
+
+
+ 2.6.3.9. getMeasures
+MDSCHEMA_MEASURES
XML for Analysis method.
+
+
+
+
+Column name
+ Type indicator
+ Length
+ Description
+
+
+CATALOG_NAME
+ DBTYPE_WSTR
+
+ The name of the catalog to which this measure
+ belongs. NULL if the provider does not
+ support catalogs.
+
+
+SCHEMA_NAME
+ DBTYPE_WSTR
+
+ The name of the schema to which this measure
+ belongs. NULL if the provider does not
+ support schemas.
+
+
+CUBE_NAME
+ DBTYPE_WSTR
+
+ The name of the cube to which this measure
+ belongs.
+
+
+MEASURE_NAME
+ DBTYPE_WSTR
+
+ The name of the measure.
+
+
+MEASURE_UNIQUE_NAME
+ DBTYPE_WSTR
+
+ The Unique name of the measure. For providers
+ that generate unique names by qualification, each
+ component of this name is delimited.
+
+
+MEASURE_CAPTION
+ DBTYPE_WSTR
+
+ A label or caption associated with the measure.
+ Used primarily for display purposes. If a caption
+ does not exist, MEASURE_NAME is returned.
+
+
+MEASURE_GUID
+ DBTYPE_GUID
+
+ Not supported.
+
+
+MEASURE_AGGREGATOR
+ DBTYPE_I4
+
+ An enumeration that identifies how a measure was
+ derived. Can be one of the following values:
+
+
+
+
+DATA_TYPE
+ DBTYPE_UI2
+
+ The data type of the measure.
+
+
+NUMERIC_PRECISION
+ DBTYPE_UI2
+
+ The maximum precision of the property if the
+ measure object's data type is exact numeric. NULL
+ for all other property types.
+
+
+NUMERIC_SCALE
+ DBTYPE_I2
+
+ The number of digits to the right of the decimal
+ point if the measure object's type indicator is
+ DBTYPE_NUMERIC or DBTYPE_DECIMAL.
+ Otherwise, this value is NULL.
+
+
+MEASURE_UNITS
+ DBTYPE_WSTR
+
+ Not supported
+
+
+DESCRIPTION
+ DBTYPE_WSTR
+
+ A human-readable description of the measure.
+ NULL if no description exists.
+
+
+EXPRESSION
+ DBTYPE_WSTR
+
+ An expression for the member.
+
+
+MEASURE_IS_VISIBLE
+ DBTYPE_BOOL
+
+ A Boolean that always returns True. If the
+ measure is not visible, it will not be included in
+ the schema rowset.
+
+
+LEVELS_LIST
+ DBTYPE_WSTR
+
+ A string that always returns NULL.
+
+
+MEASURE_NAME_SQL_COLUMN_NAME
+ DBTYPE_WSTR
+
+ The name of the column in the SQL query that
+ corresponds to the measure's name.
+
+
+MEASURE_UNQUALIFIED_CAPTION
+ DBTYPE_WSTR
+
+ The name of the measure, not qualified with the
+ measure group name.
+
+
+MEASUREGROUP_NAME
+ DBTYPE_WSTR
+
+ The name of the measure group to which the
+ measure belongs.
+
+
+MEASURE_DISPLAY_FOLDER
+ DBTYPE_WSTR
+
+ The path to be used when displaying the measure
+ in the user interface. Folder names will be
+ separated by a semicolon. Nested folders are
+ indicated by a backslash (\).
+
+
+DEFAULT_FORMAT_STRING
+ DBTYPE_WSTR
+
+ The default format string for the measure.
+2.6.3.10. getMembers
+MDSCHEMA_MEMBERS
XML for Analysis method.
+
+
+
+
+Column name
+ Type indicator
+ Length
+ Description
+
+
+CATALOG_NAME
+ DBTYPE_WSTR
+
+ The name of the database to which this member
+ belongs.
+
+
+SCHEMA_NAME
+ DBTYPE_WSTR
+
+ The name of the schema to which this member
+ belongs.
+
+
+CUBE_NAME
+ DBTYPE_WSTR
+
+ The name of the cube to which this member
+ belongs.
+
+
+DIMENSION_UNIQUE_NAME
+ DBTYPE_WSTR
+
+ The unique name of the dimension to which this
+ member belongs.
+
+
+HIERARCHY_UNIQUE_NAME
+ DBTYPE_WSTR
+
+ The unique name of the hierarchy to which this
+ member belongs.
+
+
+LEVEL_UNIQUE_NAME
+ DBTYPE_WSTR
+
+ The unique name of the level to which this
+ member belongs.
+
+
+LEVEL_NUMBER
+ DBTYPE_UI4
+
+ The distance of the member from the root of the
+ hierarchy. The root level is zero (0).
+
+
+MEMBER_ORDINAL
+ DBTYPE_UI4
+
+ (Deprecated) Always returns 0.
+
+
+MEMBER_NAME
+ DBTYPE_WSTR
+
+ The name of the member.
+
+
+MEMBER_UNIQUE_NAME
+ DBTYPE_WSTR
+
+ The unique name of the member.
+
+
+MEMBER_TYPE
+ DBTYPE_I4
+
+ The type of the member:
+
+
+
+
+
+MEMBER_GUID
+ DBTYPE_GUID
+
+ The GUID of the member. NULL if no GUID
+ exists.
+
+
+MEMBER_CAPTION
+ DBTYPE_WSTR
+
+ A label or caption associated with the member.
+ Used primarily for display purposes. If a caption
+ does not exist, MEMBER_NAME is returned.
+
+
+CHILDREN_CARDINALITY
+ DBTYPE_UI4
+
+ The number of children that the member has. This
+ can be an estimate, so consumers should not rely on
+ this to be the exact count. Providers should return
+ the best estimate possible.
+
+
+PARENT_LEVEL
+ DBTYPE_UI4
+
+ The distance of the member's parent from the
+ root level of the hierarchy. The root level is zero
+ (0).
+
+
+PARENT_UNIQUE_NAME
+ DBTYPE_WSTR
+
+ The unique name of the member's parent. NULL
+ is returned for any members at the root level.
+
+
+PARENT_COUNT
+ DBTYPE_UI4
+
+ The number of parents that this member has.
+
+
+DESCRIPTION
+ DBTYPE_WSTR
+
+ Always returns NULL.
+
+
+EXPRESSION
+ DBTYPE_WSTR
+
+ The expression for calculations, if the member
+ is of type MDMEMBER_TYPE_FORMULA.
+
+
+MEMBER_KEY
+ DBTYPE_WSTR
+
+ The value of the member's key column. Returns
+ NULL if the member has a composite key.
+
+
+IS_PLACEHOLDERMEMBER
+ DBTYPE_BOOL
+
+ A Boolean that indicates whether a member is a
+ placeholder member for an empty position in a
+ dimension hierarchy.
+
+
+IS_DATAMEMBER
+ DBTYPE_BOOL
+
+ A Boolean that indicates whether the member is a
+ data member.
+
+
+Zero or more additional columns
+ DBTYPE_UI2
+
+ No properties are returned if the members could
+ be returned from multiple levels. For example, if
+ the Tree operator is PARENT and SELF
+ for a non-parent child hierarchy, no member
+ properties are returned.
+2.6.3.11. getProperties
+
+MDSCHEMA_PROPERTIES
XML for Analysis method.
+
+
+
+
+Column name
+ Type indicator
+ Description
+
+
+CATALOG_NAME
+ DBTYPE_WSTR
+ The name of the database.
+
+
+SCHEMA_NAME
+ DBTYPE_WSTR
+ The name of the schema to which this property
+ belongs. NULL if the provider does not
+ support schemas.
+
+
+CUBE_NAME
+ DBTYPE_WSTR
+ The name of the cube.
+
+
+DIMENSION_UNIQUE_NAME
+ DBTYPE_WSTR
+ The unique name of the dimension. For providers
+ that generate unique names by qualification, each
+ component of this name is delimited.
+
+
+HIERARCHY_UNIQUE_NAME
+ DBTYPE_WSTR
+ The unique name of the hierarchy. For providers
+ that generate unique names by qualification, each
+ component of this name is delimited.
+
+
+LEVEL_UNIQUE_NAME
+ DBTYPE_WSTR
+ The unique name of the level to which this
+ property belongs. If the provider does not support
+ named levels, it should return the
+ DIMENSION_UNIQUE_NAME value for this field. For
+ providers that generate unique names by
+ qualification, each component of this name is
+ delimited.
+
+
+MEMBER_UNIQUE_NAME
+ DBTYPE_WSTR
+ The unique name of the member to which the
+ property belongs. Used for data stores that do not
+ support named levels or have properties on a
+ member-by-member basis. If the property applies to
+ all members in a level, this column is NULL.
+ For providers that generate unique names by
+ qualification, each component of this name is
+ delimited.
+
+
+PROPERTY_TYPE
+ DBTYPE_I2
+ A bitmap that specifies the type of the
+ property:
+
+
+
+
+PROPERTY_NAME
+ DBTYPE_WSTR
+ The name of the property. If the key for the
+ property is the same as the name for the property,
+ PROPERTY_NAME will be blank.
+
+
+PROPERTY_CAPTION
+ DBTYPE_WSTR
+ A label or caption associated with the property,
+ used primarily for display purposes. Returns
+ PROPERTY_NAME if a caption does not exist.
+
+
+DATA_TYPE
+ DBTYPE_UI2
+ The data type of the property.
+
+
+CHARACTER_MAXIMUM_LENGTH
+ DBTYPE_UI4
+ The maximum possible length of the property, if
+ it is a character, binary, or bit type.
+
+
+CHARACTER_OCTET_LENGTH
+ DBTYPE_UI4
+ The maximum possible length (in bytes) of the
+ property, if it is a character or binary type.
+
+
+NUMERIC_PRECISION
+ DBTYPE_UI2
+ The maximum precision of the property, if it is
+ a numeric data type.
+
+
+NUMERIC_SCALE
+ DBTYPE_I2
+ The number of digits to the right of the decimal
+ point, if it is a DBTYPE_NUMERIC or
+ DBTYPE_DECIMAL type.
+
+
+DESCRIPTION
+ DBTYPE_WSTR
+ A human readable description of the property.
+ NULL if no description exists.
+
+
+PROPERTY_CONTENT_TYPE
+ DBTYPE_I2
+ The type of the property. Can be one of the
+ following enumerations:
+
+
+
+
+SQL_COLUMN_NAME
+ DBTYPE_WSTR
+ The name of the property used in SQL queries
+ from the cube dimension or database dDimension.
+
+
+LANGUAGE
+ DBTYPE_UI2
+ The translation expressed as an LCID.
+ Only valid for property translations.
+
+
+PROPERTY_ORIGIN
+ DBTYPE_UI2
+ Identifies the type of hierarchy that the
+ property applies to:
+
+
+
+
+PROPERTY_ATTRIBUTE_HIERARCHY_NAME
+ DBTYPE_WSTR
+ The name of the attribute hierarchy sourcing
+ this property.
+
+
+PROPERTY_CARDINALITY
+ DBTYPE_WSTR
+ The cardinality of the property. Possible values
+ include the following strings:
+
+
+
+
+MIME_TYPE
+ DBTYPE_WSTR
+ The mime type for binary large objects (BLOBs).
+
+
+PROPERTY_IS_VISIBLE
+ DBTYPE_BOOL
+ A Boolean that indicates whether the property is
+ visible.
+2.6.3.12. getSets
+MDSCHEMA_SETS
XML for Analysis method.
+
+
+
+
+ Column name
+ Type indicator
+ Description
+
+
+ CATALOG_NAME
+ DBTYPE_WSTR
+ The name of the database.
+
+
+ SCHEMA_NAME
+ DBTYPE_WSTR
+ Not supported.
+
+
+ CUBE_NAME
+ DBTYPE_WSTR
+ The name of the cube.
+
+
+ SET_NAME
+ DBTYPE_WSTR
+ The name of the set, as specified in the
+ CREATE SET statement.
+
+
+ SCOPE
+ DBTYPE_I4
+ The scope of the set:
+
+
+
+
+ DESCRIPTION
+ DBTYPE_WSTR
+ Not supported.
+
+
+ EXPRESSION
+ DBTYPE_WSTR
+ The expression for the set.
+
+
+ DIMENSIONS
+ DBTYPE_WSTR
+ A comma delimited list of hierarchies included
+ in the set.
+
+
+ SET_CAPTION
+ DBTYPE_WSTR
+ A label or caption associated with the set. The
+ label or caption is used primarily for display
+ purposes.
+
+
+SET_DISPLAY_FOLDER
+ DBTYPE_WSTR
+ The path to be used by the user interface when
+ displaying the set. Folder names are separated by a
+ backslash (\), folders are separated by a
+ semicolon (;).
+ 2.6.4. Other methods
+
+
+
+
+
+ Method
+ Description
+
+
+
+ getMdxKeywords()
Returns
+
@@ -620,13 +2831,13 @@
2.6.1. Access control
2.7. Transform
-
{[Product].Members} ON ROWS
FROM [Sales]
@@ -635,7 +2846,7 @@ 2.7. Transform
Order({[Product].Members}, [Measures].[Unit Sales], ASC) ON ROWS
FROM [Sales]
@@ -647,9 +2858,9 @@ 2.7. Transform
2.8. Layout
-org.olap4j.layout
2.8. Layout
3. Other components
-3.1. Test suite
-3.2. XML/A provider
-4. Non-functionality
-
5. Related projects
5.1. Mondrian provider
-5.2. JPivot
-5.3. Other data sources
-Appendix A. Opportunities for specification
-Date and Time types
+A.1. Date and Time types
-Schema notification
+A.2. Schema notification
-A.3. Writethrough/Writeback
+Appendix B. Feedback
@@ -757,7 +2972,11 @@ JDK version
targeting JDK 1.5, and running retroweaver for backward compatibility for JDK
1.4.
Appendix D. Miscellaneous
+D.1. To be specified
Appendix E. References
+
diff --git a/src/org/olap4j/Olap4j.java b/src/org/olap4j/Olap4j.java
new file mode 100644
index 0000000..312bcae
--- /dev/null
+++ b/src/org/olap4j/Olap4j.java
@@ -0,0 +1,237 @@
+/*
+// $Id: $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2006-2006 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j;
+
+import org.olap4j.mdx.parser.MdxParserFactory;
+
+import java.sql.*;
+
+/**
+ * Miscellaneous utility functions, in particular dealing with the wrapped
+ * objects created by connection pools.
+ *
+ *
+ *
+ *
+ *
+ *
+ * olap4j class
+ * extends JDBC class
+ * created by
+ *
+ *
+ * {@link OlapConnection}
+ *
+ * {@link Connection}
+ *
+ *
+ *
+ * {@link DriverManager#getConnection(String) Connection DriverManager.getConnection(String)}
{@link javax.sql.DataSource#getConnection() Connection DataSource.getConnection()}
+ *
+ * {@link OlapStatement}
+ *
+ * {@link Statement}
+ *
+ *
+ *
+ * {@link java.sql.Connection#createStatement() Statement Connection.createStatement()}
+ *
+ * {@link PreparedOlapStatement}
+ *
+ * {@link PreparedStatement}
+ *
+ *
+ *
+ * {@link Connection#prepareStatement(String) PreparedStatement Connection.prepareStatement(String)}
+ *
+ * {@link OlapResultSet}
+ *
+ * {@link ResultSet}
+ *
+ *
+ *
+ * {@link Statement#execute(String) ResultSet Statement.executeQuery(String)}
{@link PreparedStatement#execute(String) ResultSet PreparedStatement.executeQuery()}
+ *
+ *
+ * @author jhyde
+ * @version $Id: $
+ * @since Oct 13, 2006
+ */
+public class Olap4j {
+ /**
+ * Converts a JDBC connection ({@link java.sql.Connection})
+ * to an olap4j connection ({@link OlapConnection}).
+ *
+ * OlapConnection
interface, but certain connection pools
+ * add wrappers. This method removes those wrappers.
+ */
+ public static OlapConnection convert(Connection connection) {
+ return adapterFor(connection).convert(connection);
+ }
+
+ /**
+ * Converts a JDBC statement ({@link java.sql.Statement})
+ * to an olap4j statement ({@link OlapStatement}).
+ *
+ * OlapStatement
interface, but certain connection pools
+ * add wrappers. This method removes those wrappers.
+ */
+ public static OlapStatement convert(Statement stmt) {
+ return adapterFor(stmt).convert(stmt);
+ }
+
+ /**
+ * Converts a JDBC prepared statement ({@link java.sql.Connection})
+ * to an olap4j prepared statement ({@link PreparedOlapStatement}).
+ *
+ * PreparedOlapStatement
interface, but certain
+ * connection pools add wrappers. This method removes those wrappers.
+ */
+ public static PreparedOlapStatement convert(PreparedStatement pstmt) {
+ return adapterFor(pstmt).convert(pstmt);
+ }
+
+ /**
+ * Converts a JDBC result set ({@link java.sql.ResultSet})
+ * to an olap4j result set ({@link OlapResultSet}).
+ *
+ * OlapResultSet
interface, but certain
+ * connection pools add wrappers. This method removes those wrappers.
+ */
+ public static OlapResultSet convert(ResultSet resultSet) {
+ return adapterFor(resultSet).convert(resultSet);
+ }
+
+ /**
+ * Converts a JDBC result set ({@link java.sql.DatabaseMetaData})
+ * to an olap4j result set ({@link OlapDatabaseMetaData}).
+ *
+ * DatabaseMetaData
eproduced by an olap4j driver will
+ * already implement the OlapDatabaseMetaData
interface, but
+ * certain connection pools add wrappers. This method removes those
+ * wrappers.
+ */
+ public static OlapDatabaseMetaData convert(DatabaseMetaData metadata) {
+ return adapterFor(metadata).convert(metadata);
+ }
+
+ /**
+ * Helper method to automatically create the right adapter to unpack a
+ * connection.
+ */
+ private static Adapter adapterFor(Connection connection) {
+ return CastingAdapter.INSTANCE;
+ }
+
+ /**
+ * Helper method to automatically create the right adapter to unpack a
+ * statement.
+ */
+ private static Adapter adapterFor(Statement stmt) {
+ return CastingAdapter.INSTANCE;
+ }
+
+ /**
+ * Helper method to automatically create the right adapter to unpack a
+ * prepared statement.
+ */
+ private static Adapter adapterFor(PreparedStatement pstmt) {
+ return CastingAdapter.INSTANCE;
+ }
+
+ /**
+ * Helper method to automatically create the right adapter to unpack a
+ * database metadata.
+ */
+ private static Adapter adapterFor(DatabaseMetaData metadata) {
+ return CastingAdapter.INSTANCE;
+ }
+
+ /**
+ * Helper method to automatically create the right adapter to unpack a
+ * result set.
+ */
+ private static Adapter adapterFor(ResultSet resultSet) {
+ return CastingAdapter.INSTANCE;
+ }
+
+ public static MdxParserFactory getParserFactory(Connection connection) {
+ return convert(connection).getParserFactory();
+ }
+
+ /**
+ * Specification for a helper which can remove the wrappers added by
+ * certain connection pools.
+ */
+ private static interface Adapter {
+ OlapConnection convert(Connection connection);
+ OlapStatement convert(Statement stmt);
+ PreparedOlapStatement convert(PreparedStatement pstmt);
+ OlapDatabaseMetaData convert(DatabaseMetaData metadata);
+ OlapResultSet convert(ResultSet resultSet);
+ }
+
+
+ /**
+ * Implementation of {@link Adapter} which simply casts objects to the
+ * desired type.
+ */
+ private static class CastingAdapter implements Adapter {
+ private static final Adapter INSTANCE = new CastingAdapter();
+
+ public OlapConnection convert(Connection connection) {
+ return (OlapConnection) connection;
+ }
+
+ public OlapStatement convert(Statement stmt) {
+ return (OlapStatement) stmt;
+ }
+
+ public PreparedOlapStatement convert(PreparedStatement pstmt) {
+ return (PreparedOlapStatement) pstmt;
+ }
+
+ public OlapDatabaseMetaData convert(DatabaseMetaData metadata) {
+ return (OlapDatabaseMetaData) metadata;
+ }
+
+ public OlapResultSet convert(ResultSet resultSet) {
+ return (OlapResultSet) resultSet;
+ }
+ }
+}
+
+// End Olap4j.java
diff --git a/src/org/olap4j/OlapConnection.java b/src/org/olap4j/OlapConnection.java
index f6981c4..1a29a41 100644
--- a/src/org/olap4j/OlapConnection.java
+++ b/src/org/olap4j/OlapConnection.java
@@ -13,6 +13,7 @@
import java.sql.Connection;
import java.sql.SQLException;
+import java.sql.Statement;
/**
* Connection to an OLAP server.
@@ -32,6 +33,12 @@ public interface OlapConnection extends Connection {
* Returns the factory used to create MDX parsers in this connection.
*/
MdxParserFactory getParserFactory();
+
+ /**
+ * Override {@link java.sql.Connection#createStatement()} with refined
+ * result type.
+ */
+ OlapStatement createStatement() throws SQLException;
}
// End OlapConnection.java
diff --git a/src/org/olap4j/OlapDatabaseMetaData.java b/src/org/olap4j/OlapDatabaseMetaData.java
new file mode 100644
index 0000000..102afa7
--- /dev/null
+++ b/src/org/olap4j/OlapDatabaseMetaData.java
@@ -0,0 +1,181 @@
+/*
+// $Id: $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2006-2006 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j;
+
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * Information about an OLAP database.
+ *
+ * null
means that the catalog name should not be used to narrow
+ * the search
+ * @param schemaPattern a schema name pattern; must match the schema name
+ * as it is stored in the database; "" retrieves those without a schema;
+ * null
means that the schema name should not be used to narrow
+ * the search
+ * @param cubeNamePattern a cube name pattern; must match the
+ * cube name as it is stored in the database
+ * @return ResultSet
- each row is a cube description
+ */
+ public ResultSet getCubes(
+ String catalog,
+ String schemaPattern,
+ String cubeNamePattern) throws SQLException;
+ /**
+ * Retrieves a result set describing the shared and private dimensions
+ * within a database.
+ *
+ * getHierarchy().getDimension()
.)
+ */
+ Dimension getDimension();
+
/**
* Returns the type of this Level.
*/
diff --git a/src/org/olap4j/metadata/Measure.java b/src/org/olap4j/metadata/Measure.java
new file mode 100644
index 0000000..6f5d8b4
--- /dev/null
+++ b/src/org/olap4j/metadata/Measure.java
@@ -0,0 +1,22 @@
+/*
+// $Id: $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2006-2006 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.metadata;
+
+/**
+ * Measure
...
+ *
+ * @author jhyde
+ * @version $Id: $
+ * @since Oct 13, 2006
+ */
+public interface Measure extends Member {
+}
+
+// End Measure.java
diff --git a/src/org/olap4j/metadata/Member.java b/src/org/olap4j/metadata/Member.java
index 8ba2db5..f3624ee 100644
--- a/src/org/olap4j/metadata/Member.java
+++ b/src/org/olap4j/metadata/Member.java
@@ -13,6 +13,7 @@
import mondrian.olap.Property;
import java.sql.SQLException;
+import java.util.List;
/**
* Member
is a data value in a in an OLAP Dimension.
@@ -21,9 +22,7 @@
* @version $Id$
* @since Aug 22, 2006
*/
-public interface Member {
- String getName();
-
+public interface Member extends MetadataElement {
/**
* Returns the children of this Member, indexed by name.
*
@@ -38,17 +37,32 @@ public interface Member {
Member getParentMember();
/**
- * Returns the level of this Member.
+ * Returns the Level of this Member.
+ *
+ * getLevel().getHierarchy()
.
*/
Hierarchy getHierarchy();
+ /**
+ * Returns the Dimension of this Member.
+ *
+ * getLevel().getHierarchy().getDimension()
.
+ */
+ Dimension getDimension();
+
/**
* Returns the type of this Member.
+ *
+ * this
.
*/
- Member[] getAncestorMembers();
+ Listwith member
@@ -145,7 +159,7 @@ private Type(int ordinal) {
/**
* Returns the definitions of the properties this member may have.
*/
- Property[] getProperties();
+ Listlocale
is null or if no caption has been defined for the
+ * element in that locale, returns the caption in base locale.
+ *
+ * @param locale Locale
+ * @return Caption of this element in the given locale, or the base locale;
+ * never null.
+ */
+ String getCaption(Locale locale);
+
+ /**
+ * Returns the description of this element in the given locale.
+ *
+ * If locale
is null or if no description has been defined for
+ * the element in that locale, returns the description in base locale.
+ *
+ * @param locale Locale
+ * @return description of this element in the given locale, or the base
+ * locale; never null.
+ */
+ String getDescription(Locale locale);
+}
+
+// End MetadataElement.java
diff --git a/src/org/olap4j/metadata/Property.java b/src/org/olap4j/metadata/Property.java
index b933817..ed99def 100644
--- a/src/org/olap4j/metadata/Property.java
+++ b/src/org/olap4j/metadata/Property.java
@@ -11,6 +11,8 @@
import mondrian.olap.PropertyFormatter;
+import java.util.Locale;
+
/**
* Definition of a property of a Member or Cell.
*
@@ -18,7 +20,7 @@
* @version $Id$
* @since Aug 23, 2006
*/
-public interface Property {
+public interface Property extends MetadataElement {
/**
* Returns the datatype of this Property.
*/
@@ -29,14 +31,6 @@ public interface Property {
*/
Scope getScope();
- String getDescription();
-
- /**
- * Returns the caption of this property.
- * The default implementation returns the name of the property.
- */
- String getCaption();
-
boolean isInternal();
enum Scope {
@@ -265,22 +259,30 @@ private StandardMemberProperty(
this.description = description;
}
- public Datatype getType() {
- return type;
+ public String getName() {
+ return name();
}
- public Scope getScope() {
- return Scope.MEMBER;
+ public String getUniqueName() {
+ return name();
}
- public String getDescription() {
+ public String getDescription(Locale locale) {
return description;
}
- public String getCaption() {
+ public String getCaption(Locale locale) {
return name();
}
+ public Datatype getType() {
+ return type;
+ }
+
+ public Scope getScope() {
+ return Scope.MEMBER;
+ }
+
public boolean isInternal() {
return internal;
}
@@ -384,18 +386,26 @@ public Scope getScope() {
return Scope.CELL;
}
- public String getDescription() {
- return description;
+ public String getName() {
+ return name();
}
- public PropertyFormatter getFormatter() {
- return null;
+ public String getUniqueName() {
+ return name();
}
- public String getCaption() {
+ public String getCaption(Locale locale) {
return name();
}
+ public String getDescription(Locale locale) {
+ return description;
+ }
+
+ public PropertyFormatter getFormatter() {
+ return null;
+ }
+
public boolean isInternal() {
return internal;
}
diff --git a/src/org/olap4j/metadata/Schema.java b/src/org/olap4j/metadata/Schema.java
new file mode 100644
index 0000000..af0075d
--- /dev/null
+++ b/src/org/olap4j/metadata/Schema.java
@@ -0,0 +1,23 @@
+/*
+// $Id: $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2006-2006 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.metadata;
+
+/**
+ * Schema
...
+ *
+ * @author jhyde
+ * @version $Id: $
+ * @since Oct 13, 2006
+ */
+public interface Schema {
+ NamedList
+ *
+ *
+ * DECIMAL(5, -3)
value is 10 ^ 8.
+ *
+ * @param precision Maximum number of decimal digits which a value of
+ * this type can have.
+ * Must be greater than zero.
+ * Use {@link Integer#MAX_VALUE} if the precision is unbounded.
+ * @param scale Number of digits to the right of the decimal point.
+ */
+ public DecimalType(int precision, int scale) {
+ super();
+ assert precision > 0 : "expected precision > 0";
+ this.precision = precision;
+ this.scale = scale;
+ }
+
+ /**
+ * Returns the maximum number of decimal digits which a value of
+ * this type can have.
+ */
+ public int getPrecision() {
+ return precision;
+ }
+
+ /**
+ * Returns the number of digits to the right of the decimal point.
+ */
+ public int getScale() {
+ return scale;
+ }
+
+ public String toString() {
+ return precision == Integer.MAX_VALUE ?
+ "DECIMAL(" + scale + ")" :
+ "DECIMAL(" + precision + ", " + scale + ")";
+ }
+}
+
+// End DecimalType.java
diff --git a/src/org/olap4j/type/DimensionType.java b/src/org/olap4j/type/DimensionType.java
new file mode 100755
index 0000000..8e95077
--- /dev/null
+++ b/src/org/olap4j/type/DimensionType.java
@@ -0,0 +1,79 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/DimensionType.java#5 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+import org.olap4j.metadata.Dimension;
+import org.olap4j.metadata.Hierarchy;
+import org.olap4j.metadata.Level;
+
+/**
+ * The type of an expression which represents a Dimension.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/DimensionType.java#5 $
+ */
+public class DimensionType implements Type {
+ private final Dimension dimension;
+ private final String digest;
+
+ public static final DimensionType Unknown = new DimensionType(null);
+
+ /**
+ * Creates a type representing a dimension.
+ *
+ * @param dimension Dimension that values of this type must belong to.
+ * Null if the dimension is unknown.
+ */
+ public DimensionType(Dimension dimension) {
+ this.dimension = dimension;
+ StringBuffer buf = new StringBuffer("DimensionType<");
+ if (dimension != null) {
+ buf.append("dimension=").append(dimension.getUniqueName());
+ }
+ buf.append(">");
+ this.digest = buf.toString();
+ }
+
+ public static DimensionType forDimension(Dimension dimension) {
+ return new DimensionType(dimension);
+ }
+
+ public static DimensionType forType(Type type) {
+ return new DimensionType(type.getDimension());
+ }
+
+ public boolean usesDimension(Dimension dimension, boolean maybe) {
+ return this.dimension == dimension ||
+ (maybe && this.dimension == null);
+ }
+
+ public Hierarchy getHierarchy() {
+ return dimension == null ?
+ null :
+ dimension.getHierarchies().size() > 1 ?
+ null :
+ dimension.getHierarchies().get(0);
+ }
+
+ public Level getLevel() {
+ return null;
+ }
+
+ public Dimension getDimension() {
+ return dimension;
+ }
+
+ public String toString() {
+ return digest;
+ }
+}
+
+// End DimensionType.java
diff --git a/src/org/olap4j/type/HierarchyType.java b/src/org/olap4j/type/HierarchyType.java
new file mode 100755
index 0000000..6e38435
--- /dev/null
+++ b/src/org/olap4j/type/HierarchyType.java
@@ -0,0 +1,75 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/HierarchyType.java#5 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+import org.olap4j.metadata.Hierarchy;
+import org.olap4j.metadata.Dimension;
+import org.olap4j.metadata.Level;
+
+/**
+ * The type of an expression which represents a hierarchy.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/HierarchyType.java#5 $
+ */
+public class HierarchyType implements Type {
+ private final Dimension dimension;
+ private final Hierarchy hierarchy;
+ private final String digest;
+
+ /**
+ * Creates a type representing a hierarchy.
+ */
+ public HierarchyType(Dimension dimension, Hierarchy hierarchy) {
+ this.dimension = dimension;
+ this.hierarchy = hierarchy;
+ StringBuffer buf = new StringBuffer("HierarchyType<");
+ if (hierarchy != null) {
+ buf.append("hierarchy=").append(hierarchy.getUniqueName());
+ } else if (dimension != null) {
+ buf.append("dimension=").append(dimension.getUniqueName());
+ }
+ buf.append(">");
+ this.digest = buf.toString();
+
+ }
+
+ public static HierarchyType forHierarchy(Hierarchy hierarchy) {
+ return new HierarchyType(hierarchy.getDimension(), hierarchy);
+ }
+
+ public static HierarchyType forType(Type type) {
+ return new HierarchyType(type.getDimension(), type.getHierarchy());
+ }
+
+ public boolean usesDimension(Dimension dimension, boolean maybe) {
+ return this.dimension == dimension ||
+ (maybe && this.dimension == null);
+ }
+
+ public Dimension getDimension() {
+ return dimension;
+ }
+
+ public Hierarchy getHierarchy() {
+ return hierarchy;
+ }
+
+ public Level getLevel() {
+ return null;
+ }
+
+ public String toString() {
+ return digest;
+ }
+}
+
+// End HierarchyType.java
diff --git a/src/org/olap4j/type/LevelType.java b/src/org/olap4j/type/LevelType.java
new file mode 100755
index 0000000..39ddc42
--- /dev/null
+++ b/src/org/olap4j/type/LevelType.java
@@ -0,0 +1,103 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/LevelType.java#5 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+import org.olap4j.metadata.Level;
+import org.olap4j.metadata.Dimension;
+import org.olap4j.metadata.Hierarchy;
+
+/**
+ * The type of an expression which represents a level.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/LevelType.java#5 $
+ */
+public class LevelType implements Type {
+ private final Dimension dimension;
+ private final Hierarchy hierarchy;
+ private final Level level;
+ private final String digest;
+
+ /**
+ * Creates a type representing a level.
+ *
+ * @param dimension
+ * @param hierarchy Hierarchy which values of this type must belong to, or
+ * null if not known
+ * @param level Level which values of this type must belong to, or null if
+ */
+ public LevelType(Dimension dimension, Hierarchy hierarchy, Level level) {
+ this.dimension = dimension;
+ this.hierarchy = hierarchy;
+ this.level = level;
+ if (level != null) {
+ assert hierarchy != null : "hierarchy != null";
+ assert level.getHierarchy() == hierarchy :
+ "level.getHierarchy() == hierarchy";
+ }
+ if (hierarchy != null) {
+ assert dimension != null : "dimension != null";
+ assert hierarchy.getDimension() == dimension :
+ "hierarchy.getDimension() == dimension";
+ }
+ StringBuffer buf = new StringBuffer("LevelType<");
+ if (level != null) {
+ buf.append("level=").append(level.getUniqueName());
+ } else if (hierarchy != null) {
+ buf.append("hierarchy=").append(hierarchy.getUniqueName());
+ } else if (dimension != null) {
+ buf.append("dimension=").append(dimension.getUniqueName());
+ }
+ buf.append(">");
+ this.digest = buf.toString();
+ }
+
+ public static LevelType forType(Type type) {
+ return new LevelType(
+ type.getDimension(),
+ type.getHierarchy(),
+ type.getLevel());
+
+ }
+
+ public static LevelType forLevel(Level level) {
+ return new LevelType(
+ level.getDimension(),
+ level.getHierarchy(),
+ level);
+ }
+
+ public boolean usesDimension(Dimension dimension, boolean maybe) {
+ if (this.dimension == null) {
+ return maybe;
+ } else {
+ return this.dimension == dimension;
+ }
+ }
+
+ public Dimension getDimension() {
+ return dimension;
+ }
+
+ public Hierarchy getHierarchy() {
+ return hierarchy;
+ }
+
+ public Level getLevel() {
+ return level;
+ }
+
+ public String toString() {
+ return digest;
+ }
+}
+
+// End LevelType.java
diff --git a/src/org/olap4j/type/MemberType.java b/src/org/olap4j/type/MemberType.java
new file mode 100644
index 0000000..e1fe04c
--- /dev/null
+++ b/src/org/olap4j/type/MemberType.java
@@ -0,0 +1,148 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/MemberType.java#3 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+import org.olap4j.metadata.Member;
+import org.olap4j.metadata.Level;
+import org.olap4j.metadata.Hierarchy;
+import org.olap4j.metadata.Dimension;
+
+/**
+ * The type of an expression which represents a member.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/MemberType.java#3 $
+ */
+public class MemberType implements Type {
+ private final Hierarchy hierarchy;
+ private final Dimension dimension;
+ private final Level level;
+ private final Member member;
+ private final String digest;
+
+ public static final MemberType Unknown = new MemberType(null, null, null, null);
+
+ /**
+ * Creates a type representing a member.
+ *
+ * @param dimension
+ * @param hierarchy Hierarchy the member belongs to, or null if not known.
+ * @param level Level the member belongs to, or null if not known
+ * @param member The precise member, or null if not known
+ */
+ public MemberType(
+ Dimension dimension,
+ Hierarchy hierarchy,
+ Level level,
+ Member member) {
+ this.dimension = dimension;
+ this.hierarchy = hierarchy;
+ this.level = level;
+ this.member = member;
+ if (member != null) {
+ assert level != null;
+ assert member.getLevel() == level;
+ }
+ if (level != null) {
+ assert hierarchy != null;
+ assert level.getHierarchy() == hierarchy;
+ }
+ if (hierarchy != null) {
+ assert dimension != null;
+ assert hierarchy.getDimension() == dimension;
+ }
+ StringBuffer buf = new StringBuffer("MemberType<");
+ if (member != null) {
+ buf.append("member=").append(member.getUniqueName());
+ } else if (level != null) {
+ buf.append("level=").append(level.getUniqueName());
+ } else if (hierarchy != null) {
+ buf.append("hierarchy=").append(hierarchy.getUniqueName());
+ } else if (dimension != null) {
+ buf.append("dimension=").append(dimension.getUniqueName());
+ }
+ buf.append(">");
+ this.digest = buf.toString();
+ }
+
+ public static MemberType forDimension(Dimension dimension) {
+ return new MemberType(dimension, null, null, null);
+ }
+
+ public static MemberType forHierarchy(Hierarchy hierarchy) {
+ return new MemberType(
+ hierarchy.getDimension(),
+ hierarchy,
+ null,
+ null);
+ }
+
+ public static MemberType forLevel(Level level) {
+ return new MemberType(
+ level.getDimension(),
+ level.getHierarchy(),
+ level,
+ null);
+ }
+
+ public static MemberType forMember(Member member) {
+ return new MemberType(
+ member.getDimension(),
+ member.getHierarchy(),
+ member.getLevel(),
+ member);
+ }
+
+ public String toString() {
+ return digest;
+ }
+
+ public Hierarchy getHierarchy() {
+ return hierarchy;
+ }
+
+ public Level getLevel() {
+ return level;
+ }
+
+ public boolean usesDimension(Dimension dimension, boolean maybe) {
+ if (this.dimension == null) {
+ return maybe;
+ } else {
+ return this.dimension == dimension ||
+ (maybe && this.dimension == null);
+ }
+ }
+
+ public Type getValueType() {
+ // todo: when members have more type information (double vs. integer
+ // vs. string), return better type if member != null.
+ return new ScalarType();
+ }
+
+ public Dimension getDimension() {
+ return dimension;
+ }
+
+ public static MemberType forType(Type type) {
+ if (type instanceof MemberType) {
+ return (MemberType) type;
+ } else {
+ return new MemberType(
+ type.getDimension(),
+ type.getHierarchy(),
+ type.getLevel(),
+ null);
+ }
+ }
+}
+
+// End MemberType.java
diff --git a/src/org/olap4j/type/NullType.java b/src/org/olap4j/type/NullType.java
new file mode 100755
index 0000000..d53d88b
--- /dev/null
+++ b/src/org/olap4j/type/NullType.java
@@ -0,0 +1,28 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/NullType.java#1 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+/**
+ * The type of a null expression.
+ *
+ * @author medstat
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/NullType.java#1 $
+ * @since Aug 21, 2006
+ */
+public class NullType extends ScalarType
+{
+ /**
+ * Creates a null type.
+ */
+ public NullType()
+ {
+ }
+}
+// End NullType.java
diff --git a/src/org/olap4j/type/NumericType.java b/src/org/olap4j/type/NumericType.java
new file mode 100755
index 0000000..899f554
--- /dev/null
+++ b/src/org/olap4j/type/NumericType.java
@@ -0,0 +1,35 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/NumericType.java#3 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+import org.olap4j.metadata.Dimension;
+import org.olap4j.metadata.Hierarchy;
+
+/**
+ * The type of a numeric expression.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/NumericType.java#3 $
+ */
+public class NumericType extends ScalarType {
+
+ /**
+ * Creates a numeric type.
+ */
+ public NumericType() {
+ }
+
+ public String toString() {
+ return "NUMERIC";
+ }
+}
+
+// End NumericType.java
diff --git a/src/org/olap4j/type/ScalarType.java b/src/org/olap4j/type/ScalarType.java
new file mode 100755
index 0000000..8b8195b
--- /dev/null
+++ b/src/org/olap4j/type/ScalarType.java
@@ -0,0 +1,45 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/ScalarType.java#3 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+import org.olap4j.metadata.Dimension;
+import org.olap4j.metadata.Hierarchy;
+import org.olap4j.metadata.Level;
+
+/**
+ * Base class for types which represent scalar values.
+ *
+ * Type
...
+ * Type of an MDX expression.
*
* @author jhyde
- * @version $Id: $
- * @since Oct 12, 2006
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/Type.java#3 $
*/
-public class Type {
+public interface Type {
+ /**
+ * Returns whether this type contains a given dimension.
+ *
+ *
+ * The DimensionType([Gender])
uses only the
+ * [Gender]
dimension.TupleType(MemberType([Gender]), MemberType([Store]))
+ * uses [Gender]
and [Store]
+ * dimensions.maybe
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.
+ *
+ * @param dimension Dimension
+ * @param maybe If true, returns true only if this type definitely
+ * uses the dimension
+ */
+ boolean usesDimension(Dimension dimension, boolean maybe);
+
+ /**
+ * Returns the dimension of this type, or null if not known.
+ */
+ Dimension getDimension();
+
+ /**
+ * Returns the hierarchy of this type. If not applicable, throws.
+ */
+ Hierarchy getHierarchy();
+
+ /**
+ * Returns the level of this type, or null if not known.
+ */
+ Level getLevel();
+
}
// End Type.java
diff --git a/src/org/olap4j/type/TypeUtil.java b/src/org/olap4j/type/TypeUtil.java
new file mode 100755
index 0000000..bc52cb4
--- /dev/null
+++ b/src/org/olap4j/type/TypeUtil.java
@@ -0,0 +1,161 @@
+/*
+// $Id: //open/mondrian/src/main/org.olap4j.type/TypeUtil.java#5 $
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2005-2005 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.type;
+
+import org.olap4j.metadata.Hierarchy;
+
+/**
+ * Utility methods relating to types.
+ *
+ * @author jhyde
+ * @since Feb 17, 2005
+ * @version $Id: //open/mondrian/src/main/org.olap4j.type/TypeUtil.java#5 $
+ */
+public class TypeUtil {
+
+ /**
+ * Given a set type, returns the element type. Or its element type, if it
+ * is a set type. And so on.
+ */
+ public static Type stripSetType(Type type) {
+ while (type instanceof SetType) {
+ type = ((SetType) type).getElementType();
+ }
+ return type;
+ }
+
+ /**
+ * Converts a type to a member or tuple type.
+ * If it cannot, returns null.
+ */
+ public static Type toMemberOrTupleType(Type type) {
+ type = stripSetType(type);
+ if (type instanceof TupleType) {
+ return (TupleType) type;
+ } else {
+ return toMemberType(type);
+ }
+ }
+
+ /**
+ * Converts a type to a member type.
+ * If it is a set, strips the set.
+ * If it is a member type, returns the type unchanged.
+ * If it is a dimension, hierarchy or level type, converts it to
+ * a member type.
+ * If it is a tuple, number, string, or boolean, returns null.
+ */
+ public static MemberType toMemberType(Type type) {
+ type = stripSetType(type);
+ if (type instanceof MemberType) {
+ return (MemberType) type;
+ } else if (type instanceof DimensionType ||
+ type instanceof HierarchyType ||
+ type instanceof LevelType) {
+ return MemberType.forType(type);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns whether this type is union-compatible with another.
+ * In general, to be union-compatible, types must have the same
+ * dimensionality.
+ */
+ public static boolean isUnionCompatible(Type type1, Type type2) {
+ if (type1 instanceof TupleType) {
+ TupleType tupleType1 = (TupleType) type1;
+ if (type2 instanceof TupleType) {
+ TupleType tupleType2 = (TupleType) type2;
+ if (tupleType1.elementTypes.length ==
+ tupleType2.elementTypes.length) {
+ for (int i = 0; i < tupleType1.elementTypes.length; i++) {
+ if (!isUnionCompatible(
+ tupleType1.elementTypes[i],
+ tupleType2.elementTypes[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ } else {
+ final MemberType memberType1 = toMemberType(type1);
+ if (memberType1 == null) {
+ return false;
+ }
+ final MemberType memberType2 = toMemberType(type2);
+ if (memberType2 == null) {
+ return false;
+ }
+ final Hierarchy hierarchy1 = memberType1.getHierarchy();
+ final Hierarchy hierarchy2 = memberType2.getHierarchy();
+ return equal(hierarchy1, hierarchy2);
+ }
+ }
+
+ private static boolean equal(
+ final Hierarchy hierarchy1, final Hierarchy hierarchy2) {
+ if (hierarchy1 == null ||
+ hierarchy2 == null ||
+ hierarchy2.getUniqueName().equals(
+ hierarchy1.getUniqueName())) {
+ // They are compatible.
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns whether a value of a given type can be evaluated to a scalar
+ * value.
+ *
+ *
+ *
+ *
+ * @param type Type
+ * @return Whether an expression of this type can be evaluated to yield a
+ * scalar value.
+ */
+ public static boolean canEvaluate(Type type) {
+ return ! (type instanceof SetType ||
+ type instanceof CubeType ||
+ type instanceof LevelType);
+ }
+
+ /**
+ * Returns whether a type is a set type.
+ *
+ * @param type Type
+ * @return Whether a value of this type can be evaluated to yield a set.
+ */
+ public static boolean isSet(Type type) {
+ return type instanceof SetType;
+ }
+
+ public static boolean couldBeMember(Type type) {
+ return type instanceof MemberType ||
+ type instanceof HierarchyType ||
+ type instanceof DimensionType;
+ }
+}
+
+// End TypeUtil.java
diff --git a/src/org/olap4j/type/package.html b/src/org/olap4j/type/package.html
new file mode 100755
index 0000000..a008aa5
--- /dev/null
+++ b/src/org/olap4j/type/package.html
@@ -0,0 +1,6 @@
+
+
+Type system for MDX expessions.
+
+
+