Class ExcelDataContext

  • All Implemented Interfaces:
    org.apache.metamodel.convert.HasReadTypeConverters, org.apache.metamodel.DataContext, org.apache.metamodel.UpdateableDataContext

    public final class ExcelDataContext
    extends org.apache.metamodel.QueryPostprocessDataContext
    implements org.apache.metamodel.UpdateableDataContext
    DataContext implementation to use for Excel spreadsheets. This DataContext supports both the "old" .xls format and the "new" .xlsx format, and saves the user the trouble of figuring out which one to use, simply by detecting it at runtime and delegating to the appropriate implementation.
    • Field Summary

      • Fields inherited from class org.apache.metamodel.QueryPostprocessDataContext

        INFORMATION_SCHEMA_NAME, SYSTEM_PROPERTY_CREATE_DEFAULT_TABLE_ALIAS
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.metamodel.UpdateSummary executeUpdate​(org.apache.metamodel.UpdateScript update)  
      ExcelConfiguration getConfiguration()
      Gets the Excel configuration used.
      protected org.apache.metamodel.schema.Schema getMainSchema()  
      protected String getMainSchemaName()  
      org.apache.metamodel.util.Resource getResource()
      Gets the Excel resource being read
      protected Class<? extends org.apache.metamodel.excel.SpreadsheetReaderDelegate> getSpreadsheetReaderDelegateClass()
      Convenient method for testing and inspecting internal state.
      org.apache.metamodel.data.DataSet materializeMainSchemaTable​(org.apache.metamodel.schema.Table table, List<org.apache.metamodel.schema.Column> columns, int maxRows)  
      protected void notifyTablesModified()  
      protected void onSchemaCacheRefreshed()  
      • Methods inherited from class org.apache.metamodel.QueryPostprocessDataContext

        addConverter, executeCountQuery, executePrimaryKeyLookupQuery, executeQuery, getDefaultSchemaName, getSchemaByNameInternal, getSchemaNamesInternal, isMainSchemaTable, isScalarFunctionMaterialized, materializeFromItem, materializeMainSchemaTable, materializeMainSchemaTable, materializeMainSchemaTableSelect, materializeTable
      • Methods inherited from class org.apache.metamodel.AbstractDataContext

        compileQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, isQualifiedPathDelim, parseQuery, query, refreshSchemas
      • Methods inherited from interface org.apache.metamodel.DataContext

        compileQuery, executeQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, parseQuery, query, refreshSchemas
    • Constructor Detail

      • ExcelDataContext

        public ExcelDataContext​(File file)
        Constructs an Excel DataContext based on a file, with default configuration
        Parameters:
        file -
      • ExcelDataContext

        public ExcelDataContext​(File file,
                                ExcelConfiguration configuration)
        Constructs an Excel DataContext based on a resource and a custom configuration. The file provided can be either existing or non-existing. In the case of non-existing files, a file will be automatically created when a CREATE TABLE update is executed on the DataContext.
        Parameters:
        file -
        configuration -
      • ExcelDataContext

        public ExcelDataContext​(org.apache.metamodel.util.Resource resource,
                                ExcelConfiguration configuration)
    • Method Detail

      • getConfiguration

        public ExcelConfiguration getConfiguration()
        Gets the Excel configuration used.
        Returns:
        an excel configuration.
      • getResource

        public org.apache.metamodel.util.Resource getResource()
        Gets the Excel resource being read
        Returns:
      • getMainSchemaName

        protected String getMainSchemaName()
                                    throws org.apache.metamodel.MetaModelException
        Specified by:
        getMainSchemaName in class org.apache.metamodel.QueryPostprocessDataContext
        Throws:
        org.apache.metamodel.MetaModelException
      • materializeMainSchemaTable

        public org.apache.metamodel.data.DataSet materializeMainSchemaTable​(org.apache.metamodel.schema.Table table,
                                                                            List<org.apache.metamodel.schema.Column> columns,
                                                                            int maxRows)
        Specified by:
        materializeMainSchemaTable in class org.apache.metamodel.QueryPostprocessDataContext
      • getMainSchema

        protected org.apache.metamodel.schema.Schema getMainSchema()
                                                            throws org.apache.metamodel.MetaModelException
        Specified by:
        getMainSchema in class org.apache.metamodel.QueryPostprocessDataContext
        Throws:
        org.apache.metamodel.MetaModelException
      • onSchemaCacheRefreshed

        protected void onSchemaCacheRefreshed()
        Overrides:
        onSchemaCacheRefreshed in class org.apache.metamodel.AbstractDataContext
      • getSpreadsheetReaderDelegateClass

        protected Class<? extends org.apache.metamodel.excel.SpreadsheetReaderDelegate> getSpreadsheetReaderDelegateClass()
        Convenient method for testing and inspecting internal state.
        Returns:
        the class of the spreadsheet reader delegate.
      • notifyTablesModified

        protected void notifyTablesModified()
      • executeUpdate

        public org.apache.metamodel.UpdateSummary executeUpdate​(org.apache.metamodel.UpdateScript update)
        Specified by:
        executeUpdate in interface org.apache.metamodel.UpdateableDataContext