package dk.statsbiblioteket.doms.transformers.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/** Configuration based on property file. */
public class PropertyBasedConfig implements Config {

    /** Property specifying the directory where output files will be stored. */
    public static final String OUTPUT_DIRECTORY_PROPERTY
            = "dk.statsbiblioteket.doms.transformers.outputdirectory";

    /** Properties containing configuration. */
    protected final Properties properties;

    /** Initialise based on system properties. */
    public PropertyBasedConfig() {
        properties = new Properties(System.getProperties());
    }

    /**
     * Read configuration from property file. Backed by system properties.
     *
     * @param configfile File with properties.
     * @throws IOException If file can not be read.
     */
    public PropertyBasedConfig(File configfile) throws IOException {
        this();
        properties.load(new FileInputStream(configfile));
    }

    public String getProperty(String property) {
        return properties.getProperty(property);
    }

    public String getProperty(String property, String defaultValue) {
        return properties.getProperty(property, defaultValue);
    }

    @Override
    public String getOutputDirectory() {
        return properties.getProperty(OUTPUT_DIRECTORY_PROPERTY, "output");
    }
}

package dk.statsbiblioteket.doms.transformers.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/** Configuration based on property file. */
public class PropertyBasedConfig implements Config {

    /** Property specifying the directory where output files will be stored. */
    public static final String OUTPUT_DIRECTORY_PROPERTY
            = "dk.statsbiblioteket.doms.transformers.outputdirectory";

    /** Properties containing configuration. */
    protected final Properties properties;

    /** Initialise based on system properties. */
    public PropertyBasedConfig() {
        properties = new Properties(System.getProperties());
    }

    /**
     * Read configuration from property file. Backed by system properties.
     *
     * @param configfile File with properties.
     * @throws IOException If file can not be read.
     */
    public PropertyBasedConfig(File configfile) throws IOException {
        this();
        properties.load(new FileInputStream(configfile));
    }

    @Override
    public String getOutputDirectory() {
        return properties.getProperty(OUTPUT_DIRECTORY_PROPERTY, "output");
    }
}

Revert "Persuade PropertyBaseConfig to output arbitrary properties."
Revert "Persuade PropertyBaseConfig to output arbitrary properties."

This reverts commit 0fb34a5f82c5554ac714c245241f47670b1f717d.
