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");
    }
}

@@ -1063,253 +1063,8 @@
  %7D%0A%0A
-    public String getProperty(String property) %7B%0A        return properties.getProperty(property);%0A    %7D%0A%0A    public String getProperty(String property, String defaultValue) %7B%0A        return properties.getProperty(property, defaultValue);%0A    %7D%0A%0A
     

Revert "Persuade PropertyBaseConfig to output arbitrary properties."