com.rapidminer.tools
Class ParameterService

java.lang.Object
  extended by com.rapidminer.tools.ParameterService

public class ParameterService
extends java.lang.Object

This class loads the RapidMiner property files and provides methods to access them. It also stores the values of the properties. They are still mirrored in the System properties for keeping compatibility but it is strongly recommended to use this class to get access. During init this class will try to load settings from various sources. Sources with a higher specificy will overwrite settings with a lower. The sequence is as follows while only the first step is executed if the ExecutionMode forbidds file access:

  1. loading the factory defaults from /com/rapidminer/resources/rapidminerrc from the rapidminer.jar.
  2. if the system property rapidminer.config.dir is set, the file rapidminerrc inside this directory will be loaded.
  3. if the property is not set, the environment variable RAPIDMINER_CONFIG_DIR will be evaluated in the same way.
  4. the file rapidminerrc in the user's .Rapidminer5 directory will be loaded.
  5. the file rapidminerrc.os_type in the user's .Rapidminer5 directory will be loaded.
  6. the file rapidminerrc in the user's home directory will be loaded.
  7. the file rapidminerrc.os_type in the user's home directory will be loaded.
  8. the file denoted by the System property rapidminer.rcfile will be loaded if defined.
It also provides methods to create files relative to the RapidMiner home directory. The way to access the properties via System.getProperty is deprecated and should be replaced by #getProperty(String).

Author:
Simon Fischer, Ingo Mierswa, Sebastian Land

Field Summary
static java.lang.String ENVIRONMENT_RAPIDMINER_CONFIG_DIR
           
static java.lang.String PROPERTY_RAPIDMINER_CONFIG_DIR
           
static java.lang.String PROPERTY_RAPIDMINER_SRC_ROOT
          Property specifying the root directory of the RapidMiner project sources.
static java.lang.String RAPIDMINER_CONFIG_FILE_NAME
           
 
Constructor Summary
ParameterService()
           
 
Method Summary
static boolean booleanValue(java.lang.String value, boolean deflt)
          Deprecated. 
static void copyMainUserConfigFile(VersionNumber oldVersion, VersionNumber newVersion)
          This method will copy the operating system specific config file from the RapidMiner user directory from the last version to the next.
static void ensureRapidMinerHomeSet()
          Tries to find the rapidminer.home directory if the property is not set and sets it.
static java.util.Collection<java.lang.String> getDefinedParameterKeys()
          This method will return a Collection of all keys of defined parameter types.
static java.util.Set<ParameterType> getDefinedParameterTypes()
          This method will return a Collection of all keys of defined parameter types.
static java.io.File getGlobalConfigFile(java.lang.String fileName)
          This returns the file with the given fileName from the directory denoted by first the Parameter named "rapidminer.config.dir" and if this one is not defined by the environment variable "RAPIDMINER_CONFIG_DIR".
static java.lang.String getGroupKey(java.lang.String key)
          This will return the group of the parameter with the given key.
static java.io.File getLibraryFile(java.lang.String name)
          Deprecated. 
static java.io.File getMainUserConfigFile()
          Deprecated. 
static java.util.Collection<java.lang.String> getParameterKeys()
          This method returns all keys of all parameters, implicit as well as defined ones.
static ParameterType getParameterType(java.lang.String key)
          This method returns the type of the defined parameter identified by key or null if this key is unknown.
static java.lang.String getParameterValue(java.lang.String key)
          This method returns the value of the given parameter or null if this parameter is unknown.
static java.io.File getRapidMinerHome()
          Deprecated. 
static java.io.File getSourceFile(java.lang.String name)
          Deprecated. 
static java.io.File getSourceResourceFile(java.lang.String name)
          Deprecated. 
static java.io.File getSourceRoot()
          Deprecated. 
static java.io.File getUserConfigFile(java.lang.String name)
          Deprecated. 
static java.io.File getUserRapidMinerDir()
          Deprecated. 
static java.io.File getVersionedUserConfigFile(VersionNumber versionNumber, java.lang.String name)
          Deprecated. 
static void init()
          Reads the configuration file if allowed by the ExecutionMode.
static void init(java.io.InputStream operatorsXMLStream)
          Deprecated. 
static void registerParameter(ParameterType type)
          This method lets register the given ParameterType with defaults settings.
static void registerParameter(ParameterType type, java.lang.String group)
          This method allows to set the group explicitly rather than deriving it from the key.
static void registerParameter(ParameterType type, java.lang.String group, ParameterScope scope)
          This method can be used to register the given ParameterType on the given ParameterScope.
static void registerParameterChangeListener(ParameterChangeListener listener)
          This will add the given listener to the list of listers.
static void removeParameterChangeListener(ParameterChangeListener listener)
          This method will remove the given listener from the list.
static void saveParameters()
          This method will save all currently known defined parameter types into the version and os dependent config file in the user's RapidMiner directory.
static void saveParameters(java.io.File configFile)
          This method will save all currently known defined parameters into the given file.
static void setParameters(java.io.File file)
          This sets the parameters to the values given by a properties file denoted by the given file object.
static void setParameters(java.io.InputStream in)
          This method reads the input stream that streams in a properties file and sets the parameter values accordingly.
static void setParameterValue(ParameterType type, java.lang.String value)
          This method sets the given parameter to the given value.
static void setParameterValue(java.lang.String key, java.lang.String value)
          This method sets the parameter with the given key to the given value.
static void writeProperties(java.util.Properties properties, java.io.File file)
          Deprecated. 
static void writePropertyIntoMainUserConfigFile(java.lang.String key, java.lang.String value)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RAPIDMINER_CONFIG_FILE_NAME

public static final java.lang.String RAPIDMINER_CONFIG_FILE_NAME
See Also:
Constant Field Values

PROPERTY_RAPIDMINER_SRC_ROOT

public static final java.lang.String PROPERTY_RAPIDMINER_SRC_ROOT
Property specifying the root directory of the RapidMiner project sources.

See Also:
Constant Field Values

PROPERTY_RAPIDMINER_CONFIG_DIR

public static final java.lang.String PROPERTY_RAPIDMINER_CONFIG_DIR
See Also:
Constant Field Values

ENVIRONMENT_RAPIDMINER_CONFIG_DIR

public static final java.lang.String ENVIRONMENT_RAPIDMINER_CONFIG_DIR
See Also:
Constant Field Values
Constructor Detail

ParameterService

public ParameterService()
Method Detail

init

public static void init()
Reads the configuration file if allowed by the ExecutionMode.


setParameterValue

public static void setParameterValue(ParameterType type,
                                     java.lang.String value)
This method sets the given parameter to the given value. If the parameter is not known, yet, it will be added as a defined parameter with a default scope.


setParameterValue

public static void setParameterValue(java.lang.String key,
                                     java.lang.String value)
This method sets the parameter with the given key to the given value. If the parameter does not yet exist a new non defined parameter will be created. The value can then be retrieved but it won't be saved in any configuration file and will be lost after restarting RapidMiner. For compatibility reasons this will set the parameter also in the System properties. This might be removed in further versions.


getParameterValue

public static java.lang.String getParameterValue(java.lang.String key)
This method returns the value of the given parameter or null if this parameter is unknown. For compatibility reasons this will return defined parameters as well as undefined.


getGroupKey

public static java.lang.String getGroupKey(java.lang.String key)
This will return the group of the parameter with the given key. If the key is unknown, null will be returned.


getParameterType

public static ParameterType getParameterType(java.lang.String key)
This method returns the type of the defined parameter identified by key or null if this key is unknown.


getParameterKeys

public static java.util.Collection<java.lang.String> getParameterKeys()
This method returns all keys of all parameters, implicit as well as defined ones.


getDefinedParameterKeys

public static java.util.Collection<java.lang.String> getDefinedParameterKeys()
This method will return a Collection of all keys of defined parameter types. Undefined types will not be returned.


getDefinedParameterTypes

public static java.util.Set<ParameterType> getDefinedParameterTypes()
This method will return a Collection of all keys of defined parameter types. Undefined types will not be returned.


setParameters

public static void setParameters(java.io.File file)
                          throws java.io.FileNotFoundException,
                                 java.io.IOException
This sets the parameters to the values given by a properties file denoted by the given file object.

Throws:
java.io.IOException
java.io.FileNotFoundException

setParameters

public static void setParameters(java.io.InputStream in)
                          throws java.io.IOException
This method reads the input stream that streams in a properties file and sets the parameter values accordingly. If the stream cannot be accessed an exception will be thrown.

Throws:
java.io.IOException

getGlobalConfigFile

public static java.io.File getGlobalConfigFile(java.lang.String fileName)
This returns the file with the given fileName from the directory denoted by first the Parameter named "rapidminer.config.dir" and if this one is not defined by the environment variable "RAPIDMINER_CONFIG_DIR". If neither one is defined, null is returned.


copyMainUserConfigFile

public static void copyMainUserConfigFile(VersionNumber oldVersion,
                                          VersionNumber newVersion)
This method will copy the operating system specific config file from the RapidMiner user directory from the last version to the next.


saveParameters

public static void saveParameters()
This method will save all currently known defined parameter types into the version and os dependent config file in the user's RapidMiner directory. This method will also generate files that are needed for preStartParameter that affect as environment variables the staring JVM. If file access isn't allowed nothing is done at all.


saveParameters

public static void saveParameters(java.io.File configFile)
This method will save all currently known defined parameters into the given file. If file access isn't allowed by the execution mode, nothing is done. Please notice that in contrast to saveParameters(), no preStartParameter files are written.


registerParameter

public static void registerParameter(ParameterType type)
This method lets register the given ParameterType with defaults settings. To have more control over the scope and group name refer to any other registerParameter method. If a implicite Parameter is already defined with the key, it will be converted to an explict without loosing the data.


registerParameter

public static void registerParameter(ParameterType type,
                                     java.lang.String group)
This method allows to set the group explicitly rather than deriving it from the key.


registerParameter

public static void registerParameter(ParameterType type,
                                     java.lang.String group,
                                     ParameterScope scope)
This method can be used to register the given ParameterType on the given ParameterScope. This method can be used to define for example preStartParameters like memory size...


ensureRapidMinerHomeSet

public static void ensureRapidMinerHomeSet()
Tries to find the rapidminer.home directory if the property is not set and sets it.


registerParameterChangeListener

public static void registerParameterChangeListener(ParameterChangeListener listener)
This will add the given listener to the list of listers. It will be informed whenever a setting is changed.


removeParameterChangeListener

public static void removeParameterChangeListener(ParameterChangeListener listener)
This method will remove the given listener from the list. It won't be informed anymore.


writeProperties

@Deprecated
public static void writeProperties(java.util.Properties properties,
                                              java.io.File file)
Deprecated. 

This method is deprecated and shouldn't be used anymore. To save RapidMiner's Parameters, use method #saveProperties(File)). To save the given properties you can simply call Properties.store(java.io.OutputStream, String) yourself.


writePropertyIntoMainUserConfigFile

@Deprecated
public static void writePropertyIntoMainUserConfigFile(java.lang.String key,
                                                                  java.lang.String value)
Deprecated. 

This method shouldn't be used anymore since it does two actions at one time: Setting and saving. You can easily replace it by subsequent calls to setParameterValue(String, String) and saveParameters().


getMainUserConfigFile

@Deprecated
public static java.io.File getMainUserConfigFile()
Deprecated. 

Deprecated method. Remains only for compatibility. Please use FileSystemService.getMainUserConfigFile() instead.


getUserConfigFile

@Deprecated
public static java.io.File getUserConfigFile(java.lang.String name)
Deprecated. 

Deprecated method. Remains only for compatibility. Please use FileSystemService.getUserConfigFile(String) instead.


getVersionedUserConfigFile

@Deprecated
public static java.io.File getVersionedUserConfigFile(VersionNumber versionNumber,
                                                                 java.lang.String name)
Deprecated. 

Deprecated method. Remains only for compatibility. Please use FileSystemService.getVersionedUserConfigFile(VersionNumber, String) instead.


getUserRapidMinerDir

@Deprecated
public static java.io.File getUserRapidMinerDir()
Deprecated. 

Deprecated method. Remains only for compatibility. Please use FileSystemService.getUserRapidMinerDir() instead.


getRapidMinerHome

@Deprecated
public static java.io.File getRapidMinerHome()
                                      throws java.io.IOException
Deprecated. 

Deprecated method. Remains only for compatibility. Please use FileSystemService.getRapidMinerHome() instead.

Throws:
java.io.IOException

getLibraryFile

@Deprecated
public static java.io.File getLibraryFile(java.lang.String name)
                                   throws java.io.IOException
Deprecated. 

Deprecated method. Remains only for compatibility. Please use FileSystemService.getLibraryFile(String) instead.

Throws:
java.io.IOException

getSourceRoot

@Deprecated
public static java.io.File getSourceRoot()
Deprecated. 

Deprecated method. Remains only for compatibility. Please use FileSystemService.getSourceRoot() instead.


getSourceFile

@Deprecated
public static java.io.File getSourceFile(java.lang.String name)
Deprecated. 

Deprecated method. Remains only for compatibility. Please use FileSystemService.getSourceFile(String) instead.


getSourceResourceFile

@Deprecated
public static java.io.File getSourceResourceFile(java.lang.String name)
Deprecated. 

Deprecated method. Remains only for compatibility. Please use FileSystemService.getSourceResourceFile(String) instead.


init

@Deprecated
public static void init(java.io.InputStream operatorsXMLStream)
Deprecated. 

This method is deprecated and remains only for compatibility. Please use init() instead.


booleanValue

@Deprecated
public static boolean booleanValue(java.lang.String value,
                                              boolean deflt)
Deprecated. 

Returns true if value is "true", "yes", "y" or "on". Returns false if value is "false", "no", "n" or "off". Otherwise returns deflt.



Copyright © 2001-2009 by Rapid-I