dk.eobjects.metamodel
Class DataContext

java.lang.Object
  extended by dk.eobjects.metamodel.DataContext

public class DataContext
extends java.lang.Object

A DataContext represents the central entry point for interactions with datastores. The DataContext contains of the structure of data (in the form of schemas) and interactions (in the form of queries) with data.


Constructor Summary
DataContext(IDataContextStrategy strategy)
          Creates a DataContext based on a specified IDataContextStrategy.
 
Method Summary
 DataSet executeQuery(Query query)
          Executes a query against the data context.
 Schema getDefaultSchema()
           
 Schema getSchemaByName(java.lang.String name)
          Gets a schema by a specified name
 java.lang.String[] getSchemaNames()
           
 Schema[] getSchemas()
           
 DataContext refreshSchemas()
          Enforces a refresh of the schemas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataContext

public DataContext(IDataContextStrategy strategy)
Creates a DataContext based on a specified IDataContextStrategy. This enables development of custom datastore formats, by developing your own strategy-objects.

Parameters:
strategy -
Method Detail

refreshSchemas

public DataContext refreshSchemas()
Enforces a refresh of the schemas.


getSchemas

public Schema[] getSchemas()
                    throws MetaModelException
Returns:
the schemas in this data context. Schemas are cached for reuse in many situations so if you want to update the schemas, use the refreshSchemas() method.
Throws:
MetaModelException - if an error occurs retrieving the schema model

getSchemaNames

public java.lang.String[] getSchemaNames()
                                  throws MetaModelException
Returns:
an array of valid schema names
Throws:
MetaModelException - if an error occurs retrieving the schema model

getDefaultSchema

public Schema getDefaultSchema()
                        throws MetaModelException
Returns:
the schema that you are most probable to be interested in. The default schema is determined by finding the schema with most available of tables. In a lot of situations there will only be a single available schema and in that case this will of course be the schema returned.
Throws:
MetaModelException - if an error occurs retrieving the schema model

getSchemaByName

public Schema getSchemaByName(java.lang.String name)
                       throws MetaModelException
Gets a schema by a specified name

Parameters:
name - the name of the desired schema
Returns:
the Schema with the specified name or null if no such schema exists
Throws:
MetaModelException - if an error occurs retrieving the schema model

executeQuery

public DataSet executeQuery(Query query)
                     throws MetaModelException
Executes a query against the data context.

Parameters:
query - the query object to execute
Returns:
the dataset produced from executing the query
Throws:
MetaModelException - if the specified query does not make sense or cannot be executed because of restraints on the type of datastore.


Copyright © 2007-2008. All Rights Reserved.