Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_901 / libraries / libGDBMS / src / main / java / com / hardcode / gdbms / engine / data / db / DBDataSourceFactory.java @ 10571

History | View | Annotate | Download (1.65 KB)

1
package com.hardcode.gdbms.engine.data.db;
2

    
3
import com.hardcode.gdbms.engine.data.DataSourceFactory;
4
import com.hardcode.gdbms.engine.data.driver.DBDriver;
5
import com.hardcode.gdbms.engine.data.driver.DBTransactionalDriver;
6
import com.hardcode.gdbms.engine.data.edition.DirectDataWare;
7

    
8

    
9
/**
10
 * Factory to create database DataSources
11
 */
12
public class DBDataSourceFactory {
13
    /**
14
     * Creates a new DBDataSource
15
     *
16
     * @return DataBaseDataSource
17
     */
18
    public static DBDataSource newDataSourceInstance() {
19
        return new DBDataSourceAdapter();
20
    }
21

    
22
    public static DBDataSource newSpatialDataSourceInstance() {
23
        return new DBSpatialDataSourceAdapter();
24
    }
25
    
26
    /**
27
     * Creates a new DataWare suitable for the specified driver
28
     *
29
     * @param driver DBDriver
30
     *
31
     * @return DataWare
32
     */
33
    public static DBDataWare newDataWareInstance(DBDriver driver, int mode) {
34
        if (driver instanceof DBTransactionalDriver) {
35
            if (mode == DataSourceFactory.DATA_WARE_COHERENT_ROW_ORDER){
36
                return new CoherentRowOrderDataWare();
37
            }else{
38
                    DBDataWare directDataware = new DirectDataWare();
39
//                    directDataware.setSourceInfo(DataSourceFactory.)
40
                return directDataware;
41
            }
42
        } else {
43
            return new FakeTransactionDataWare();
44
        }
45
    }
46

    
47
    /**
48
     * Returns the driver name of the driver layer of 'table'
49
     *
50
     * @param table table which driver name is wanted
51
     *
52
     * @return String
53
     */
54
    public static String getDriver(DBDataSource table) {
55
        return ((DBDataSourceAdapter) table).getDriver().getName();
56
    }
57
}