<commit_before>package io.advant.orm;

import io.advant.orm.internal.DBConnectionParams;
import io.advant.orm.type.DBType;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author <NAME>
 */
public class DBConfig {

    private static final Logger LOGGER = Logger.getLogger(DBConfig.class.getName());
    private String datasource;
    private DBType dbType;
    private String driver;
    private String host;
    private int port;
    private String database;
    private String user;
    private String password;
    private Properties properties;
    private Set<String> entities = new HashSet<>();

    public DBConfig(Properties configProps) {
        configureProperties(configProps);
    }

    public DBConfig(InputStream inputStream) {
        try {
            Properties configProps = new Properties();
            configProps.load(inputStream);
            configureProperties(configProps);
        } catch (IOException e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
        }
    }

    private void configureProperties(Properties configProps) {
        datasource = configProps.getProperty("datasource");
        dbType = DBType.valueOf(configProps.getProperty("db.type").toUpperCase());
        driver = dbType.getDriver();
        host = configProps.getProperty("db.host");
        port = Integer.valueOf(configProps.getProperty("db.port", "0"));
        database = configProps.getProperty("db.database");
        user = configProps.getProperty("db.user", null);
        password = configProps.getProperty("db.password", null);
        Enumeration enumKey = configProps.keys();
        while (enumKey.hasMoreElements()) {
            String key = (String) enumKey.nextElement();
            String dbProperty = "db.property.";
            if (key.startsWith(dbProperty)) {
                if (properties == null) {
                    properties = new Properties();
                }
                String value = configProps.getProperty(key);
                properties.put(key.substring(dbProperty.length()), value);
            } else if (key.startsWith("entity.")) {
                if (entities == null) {
                    entities = new HashSet<>();
                }
                String value = configProps.getProperty(key);
                entities.add(value);
            }
        }
    }

    public DBConfig(String datasource) {
        this.datasource = datasource;
    }

    public DBConfig(DBType dbType, String host, int port, String database, String user, String password) {
        this(dbType, database, user ,password);
        this.host = host;
        this.port = port;
    }

    public DBConfig(DBType dbType, String database, String user, String password) {
        this.driver = dbType.getDriver();
        this.dbType = dbType;
        this.database = database;
        this.user = user;
        this.password = password;
    }<commit_msg>Fix User Password default value<commit_after>package io.advant.orm;

import io.advant.orm.internal.DBConnectionParams;
import io.advant.orm.type.DBType;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author <NAME>
 */
public class DBConfig {

    private static final Logger LOGGER = Logger.getLogger(DBConfig.class.getName());
    private String datasource;
    private DBType dbType;
    private String driver;
    private String host;
    private int port;
    private String database;
    private String user;
    private String password;
    private Properties properties;
    private Set<String> entities = new HashSet<>();

    public DBConfig(Properties configProps) {
        configureProperties(configProps);
    }

    public DBConfig(InputStream inputStream) {
        try {
            Properties configProps = new Properties();
            configProps.load(inputStream);
            configureProperties(configProps);
        } catch (IOException e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
        }
    }

    private void configureProperties(Properties configProps) {
        datasource = configProps.getProperty("datasource");
        dbType = DBType.valueOf(configProps.getProperty("db.type").toUpperCase());
        driver = dbType.getDriver();
        host = configProps.getProperty("db.host");
        port = Integer.valueOf(configProps.getProperty("db.port", "0"));
        database = configProps.getProperty("db.database");
        user = configProps.getProperty("db.user");
        password = configProps.getProperty("db.password");
        Enumeration enumKey = configProps.keys();
        while (enumKey.hasMoreElements()) {
            String key = (String) enumKey.nextElement();
            String dbProperty = "db.property.";
            if (key.startsWith(dbProperty)) {
                if (properties == null) {
                    properties = new Properties();
                }
                String value = configProps.getProperty(key);
                properties.put(key.substring(dbProperty.length()), value);
            } else if (key.startsWith("entity.")) {
                if (entities == null) {
                    entities = new HashSet<>();
                }
                String value = configProps.getProperty(key);
                entities.add(value);
            }
        }
    }

    public DBConfig(String datasource) {
        this.datasource = datasource;
    }

    public DBConfig(DBType dbType, String host, int port, String database, String user, String password) {
        this(dbType, database, user ,password);
        this.host = host;
        this.port = port;
    }

    public DBConfig(DBType dbType, String database, String user, String password) {
        this.driver = dbType.getDriver();
        this.dbType = dbType;
        this.database = database;
        this.user = user == null ? "" : user;
        this.password = password == null ? "" : password;
    }
{'fraction_non_alphanumeric': 0.10932991343379288, 'fraction_numerical': 0.0003206155819172812, 'mean_word_length': 2.4488667772249864, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2481612', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1609, 'n_words': 388}