<commit_before>package de.qaware.chronix.shared.ServerConfig;

import de.qaware.chronix.database.BenchmarkDataSource;
import org.apache.commons.compress.utils.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import static java.nio.file.StandardCopyOption.*;

/**
 * Created by mcqueen666 on 08.08.16.
 *
 */
@SuppressWarnings("unchecked")
public class TSDBInterfaceHandler {

    private static TSDBInterfaceHandler instance;
    private final Logger logger = LoggerFactory.getLogger(TSDBInterfaceHandler.class);
    private String interfaceDirectoryName = "interfaces";
    private String interfaceDirectory = System.getProperty("user.home") + File.separator +"chronixBenchmark" + File.separator + interfaceDirectoryName + File.separator;
    //private ServerConfigAccessor serverConfigAccessor;
    private Map<String, File> interfaces;

    private TSDBInterfaceHandler(){
        //serverConfigAccessor = ServerConfigAccessor.getInstance();
        //interfaceDirectory = serverConfigAccessor.getConfigDirectory() + interfaceDirectoryName + File.separator;
        makeInterfaceDirectory();
        interfaces = new HashMap<>();
        readInterfaceDirectory();

    }

    public static synchronized TSDBInterfaceHandler getInstance(){
        if(instance == null){
            instance = new TSDBInterfaceHandler();
        }
        return instance;
    }

    public Map<String, File> getInterfaces() {
        return interfaces;
    }

    public String getInterfaceDirectory() {
        return interfaceDirectory;
    }

    @SuppressWarnings("ResultOfMethodCallIgnored")
    private void makeInterfaceDirectory(){
        File directory = new File(interfaceDirectory);
        if(!directory.exists()){
            directory.mkdir();
        }
    }

    private void readInterfaceDirectory(){
        File directory = new File(interfaceDirectory);
        if(directory.exists()){
            File[] fileList = directory.listFiles();
            if(fileList != null) {
                for (File file : fileList) {
                    if (file.getName().endsWith(".jar")) {
                        interfaces.put(file.getName().replaceFirst(".jar", ""), file);
                    }
                }<commit_msg>also create chronixBenchmark dir if it does not exist (first launch of setup)<commit_after>package de.qaware.chronix.shared.ServerConfig;

import de.qaware.chronix.database.BenchmarkDataSource;
import org.apache.commons.compress.utils.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import static java.nio.file.StandardCopyOption.*;

/**
 * Created by mcqueen666 on 08.08.16.
 *
 */
@SuppressWarnings("unchecked")
public class TSDBInterfaceHandler {

    private static TSDBInterfaceHandler instance;
    private final Logger logger = LoggerFactory.getLogger(TSDBInterfaceHandler.class);
    private String interfaceDirectoryName = "interfaces";
    private String interfaceDirectory = System.getProperty("user.home") + File.separator +"chronixBenchmark" + File.separator + interfaceDirectoryName + File.separator;
    //private ServerConfigAccessor serverConfigAccessor;
    private Map<String, File> interfaces;

    private TSDBInterfaceHandler(){
        //serverConfigAccessor = ServerConfigAccessor.getInstance();
        //interfaceDirectory = serverConfigAccessor.getConfigDirectory() + interfaceDirectoryName + File.separator;
        makeInterfaceDirectory();
        interfaces = new HashMap<>();
        readInterfaceDirectory();

    }

    public static synchronized TSDBInterfaceHandler getInstance(){
        if(instance == null){
            instance = new TSDBInterfaceHandler();
        }
        return instance;
    }

    public Map<String, File> getInterfaces() {
        return interfaces;
    }

    public String getInterfaceDirectory() {
        return interfaceDirectory;
    }

    @SuppressWarnings("ResultOfMethodCallIgnored")
    private void makeInterfaceDirectory(){
        File directory = new File(interfaceDirectory);
        if(!directory.exists()){
            directory.mkdirs();
        }
    }

    private void readInterfaceDirectory(){
        File directory = new File(interfaceDirectory);
        if(directory.exists()){
            File[] fileList = directory.listFiles();
            if(fileList != null) {
                for (File file : fileList) {
                    if (file.getName().endsWith(".jar")) {
                        interfaces.put(file.getName().replaceFirst(".jar", ""), file);
                    }
                }
{'fraction_non_alphanumeric': 0.10434073772162217, 'fraction_numerical': 0.004483391073975953, 'mean_word_length': 3.107112970711297, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4112397', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1247, 'n_words': 276}