/*
 * LensKit, an open source recommender systems toolkit.
 * Copyright 2010-2012 Regents of the University of Minnesota and contributors
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of the
 * License, or (at your option) any later version.
 *
 * This program 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
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
package org.grouplens.lenskit.eval.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import java.util.Properties;

/**
 * The class that represents the set of properties passed in to a
 * Groovy evaluation script.  These properties will have been created
 * a caller, who passes in a Properties object, which will be embedded
 * in the instance of this class.  This instance will then be passed
 * in to the Groovy evaluation script under a special name, so the
 * script can use it to pull properties out.
 *
 * @author John Riedl
 * @since 1.1
 */
public class EvalScriptConfig {
    private static Logger logger;
    private Properties properties;

    public EvalScriptConfig() {
	this(new Properties());
    }

    public EvalScriptConfig(Properties in_properties) {
	logger = LoggerFactory.getLogger(getClass());
	properties = (Properties) in_properties.clone();
    }

    /**
     * Get the value of a property.
     *
     * @param key		The name of the property
     * @param defaultValue	The value to return if no such key
     * @return The value of the property
     */
    public String getProperty(String key, String defaultValue) {
	return properties.getProperty(key, defaultValue);
    }

    /**
     * Get the value of a property.
     *
     * @param key		The name of the property
     * @return The value of the property, or null if there is no such key
     */
    public String getProperty(String key) {
	return properties.getProperty(key, null);
    }

    /**
     * Get the script for this evaluation.  Will often include a path.
     *
     * @return The script name, or "eval.groovy" if none has been set.
     */
    public String getScript() {
	return getProperty("lenskit.eval.script", "eval.groovy");
    }

    /**
     * Get the data directory for this evaluation.
     *
     * @return The data directory, or "." if none has been set.
     */
    public String getDataDir() {
	return getProperty("lenskit.eval.dataDir", ".");
    }

    /**
     * Get the analysis directory for this evaluation.
     *
     * @return The analysis directory, or "." if none has been set.
     */
    public String getAnalysisDir() {
	return getProperty("lenskit.eval.analysisDir", ".");
    }

}

@@ -912,172 +912,8 @@
 g;%0A%0A
-import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport javax.annotation.CheckForNull;%0Aimport javax.annotation.Nonnull;%0Aimport javax.annotation.Nullable;%0A%0A
 impo
@@ -1409,42 +1409,8 @@
 g %7B%0A
-    private static Logger logger;%0A
     
@@ -1473,17 +1473,24 @@
 fig() %7B%0A
-%09
+        
 this(new
@@ -1572,56 +1572,16 @@
 ) %7B%0A
-%09logger = LoggerFactory.getLogger(getClass());%0A%09
+        
 prop
@@ -1692,34 +1692,42 @@
     * @param key
-%09%09
+          
 The name of the 
@@ -1761,17 +1761,17 @@
 ultValue
-%09
+ 
 The valu
@@ -1907,25 +1907,32 @@
 ultValue) %7B%0A
-%09
+        
 return prope
@@ -2048,10 +2048,9 @@
  key
-%09%09
+ 
 The 
@@ -2192,25 +2192,32 @@
 ring key) %7B%0A
-%09
+        
 return prope
@@ -2446,25 +2446,32 @@
 tScript() %7B%0A
-%09
+        
 return getPr
@@ -2686,33 +2686,40 @@
  getDataDir() %7B%0A
-%09
+        
 return getProper
@@ -2945,9 +2945,16 @@
 ) %7B%0A
-%09
+        
 retu

Reformat EvalConfigScript.