/*
 * Created on Feb 2, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package gov.nasa.jsc.plum;

import java.io.Serializable;
import java.util.prefs.Preferences;

/**
 * @author randrews
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class Configuration implements Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = -7757834311827638099L;

    private Preferences prefs;
    
    public static final String CALC="calc";
    public static final String COMBOGEN="combogen";
    public static final String INCGRAPH="incgraph";
    public static final String SIMULGRAPH="simulgraph";
    public static final String SELSUCCESS="selsuccess";
    public static final String TOPOLOGY="topology";
    public static final String OUTPUT="output";
    public static final String PROGRAMS="programs";
    public static final String AVGRUNTIME="avgruntime";
    public static final String SINGLE="single";
    public static final String DELIMITER="delimiter";
    
    private static final String AVGRUNTIME_DEFAULT="avgruntime $outputavgruntime.ps 5000 $order $host $user $pass $table $outputdb";
    private static final String TOPOLOGY_DEFAULT="topology $outputtopology.ps $host $db $user $pass";
    private static final String SIMULGRAPH_DEFAULT="simulgraph $outputsimulgraph.ps $host $user $pass $table $outputdb";
    private static final String SELSUCCESS_DEFAULT="selectsuccess $idx $outputselsuccess.ps $outputcombos.txt $host $user $pass $db $outputdb";
    private static final String INCGRAPH_DEFAULT="incgraph $outputincgraph.ps $host $user $pass $table $db $outputdb";
    private static final String SINGLE_DEFAULT="calc $idx $combo $sams $host $user $pass $db $outputdb";
    private static final String CALC_DEFAULT="calc $idx $host $user $pass $db $outputdb";
    private static final String COMBOGEN_DEFAULT="combogen $idx $host $user $pass $db $outputdb";
    private static final String OUTPUT_DEFAULT="PlumOutput";
    private static final String PROGRAMS_DEFAULT="bin";
    private static final String DELIMITER_DEFAULT="backslash";
    
    public Configuration(){
        prefs=Preferences.userNodeForPackage(getClass());
    }
    
    public String getDelimiter(){
        return prefs.get(DELIMITER,DELIMITER_DEFAULT);
    }
    
    public void setDelimiter(String delimiter){
        prefs.put(DELIMITER,delimiter);
    }
    
    /**
     * @return Returns the path to the programs.
     */
    public String getPrograms() {
        return prefs.get(PROGRAMS,PROGRAMS_DEFAULT);
    }
    /**
     * @param programs The program path to set.
     */
    public void setPrograms(String programs) {
        prefs.put(PROGRAMS,programs);
    }

    /**
     * @return Returns the output.
     */
    public String getOutput() {
        return prefs.get(OUTPUT,OUTPUT_DEFAULT);
    }
    /**
     * @param output The output path to set.
     */
    public void setOutput(String output) {
        prefs.put(OUTPUT,output);
    }
    /**
     * @return Returns the combo generator.
     */
    public String getCombogen() {
        return prefs.get(COMBOGEN,COMBOGEN_DEFAULT);
    }
    /**
     * @param brain The combo generator to set.
     */
    public void setCombogen(String combogen) {
        prefs.put(COMBOGEN,combogen);
    }
    /**
     * @return Returns the calc.
     */
    public String getCalc() {
        return prefs.get(CALC,CALC_DEFAULT);
    }
    /**
     * @param calc The calc to set.
     */
    public void setCalc(String calc) {
        prefs.put(CALC,calc);
    }
    /**
     * @return Returns the calc.
     */
    public String getSingle() {
        return prefs.get(SINGLE,SINGLE_DEFAULT);
    }
    /**
     * @param calc The calc to set.
     */
    public void setSingle(String single) {
        prefs.put(SINGLE,single);
    }
    /**
     * @return Returns the incrementGraph.
     */
    public String getIncrementGraph() {
        return prefs.get(INCGRAPH,INCGRAPH_DEFAULT);
    }
    /**
     * @param incrementGraph The incrementGraph to set.
     */
    public void setIncrementGraph(String incrementGraph) {
        prefs.put(INCGRAPH,incrementGraph);
    }
    /**
     * @return Returns the selSuccess.
     */
    public String getSelSuccess() {
        return prefs.get(SELSUCCESS,SELSUCCESS_DEFAULT);
    }
    /**
     * @param selSuccess The selSuccess to set.
     */
    public void setSelSuccess(String selSuccess) {
        prefs.put(SELSUCCESS,selSuccess);
    }
    /**
     * @return Returns the simulGraph.
     */
    public String getSimulGraph() {
        return prefs.get(SIMULGRAPH,SIMULGRAPH_DEFAULT);
    }
    /**
     * @param simulGraph The simulGraph to set.
     */
    public void setSimulGraph(String simulGraph) {
        prefs.put(SIMULGRAPH,simulGraph);
    }
    /**
     * @return Returns the topology.
     */
    public String getTopology() {
        return prefs.get(TOPOLOGY,TOPOLOGY_DEFAULT);
    }
    /**
     * @param topology The topology to set.
     */
    public void setTopology(String topology) {
        prefs.put(TOPOLOGY,topology);
    }
    /**
     * @return Returns the avgRuntime.
     */
    public String getAvgRuntime() {
        return prefs.get(AVGRUNTIME,AVGRUNTIME_DEFAULT);
    }
    /**
     * @param avgRuntime The avgRuntime to set.
     */
    public void setAvgRuntime(String avgRuntime) {
        prefs.put(AVGRUNTIME,avgRuntime);
    }
    
    public void setDefault(){
        prefs.put(CALC,CALC_DEFAULT);
        prefs.put(COMBOGEN,COMBOGEN_DEFAULT);
        prefs.put(INCGRAPH,INCGRAPH_DEFAULT);
        prefs.put(SIMULGRAPH,SIMULGRAPH_DEFAULT);
        prefs.put(SELSUCCESS,SELSUCCESS_DEFAULT);
        prefs.put(TOPOLOGY,TOPOLOGY_DEFAULT);
        prefs.put(OUTPUT,OUTPUT_DEFAULT);
        prefs.put(PROGRAMS,PROGRAMS_DEFAULT);
        prefs.put(AVGRUNTIME,AVGRUNTIME_DEFAULT);
        prefs.put(SINGLE,SINGLE_DEFAULT);
        prefs.put(DELIMITER,DELIMITER_DEFAULT);
    }
}
