net.librec.util.DriverClassUtil Maven / Gradle / Ivy
/**
* Copyright (C) 2016 LibRec
*
* This file is part of LibRec.
* LibRec is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LibRec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LibRec. If not, see .
*/
package net.librec.util;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import net.librec.recommender.Recommender;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Properties;
/**
* Driver Class Util
*
* @author WangYuFeng
*/
public class DriverClassUtil {
/**
* driver Class BiMap matches configuration of driver.classes.props
*/
private static BiMap driverClassBiMap;
/**
* inverse configuration of driver.classes.props
*/
private static BiMap driverClassInverseBiMap;
static {
driverClassBiMap = HashBiMap.create();
Properties prop = new Properties();
InputStream is = null;
try {
is = DriverClassUtil.class.getClassLoader().getResourceAsStream("driver.classes.props");
prop.load(is);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Iterator> propIte = prop.entrySet().iterator();
while (propIte.hasNext()) {
Entry