org.eobjects.metamodel
Interface DataContext

All Known Subinterfaces:
UpdateableDataContext
All Known Implementing Classes:
AbstractDataContext, AccessDataContext, CompositeDataContext, CouchDbDataContext, CsvDataContext, DbaseDataContext, ExcelDataContext, FixedWidthDataContext, InterceptableDataContext, JdbcDataContext, MongoDbDataContext, OpenOfficeDataContext, QueryPostprocessDataContext, QueryPostprocessDelegate, XmlDataContext, XmlDomDataContext, XmlSaxDataContext

public interface DataContext

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.

Author:
Kasper Sørensen

Method Summary
 DataSet executeQuery(Query query)
          Executes a query against the DataContext.
 Column getColumnByQualifiedLabel(String columnName)
          Finds a column in the DataContext based on a fully qualified column label.
 Schema getDefaultSchema()
          Gets the default schema of this DataContext.
 Schema getSchemaByName(String name)
          Gets a schema by a specified name.
 String[] getSchemaNames()
          Gets the names of all schemas within this DataContext.
 Schema[] getSchemas()
          Gets all schemas within this DataContext.
 Table getTableByQualifiedLabel(String tableName)
          Finds a table in the DataContext based on a fully qualified table label.
 InitFromBuilder query()
          Starts building a query using the query builder API.
 DataContext refreshSchemas()
          Enforces a refresh of the schemas.
 

Method Detail

refreshSchemas

DataContext refreshSchemas()
Enforces a refresh of the schemas. If not refreshed, cached schema objects may be used.

Returns:
this DataContext

getSchemas

Schema[] getSchemas()
                    throws MetaModelException
Gets all schemas within this DataContext.

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

String[] getSchemaNames()
                        throws MetaModelException
Gets the names of all schemas within this DataContext.

Returns:
an array of valid schema names
Throws:
MetaModelException - if an error occurs retrieving the schema model

getDefaultSchema

Schema getDefaultSchema()
                        throws MetaModelException
Gets the default schema of this DataContext.

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

Schema getSchemaByName(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

query

InitFromBuilder query()
Starts building a query using the query builder API. This way of building queries is the preferred approach since it provides a more type-safe approach to building API's as well as allows the DataContext implementation to be aware of the query building process.

Returns:
a query builder component at the initial position in building a query.

executeQuery

DataSet executeQuery(Query query)
                     throws MetaModelException
Executes a query against the DataContext.

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.

getColumnByQualifiedLabel

Column getColumnByQualifiedLabel(String columnName)
Finds a column in the DataContext based on a fully qualified column label. The qualified label consists of the the schema, table and column name, delimited by a dot (.).

Parameters:
columnName -
Returns:
a column that matches the qualified label, or null if no such column exists

getTableByQualifiedLabel

Table getTableByQualifiedLabel(String tableName)
Finds a table in the DataContext based on a fully qualified table label. The qualified label consists of the the schema and table name, delimited by a dot (.).

Parameters:
tableName -
Returns:
a table that matches the qualified label, or null if no such table exists


Copyright © 2007-2012. All Rights Reserved.