JGAP

org.jgap.data.config
Class RootConfigurationHandler

java.lang.Object
  extended by org.jgap.data.config.RootConfigurationHandler
All Implemented Interfaces:
ConfigurationHandler

public class RootConfigurationHandler
extends java.lang.Object
implements ConfigurationHandler

The ConfigurationHandler for the Configuration class itself. This is the entry point for a Configuration. In other words this is for dynamically building up a Configuration.

Since:
2.3

Constructor Summary
RootConfigurationHandler()
           
 
Method Summary
static void configureClass(java.lang.String className)
          Retrieve all instances of a certain property from the config file reader and configure each of these.
 java.util.List getConfigProperties()
          Return the information to generate the GUI for configuring this class.
 java.lang.String getName()
          Return the name of this Configuration Object to be used in the properties file.
 java.lang.String getNS()
          Get the namespace to be used in the config file for the Configurable this ConfigurationHandler belongs to.
static java.lang.reflect.Field getPrivateField(java.lang.Object a_instance, java.lang.String a_fieldName)
          Helper method: Read a private field.
 void readConfig()
          Method that will populate an Configurable with the properties in the config file.
 void setConfigProperty(java.lang.Object a_configurable, java.lang.String a_propertyName, java.lang.String a_value)
          Sets the property of a configurable to a given value.
 void setConfigurable(Configurable a_configurable)
          Set the Configurable to which this ConfigurationHandler belongs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RootConfigurationHandler

public RootConfigurationHandler()
Method Detail

getName

public java.lang.String getName()
Description copied from interface: ConfigurationHandler
Return the name of this Configuration Object to be used in the properties file.

Specified by:
getName in interface ConfigurationHandler
Returns:
Name of this Configuration Object (name of what you are configuring) to be used in the properties file.
Since:
2.3

getConfigProperties

public java.util.List getConfigProperties()
Return the information to generate the GUI for configuring this class.

Specified by:
getConfigProperties in interface ConfigurationHandler
Returns:
a list of ConfigProperty objects
Since:
2.3

getNS

public java.lang.String getNS()
Get the namespace to be used in the config file for the Configurable this ConfigurationHandler belongs to.

Specified by:
getNS in interface ConfigurationHandler
Returns:
the namespace of the Configurable
Since:
2.3

readConfig

public void readConfig()
                throws ConfigException,
                       InvalidConfigurationException
Method that will populate an Configurable with the properties in the config file.

Specified by:
readConfig in interface ConfigurationHandler
Throws:
ConfigException
InvalidConfigurationException
Since:
2.3

setConfigurable

public void setConfigurable(Configurable a_configurable)
Set the Configurable to which this ConfigurationHandler belongs.

Specified by:
setConfigurable in interface ConfigurationHandler
Parameters:
a_configurable - the Configurable to which this ConfigurationHandler belongs
Since:
2.3

setConfigProperty

public void setConfigProperty(java.lang.Object a_configurable,
                              java.lang.String a_propertyName,
                              java.lang.String a_value)
                       throws java.lang.IllegalAccessException
Sets the property of a configurable to a given value. Uses reflection to do so. Queries the method getConfigVarName for the name of the field hosting the configurable properties.

Parameters:
a_configurable - the configurable to use
a_propertyName - the property to set
a_value - the value to assign to the property
Throws:
java.lang.IllegalAccessException
Since:
2.6

getPrivateField

public static java.lang.reflect.Field getPrivateField(java.lang.Object a_instance,
                                                      java.lang.String a_fieldName)
Helper method: Read a private field.

Parameters:
a_instance - the instance the field is contained with
a_fieldName - the name of the field to read
Returns:
the Field object or null, if none found
Since:
2.6

configureClass

public static void configureClass(java.lang.String className)
                           throws ConfigException
Retrieve all instances of a certain property from the config file reader and configure each of these.

Parameters:
className - the name of the property to configure
Throws:
ConfigException
Since:
2.4

JGAP