CFEngine API

org.recommender.algorithms
Class SimpleParameterSet

java.lang.Object
  |
  +--org.recommender.algorithms.ParameterSet
        |
        +--org.recommender.algorithms.SimpleParameterSet

public class SimpleParameterSet
extends ParameterSet

Parse a file containing algorithm parameters, and allow access to those parameters.

Author:
Daniel Lowd

Field Summary
(package private)  java.lang.String allParams
          Keep a string with the file's entire contents.
(package private)  java.util.Hashtable params
          Keep track of all parameters
 
Constructor Summary
SimpleParameterSet()
          Constructor, creates dummy parameter file
SimpleParameterSet(java.util.Properties props)
          Constructor, gets params from props directly and changes them into strings
SimpleParameterSet(java.lang.String filename)
          Constructor, loads the file with the given filename.
 
Method Summary
 java.lang.String getAllParams()
          Return a string containing all parameters.
 java.lang.String getString(java.lang.String paramName)
          Get a parameter's value.
 java.lang.String getString(java.lang.String paramName, java.lang.String defaultVal)
          Get a parameter's value.
 void setString(java.lang.String paramName, java.lang.String value)
          Sets a parameter's value.
 
Methods inherited from class org.recommender.algorithms.ParameterSet
getBoolean, getFloat, getInt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

params

java.util.Hashtable params
Keep track of all parameters


allParams

java.lang.String allParams
Keep a string with the file's entire contents.

Constructor Detail

SimpleParameterSet

public SimpleParameterSet(java.lang.String filename)
                   throws java.io.FileNotFoundException
Constructor, loads the file with the given filename.

Parameters:
filename -
Throws:
java.io.FileNotFoundException

SimpleParameterSet

public SimpleParameterSet(java.util.Properties props)
Constructor, gets params from props directly and changes them into strings

Parameters:
props -

SimpleParameterSet

public SimpleParameterSet()
Constructor, creates dummy parameter file

Method Detail

getString

public java.lang.String getString(java.lang.String paramName,
                                  java.lang.String defaultVal)
Get a parameter's value. If the parameter has no value, create a parameter with the specified default value and return that value. This way, we have a record of any default values being used. One caveat: if the same parameter is requested twice with two different default values specified, only the first will be used. Once it is requested the first time, the parameter will be set to the first default value provided, just as if it had been specified in a parameter file.

Specified by:
getString in class ParameterSet
Parameters:
paramName -
defaultVal -
Returns:
param's value

getString

public java.lang.String getString(java.lang.String paramName)
Get a parameter's value. Return null if not found.

Specified by:
getString in class ParameterSet
Parameters:
paramName -
Returns:
param's value, null if not found

setString

public void setString(java.lang.String paramName,
                      java.lang.String value)
Sets a parameter's value. This may alter the allParams string so that it contains two copies of a parameter. This should probably be considered a BUG. Perhaps we can live with it for now.

Specified by:
setString in class ParameterSet
Parameters:
paramName -
value -

getAllParams

public java.lang.String getAllParams()
Return a string containing all parameters. This includes default parameters, if default parameters were used with the getString method.

Specified by:
getAllParams in class ParameterSet
Returns:
allParams

CFEngine API

Copyright © 2003 - Oregon State University www.orst.edu