Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.pivot.table
Class TableDataSource

java.lang.Object
  extended by com.citra.pivot.table.TableDataSource
All Implemented Interfaces:
DataSource

public class TableDataSource
extends Object
implements DataSource

TableDataSource is a DataSource implementation that reads from user data and allows for the construction of an OLAP schema, depending on the input data.


Field Summary
static int PRECOMPUTE_ALL
          a constant indicating that all aggregated values should be precomputed
static int PRECOMPUTE_LEAVES
          a constant indicating that only the leaf member values should be precomputed
static int PRECOMPUTE_NOTHING
          a constant indicating that no aggregations should be precomputed
static int PRECOMPUTE_TOP
          a constant indicating that only the first level member values should be precomputed
protected  int preComputeMode
          mask indicating what to precompute when compiling cube
protected  TableSchema schema
          the data source's schema
protected  TableFormatter tableFormatter
          the associated table formatter
 
Constructor Summary
TableDataSource()
          Constructs a TableDataSource.
TableDataSource(TableSchema schema)
          Constructs a TableDataSource.
TableDataSource(TableSchema schema, TableModel flatModel)
          Constructs a TableDataSource.
 
Method Summary
 void compile()
          Compiles the schema and its cubes.
 Connection createConnection()
          Returns a new connection to the datasource.
protected  TableFormatter createDefaultFormatter()
          Creates and returns the default formatter.
 int getPrecomputeMode()
          Retrieves the mode for precomputing aggregate values when the schema and cubes are first compiled.
 OlapSchema getSchema()
          Retrieves the schema of the datasource.
 TableFormatter getTableFormatter()
          Returns the associated formatter.
 Object getValue(TableMeasure msr, TableQuery query)
          Retrieves an aggregated value from the data source.
 boolean isCompiled()
          Determines whether the schema has been compiled.
 void load(ObjectInputStream in)
          Loads the schema and aggregate values from an object inputstream.
 void save(ObjectOutputStream out)
          Saves the schema and aggregate values to an object outputstream.
 void save(ObjectOutputStream out, int preComputeMode)
          Saves the schema and aggregate values to an object outputstream, having precomputed a set of aggregates first according to preComputeMode.
 void setModel(TableModel model)
          Assigns a table model to the datasource.
 void setModel(TableModel model, boolean clear)
          Assigns a table model to the datasource.
 void setPrecomputeMode(int preComputeMode)
          Assigns the mode for precomputing aggregate values when the schema and cubes are first compiled.
 void setSchema(TableSchema schema)
          Assigns a new schema to the data source.
 void setTableFormatter(TableFormatter tableFormatter)
          Assigns a new formatter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRECOMPUTE_NOTHING

public static final int PRECOMPUTE_NOTHING
a constant indicating that no aggregations should be precomputed

See Also:
Constant Field Values

PRECOMPUTE_ALL

public static final int PRECOMPUTE_ALL
a constant indicating that all aggregated values should be precomputed

See Also:
Constant Field Values

PRECOMPUTE_LEAVES

public static final int PRECOMPUTE_LEAVES
a constant indicating that only the leaf member values should be precomputed

See Also:
Constant Field Values

PRECOMPUTE_TOP

public static final int PRECOMPUTE_TOP
a constant indicating that only the first level member values should be precomputed

See Also:
Constant Field Values

schema

protected TableSchema schema
the data source's schema


preComputeMode

protected int preComputeMode
mask indicating what to precompute when compiling cube


tableFormatter

protected TableFormatter tableFormatter
the associated table formatter

Constructor Detail

TableDataSource

public TableDataSource()
Constructs a TableDataSource.


TableDataSource

public TableDataSource(TableSchema schema)
Constructs a TableDataSource.


TableDataSource

public TableDataSource(TableSchema schema,
                       TableModel flatModel)
Constructs a TableDataSource.

Method Detail

compile

public void compile()
             throws DataSourceException
Compiles the schema and its cubes.

Throws:
DataSourceException

createDefaultFormatter

protected TableFormatter createDefaultFormatter()
Creates and returns the default formatter. This is a DefaultTableFormatter.

Returns:
the default table formatter

createConnection

public Connection createConnection()
Returns a new connection to the datasource.

Specified by:
createConnection in interface DataSource
Returns:
a new connection to the datasource

getPrecomputeMode

public int getPrecomputeMode()
Retrieves the mode for precomputing aggregate values when the schema and cubes are first compiled. The mode is a mask, comprising of the following values: PRECOMPUTE_NOTHING, PRECOMPUTE_ALL, PRECOMPUTE_LEAVES, PRECOMPUTE_TOP.

Returns:
the precompute mode

getSchema

public OlapSchema getSchema()
Retrieves the schema of the datasource. The schema serves as a starting point for getting members and making queries.

Specified by:
getSchema in interface DataSource
Returns:
the datasource's schema

getTableFormatter

public TableFormatter getTableFormatter()
Returns the associated formatter.

Returns:
the datasource's table formatter

getValue

public Object getValue(TableMeasure msr,
                       TableQuery query)
                throws DataSourceException
Retrieves an aggregated value from the data source.

Parameters:
msr - the measure for which an aggregate is returned
query - the tuple that contains a list of member parameters
Returns:
the aggregated value
Throws:
DataSourceException

isCompiled

public boolean isCompiled()
Determines whether the schema has been compiled.

Returns:
true if the schema is compiled, false otherwise

load

public void load(ObjectInputStream in)
          throws IOException,
                 DataSourceException
Loads the schema and aggregate values from an object inputstream. This will effectively recreate the datasource.

Parameters:
in - the stream to read from
Throws:
IOException
DataSourceException

save

public void save(ObjectOutputStream out)
          throws IOException,
                 DataSourceException
Saves the schema and aggregate values to an object outputstream.

Parameters:
out - the stream to write to
Throws:
IOException
DataSourceException

save

public void save(ObjectOutputStream out,
                 int preComputeMode)
          throws IOException,
                 DataSourceException
Saves the schema and aggregate values to an object outputstream, having precomputed a set of aggregates first according to preComputeMode.

Parameters:
out - the stream to write to
preComputeMode - the preComputeMode
Throws:
IOException
DataSourceException

setModel

public void setModel(TableModel model)
              throws DataSourceException
Assigns a table model to the datasource. If the datasource has already been compiled, all previous tree member structures and aggregations will be discarded. The model will stay in memory until the datasource has been compiled.

Parameters:
model - the model to assign
Throws:
DataSourceException

setModel

public void setModel(TableModel model,
                     boolean clear)
              throws DataSourceException
Assigns a table model to the datasource. If clear is true and the datasource is already compiled, all previous tree member structures and aggregations will be discarded. If however clear is false, data from the model will be added to those already aggregated. This allows for incremental aggregation. The clear parameter has no effect if the data source is not compiled. The model will stay in memory until the datasource has been compiled.

Parameters:
model - the model to assign
clear - flag that affects whether results from previous aggregations should be kept
Throws:
DataSourceException

setPrecomputeMode

public void setPrecomputeMode(int preComputeMode)
Assigns the mode for precomputing aggregate values when the schema and cubes are first compiled. The mode is a mask, comprising of the following values: PRECOMPUTE_NOTHING, PRECOMPUTE_ALL, PRECOMPUTE_LEAVES, PRECOMPUTE_TOP.

Parameters:
preComputeMode - the precompute mode

setSchema

public void setSchema(TableSchema schema)
               throws DataSourceException
Assigns a new schema to the data source.

Parameters:
schema - the new schema to assign
Throws:
DataSourceException

setTableFormatter

public void setTableFormatter(TableFormatter tableFormatter)
Assigns a new formatter.

Parameters:
tableFormatter - the new formatter to assign

Copyright © 2011 Citra Technologies. All Rights Reserved.