org.powertac.common
Class PluginConfig

java.lang.Object
  extended by org.powertac.common.PluginConfig

public class PluginConfig
extends Object

Instances of this class can be used to configure plugins, and to communicate configuration information to brokers at the beginning of a simulation. In order to use this correctly, there should be exactly once instance created for each configurable plugin. This should be created in plugin's initialization service.

Author:
John Collins

Constructor Summary
PluginConfig(String role, String name)
          Creates a new PluginConfig.
 
Method Summary
 PluginConfig addConfiguration(String name, String value)
          Adds a config item to this PluginConfig.
 PluginConfig asPrivileged()
           
 Map<String,String> getConfiguration()
           
 String getConfigurationValue(String key)
           
 Double getDoubleValue(String name, Double defaultValue)
           
 long getId()
           
 Integer getIntegerValue(String name, Integer defaultValue)
           
 String getName()
           
 String getRoleName()
           
 boolean isPrivileged()
           
 String toString()
           
 boolean update(PluginConfig replacement)
          Updates the configuration from a matching PluginConfig (presumably this was read from a file or received as a message).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PluginConfig

public PluginConfig(String role,
                    String name)
Creates a new PluginConfig. Attributes can be added with the fluent-style addConfiguration() method. The role should be the classname of the type that is being configured (not the name of the type creating the PluginConfig, unless it's the same type). The name can be left blank as long as the role is a singleton; otherwise it should distinguish the instances of the role from each other.

Method Detail

getId

public long getId()

getRoleName

public String getRoleName()

getName

public String getName()

isPrivileged

public boolean isPrivileged()

asPrivileged

public PluginConfig asPrivileged()

getConfiguration

public Map<String,String> getConfiguration()

getConfigurationValue

public String getConfigurationValue(String key)

update

public boolean update(PluginConfig replacement)
Updates the configuration from a matching PluginConfig (presumably this was read from a file or received as a message). This only works if the roleName and name match. If successful, returns true; otherwise false.


addConfiguration

public PluginConfig addConfiguration(String name,
                                     String value)
Adds a config item to this PluginConfig. Returns the PluginConfig instance for convenience in stringing together config calls.


toString

public String toString()
Overrides:
toString in class Object

getIntegerValue

public Integer getIntegerValue(String name,
                               Integer defaultValue)

getDoubleValue

public Double getDoubleValue(String name,
                             Double defaultValue)


Copyright © 2012. All Rights Reserved.