All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mycomm.dao.dao4comm.annotation.dialect.DialectHandlerSelector Maven / Gradle / Ivy

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycomm.dao.dao4comm.annotation.dialect;

import com.mycomm.dao.dao4comm.annotation.OneToOneHandler;
import com.mycomm.dao.dao4comm.annotation.dialect.mysql.MySqlColumTypeDetector;
import com.mycomm.dao.dao4comm.annotation.dialect.mysql.MySqlOneToOneHandler;
import com.mycomm.dao.dao4comm.annotation.dialect.mysql.MySqlTableCharSetSelector;
import com.mycomm.dao.dao4comm.annotation.dialect.mysql.MysqlSqlBuilder;
import com.mycomm.dao.dao4comm.annotation.dialect.oracle.OracleColumDialectHandler;
import com.mycomm.dao.dao4comm.annotation.dialect.oracle.OracleOneToOneHandler;
import com.mycomm.dao.dao4comm.annotation.dialect.oracle.OracleSqlBuilder;
import com.mycomm.dao.dao4comm.annotation.dialect.oracle.OracleTableCharSetSelector;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author jw362j
 */
public class DialectHandlerSelector {
//

    private static Map dialects;
    private static Map tableCreators;
    private static Map oneToOne;
    private static Map charSetSelectors;

    static {
        dialects = new HashMap();
        dialects.put(DataBaseType.Oracl, new OracleColumDialectHandler());
        dialects.put(DataBaseType.MYSQL, new MySqlColumTypeDetector());

        tableCreators = new HashMap();
        tableCreators.put(DataBaseType.MYSQL, new MysqlSqlBuilder());
        tableCreators.put(DataBaseType.Oracl, new OracleSqlBuilder());

        oneToOne = new HashMap();
        oneToOne.put(DataBaseType.Oracl, new OracleOneToOneHandler());
        oneToOne.put(DataBaseType.MYSQL, new MySqlOneToOneHandler());

        charSetSelectors = new HashMap();
        charSetSelectors.put(DataBaseType.Oracl, new OracleTableCharSetSelector());
        charSetSelectors.put(DataBaseType.MYSQL, new MySqlTableCharSetSelector());

    }

    public static ColumTypeDetector selectColumDialectHandler(DataBaseType dbt) {
        if (dbt == null) {
            return dialects.get(DataBaseType.MYSQL);
        }
        return dialects.get(dbt);
    }

    public static SqlBuilder selectTableCreator(DataBaseType dbt) {
        if (dbt == null) {
            return tableCreators.get(DataBaseType.MYSQL);
        }
        return tableCreators.get(dbt);
    }

    public static OneToOneHandler selectOneToOneHandler(DataBaseType dbt) {
        if (dbt == null) {
            return oneToOne.get(DataBaseType.MYSQL);
        }
        return oneToOne.get(dbt);
    }

    public static TableCharSetSelector selectTableCharSetSelector(DataBaseType dbt) {
        if (dbt == null) {
            return charSetSelectors.get(DataBaseType.MYSQL);
        }
        return charSetSelectors.get(dbt);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy