dk.eobjects.metamodel
Class DataContextFactory

Package class diagram package DataContextFactory
java.lang.Object
  extended by dk.eobjects.metamodel.DataContextFactory

public class DataContextFactory
extends java.lang.Object

A factory for DataContext objects. This class substantially easens the task of creating and initializing DataContext objects and their strategies for reading datastores. A lot of the factory methods support column type detection, narrowing and transformation. For details on this approach to datastores.

See Also:
ColumnTypeTransformer, DataContext, IDataContextStrategy

Field Summary
static char DEFAULT_CSV_QUOTE_CHAR
           
static char DEFAULT_CSV_SEPARATOR_CHAR
           
static TableType[] DEFAULT_JDBC_TABLE_TYPES
           
 
Method Summary
static DataContext createAccessDataContext(java.io.File file)
          Creates a DataContext based on a MS Access (.mdb) file
static DataContext createAccessDataContext(java.lang.String filename)
          Creates a DataContext based on a MS Access (.mdb) file
static DataContext createCompositeDataContext(java.util.Collection<DataContext> delegates)
          Creates a composite DataContext based on a set of delegate DataContexts.
static DataContext createCompositeDataContext(DataContext... delegates)
          Creates a composite DataContext based on a set of delegate DataContexts.
static DataContext createCsvDataContext(java.io.File file)
          Creates a DataContext based on a CSV file
static DataContext createCsvDataContext(java.io.File file, boolean transformColumnTypes)
          Creates a DataContext based on a CSV file
static DataContext createCsvDataContext(java.io.File file, char separatorChar, char quoteChar, boolean transformColumnTypes)
          Creates a DataContext based on a CSV file
static DataContext createCsvDataContext(java.io.File file, char separatorChar, char quoteChar, boolean transformColumnTypes, java.lang.String encoding)
          Creates a DataContext based on a CSV file
static DataContext createCsvDataContext(java.io.InputStream inputStream, char separatorChar, char quoteChar, boolean transformColumnTypes)
          Creates a DataContext based on CSV-content through an input stream
static DataContext createDbaseDataContext(java.io.File file)
          Creates a DataContext based on a dBase file
static DataContext createDbaseDataContext(java.lang.String filename)
          Creates a DataContext based on a dBase file
static DataContext createExcelDataContext(java.io.File file)
          Creates a DataContet based on an Excel spreadsheet file
static DataContext createExcelDataContext(java.io.File file, boolean transformColumnTypes)
          Creates a DataContext based on an Excel spreadsheet file
static DataContext createJdbcDataContext(java.sql.Connection connection)
          Creates a DataContext based on a JDBC connection
static DataContext createJdbcDataContext(java.sql.Connection connection, java.lang.String catalogName)
          Creates a DataContext based on a JDBC connection
static DataContext createJdbcDataContext(java.sql.Connection connection, java.lang.String catalogName, TableType[] tableTypes)
          Creates a DataContext based on a JDBC connection
static DataContext createJdbcDataContext(java.sql.Connection connection, TableType... tableTypes)
          Creates a DataContext based on a JDBC connection
static DataContext createJdbcDataContext(javax.sql.DataSource ds)
          Creates a DataContext based on a JDBC datasource
static DataContext createJdbcDataContext(javax.sql.DataSource ds, java.lang.String catalogName)
          Creates a DataContext based on a JDBC datasource
static DataContext createJdbcDataContext(javax.sql.DataSource ds, java.lang.String catalogName, TableType[] tableTypes)
          Creates a DataContext based on a JDBC datasource
static DataContext createJdbcDataContext(javax.sql.DataSource ds, TableType... tableTypes)
          Creates a DataContext based on a JDBC datasource
static DataContext createOpenOfficeDataContext(java.io.File file)
          Creates a DataContext based on an OpenOffice.org database file.
static DataContext createXmlDataContext(java.io.File file, boolean autoFlattenTables, boolean transformColumnTypes)
          Creates a DataContext based on a XML file.
static DataContext createXmlDataContext(org.xml.sax.InputSource inputSource, java.lang.String schemaName, boolean autoFlattenTables, boolean transformColumnTypes)
          Creates a DataContext based on XML-content from an input source.
static DataContext createXmlDataContext(java.net.URL url, boolean autoFlattenTables, boolean transformColumnTypes)
          Creates a DataContext based on XML-content from a URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_JDBC_TABLE_TYPES

public static final TableType[] DEFAULT_JDBC_TABLE_TYPES

DEFAULT_CSV_SEPARATOR_CHAR

public static final char DEFAULT_CSV_SEPARATOR_CHAR
See Also:
Constant Field Values

DEFAULT_CSV_QUOTE_CHAR

public static final char DEFAULT_CSV_QUOTE_CHAR
See Also:
Constant Field Values
Method Detail

createCompositeDataContext

public static DataContext createCompositeDataContext(DataContext... delegates)
Creates a composite DataContext based on a set of delegate DataContexts. Composite DataContexts enables cross-DataContext querying and unified schema exploration

Parameters:
delegates - an array/var-args of delegate DataContexts
Returns:
a DataContext that matches the request

createCompositeDataContext

public static DataContext createCompositeDataContext(java.util.Collection<DataContext> delegates)
Creates a composite DataContext based on a set of delegate DataContexts. Composite DataContexts enables cross-DataContext querying and unified schema exploration

Parameters:
delegates - a collection of delegate DataContexts
Returns:
a DataContext that matches the request

createAccessDataContext

public static DataContext createAccessDataContext(java.lang.String filename)
Creates a DataContext based on a MS Access (.mdb) file

Parameters:
filename - the path to a MS Access (.mdb) file
Returns:
a DataContext object that matches the request

createAccessDataContext

public static DataContext createAccessDataContext(java.io.File file)
Creates a DataContext based on a MS Access (.mdb) file

Parameters:
file - a MS Access (.mdb) file
Returns:
a DataContext object that matches the request

createDbaseDataContext

public static DataContext createDbaseDataContext(java.io.File file)
Creates a DataContext based on a dBase file

Parameters:
file - a dBase (.dbf) file
Returns:
a DataContext object that matches the request

createDbaseDataContext

public static DataContext createDbaseDataContext(java.lang.String filename)
Creates a DataContext based on a dBase file

Parameters:
the - path to a dBase (.dbf) file
Returns:
a DataContext object that matches the request

createCsvDataContext

public static DataContext createCsvDataContext(java.io.File file)
Creates a DataContext based on a CSV file

Parameters:
file - a CSV file
Returns:
a DataContext object that matches the request

createCsvDataContext

public static DataContext createCsvDataContext(java.io.File file,
                                               boolean transformColumnTypes)
Creates a DataContext based on a CSV file

Parameters:
file - a CSV file
transformColumnTypes - a boolean indicating if MetaModel should detect, narrow and transform column types
Returns:
a DataContext object that matches the request

createCsvDataContext

public static DataContext createCsvDataContext(java.io.File file,
                                               char separatorChar,
                                               char quoteChar,
                                               boolean transformColumnTypes)
Creates a DataContext based on a CSV file

Parameters:
file - a CSV file
separatorChar - the char to use for separating values
quoteChar - the char used for quoting values (typically if they include the separator char)
transformColumnTypes - a boolean indicating if MetaModel should detect, narrow and transform column types
Returns:
a DataContext object that matches the request

createCsvDataContext

public static DataContext createCsvDataContext(java.io.File file,
                                               char separatorChar,
                                               char quoteChar,
                                               boolean transformColumnTypes,
                                               java.lang.String encoding)
Creates a DataContext based on a CSV file

Parameters:
file - a CSV file
separatorChar - the char to use for separating values
quoteChar - the char used for quoting values (typically if they include the separator char)
transformColumnTypes - a boolean indicating if MetaModel should detect, narrow and transform column types
encoding - the character encoding of the file
Returns:
a DataContext object that matches the request

createCsvDataContext

public static DataContext createCsvDataContext(java.io.InputStream inputStream,
                                               char separatorChar,
                                               char quoteChar,
                                               boolean transformColumnTypes)
Creates a DataContext based on CSV-content through an input stream

Parameters:
inputStream - the input stream to read from
separatorChar - the char to use for separating values
quoteChar - the char used for quoting values (typically if they include the separator char)
transformColumnTypes - a boolean indicating if MetaModel should detect, narrow and transform column types
Returns:
a DataContext object that matches the request

createExcelDataContext

public static DataContext createExcelDataContext(java.io.File file)
Creates a DataContet based on an Excel spreadsheet file

Parameters:
file - an excel spreadsheet file
Returns:
a DataContext object that matches the request

createExcelDataContext

public static DataContext createExcelDataContext(java.io.File file,
                                                 boolean transformColumnTypes)
Creates a DataContext based on an Excel spreadsheet file

Parameters:
file - an Excel spreadsheet file
transformColumnTypes - a boolean indicating if MetaModel should detect, narrow and transform column types
Returns:
a DataContext object that matches the request

createXmlDataContext

public static DataContext createXmlDataContext(java.io.File file,
                                               boolean autoFlattenTables,
                                               boolean transformColumnTypes)
Creates a DataContext based on a XML file. Tables are created by examining the data in the XML file, NOT by reading XML Schemas (xsd/dtd's). This enables compliancy with ALL xml formats but also raises a risk that two XML files with the same format wont nescesarily yield the same table model if some optional attributes or tags are omitted in one of the files.

Parameters:
file - a XML file
autoFlattenTables - a boolean indicating if MetaModel should flatten very simple table structures (where tables only contain a single data-carrying column) for greater usability of the generated table-based model
transformColumnTypes - a boolean indicating if MetaModel should detect, narrow and transform column types
Returns:
a DataContext object that matches the request

createXmlDataContext

public static DataContext createXmlDataContext(org.xml.sax.InputSource inputSource,
                                               java.lang.String schemaName,
                                               boolean autoFlattenTables,
                                               boolean transformColumnTypes)
Creates a DataContext based on XML-content from an input source. Tables are created by examining the data in the XML file, NOT by reading XML Schemas (xsd/dtd's). This enables compliancy with ALL xml formats but also raises a risk that two XML files with the same format wont nescesarily yield the same table model if some optional attributes or tags are omitted in one of the files.

Parameters:
inputSource - an input source feeding XML content
schemaName - the name to be used for the main schema
autoFlattenTables - a boolean indicating if MetaModel should flatten very simple table structures (where tables only contain a single data-carrying column) for greater usability of the generated table-based model
transformColumnTypes - a boolean indicating if MetaModel should detect, narrow and transform column types
Returns:
a DataContext object that matches the request

createXmlDataContext

public static DataContext createXmlDataContext(java.net.URL url,
                                               boolean autoFlattenTables,
                                               boolean transformColumnTypes)
Creates a DataContext based on XML-content from a URL. Tables are created by examining the data in the XML file, NOT by reading XML Schemas (xsd/dtd's). This enables compliancy with ALL xml formats but also raises a risk that two XML files with the same format wont nescesarily yield the same table model if some optional attributes or tags are omitted in one of the files.

Parameters:
url - the URL to use for feeding XML content
autoFlattenTables - a boolean indicating if MetaModel should flatten very simple table structures (where tables only contain a single data-carrying column) for greater usability of the generated table-based model
transformColumnTypes - a boolean indicating if MetaModel should detect, narrow and transform column types
Returns:
a DataContext object that matches the request

createOpenOfficeDataContext

public static DataContext createOpenOfficeDataContext(java.io.File file)
Creates a DataContext based on an OpenOffice.org database file.

Parameters:
file - an OpenOffice.org database file
Returns:
a DataContext object that matches the request

createJdbcDataContext

public static DataContext createJdbcDataContext(java.sql.Connection connection)
Creates a DataContext based on a JDBC connection

Parameters:
connection - a JDBC connection
Returns:
a DataContext object that matches the request

createJdbcDataContext

public static DataContext createJdbcDataContext(javax.sql.DataSource ds)
Creates a DataContext based on a JDBC datasource

Parameters:
ds - a JDBC datasource
Returns:
a DataContext object that matches the request

createJdbcDataContext

public static DataContext createJdbcDataContext(java.sql.Connection connection,
                                                java.lang.String catalogName)
Creates a DataContext based on a JDBC connection

Parameters:
connection - a JDBC connection
catalogName - a catalog name to use
Returns:
a DataContext object that matches the request

createJdbcDataContext

public static DataContext createJdbcDataContext(java.sql.Connection connection,
                                                TableType... tableTypes)
Creates a DataContext based on a JDBC connection

Parameters:
connection - a JDBC connection
tableTypes - the types of tables to include in the generated schemas
Returns:
a DataContext object that matches the request

createJdbcDataContext

public static DataContext createJdbcDataContext(java.sql.Connection connection,
                                                java.lang.String catalogName,
                                                TableType[] tableTypes)
Creates a DataContext based on a JDBC connection

Parameters:
connection - a JDBC connection
catalogName - a catalog name to use
tableTypes - the types of tables to include in the generated schemas
Returns:
a DataContext object that matches the request

createJdbcDataContext

public static DataContext createJdbcDataContext(javax.sql.DataSource ds,
                                                TableType... tableTypes)
Creates a DataContext based on a JDBC datasource

Parameters:
ds - a JDBC datasource
tableTypes - the types of tables to include in the generated schemas
Returns:
a DataContext object that matches the request

createJdbcDataContext

public static DataContext createJdbcDataContext(javax.sql.DataSource ds,
                                                java.lang.String catalogName,
                                                TableType[] tableTypes)
Creates a DataContext based on a JDBC datasource

Parameters:
ds - a JDBC datasource
catalogName - a catalog name to use
tableTypes - the types of tables to include in the generated schemas
Returns:
a DataContext object that matches the request

createJdbcDataContext

public static DataContext createJdbcDataContext(javax.sql.DataSource ds,
                                                java.lang.String catalogName)
Creates a DataContext based on a JDBC datasource

Parameters:
ds - a JDBC datasource
catalogName - a catalog name to use
Returns:
a DataContext object that matches the request


Copyright © 2007-2010. All Rights Reserved.