com.rubecula.darwin.core
Class Environment_Abstract

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,Object>
          extended by com.rubecula.util.StringMap_Abstract
              extended by com.rubecula.darwin.core.Environment_Abstract
All Implemented Interfaces:
Environment, Identifiable, StringMap, Serializable, Cloneable, Map<String,Object>
Direct Known Subclasses:
Environment_Default, Environment_PepperedMoth

public abstract class Environment_Abstract
extends StringMap_Abstract
implements Environment, Identifiable

Abstract class defining base methods which implement Environment interface.

Author:
Robin Hillyard
See Also:
Serialized Form

Field Summary
protected static org.apache.commons.logging.Log log
          The logger for this class.
 
Constructor Summary
protected Environment_Abstract()
          Construct an empty unidentified environment (no eco factors).
protected Environment_Abstract(String identifier)
          Construct an empty identified environment (no eco factors).
 
Method Summary
 void addListener(EnvironmentListener listener)
          Mutating method to add a listener to changes in this Environment.
protected  void environmentChanged()
          This method should be called whenever the environment has changed.
 double getDoubleValue(String name)
          Method to retrieve the value of the eco factor defined by name.
 EcoFactor getFactor(String name)
          Method to retrieve the eco factor defined by name.
 String getIdentifier()
          Method to get the specific identifier for an object.
 Object put(EcoFactor factor)
          Add an eco factor to this environment.
 
Methods inherited from class com.rubecula.util.StringMap_Abstract
get, put
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rubecula.darwin.core.Environment
keySet
 
Methods inherited from interface com.rubecula.util.StringMap
get, put
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
The logger for this class.

Constructor Detail

Environment_Abstract

protected Environment_Abstract()
Construct an empty unidentified environment (no eco factors).


Environment_Abstract

protected Environment_Abstract(String identifier)
Construct an empty identified environment (no eco factors).

Parameters:
identifier - the identifier for this Environment (for logging).
Method Detail

addListener

public void addListener(EnvironmentListener listener)
Description copied from interface: Environment
Mutating method to add a listener to changes in this Environment.

Specified by:
addListener in interface Environment
Parameters:
listener - an object which is interested in changes to the environment.
See Also:
Collection.add(java.lang.Object)

getDoubleValue

public double getDoubleValue(String name)
Description copied from interface: Environment
Method to retrieve the value of the eco factor defined by name.

Specified by:
getDoubleValue in interface Environment
Parameters:
name - the name (identifier, key) of the eco factor.
Returns:
the eco factor value, as a double. If the value cannot be rendered as double, the result is undefined.

getFactor

public EcoFactor getFactor(String name)
Description copied from interface: Environment
Method to retrieve the eco factor defined by name.

Specified by:
getFactor in interface Environment
Parameters:
name - the name (identifier, key) of the eco factor.
Returns:
the eco factor value itself.

put

public Object put(EcoFactor factor)
Description copied from interface: Environment
Add an eco factor to this environment.

Specified by:
put in interface Environment
Parameters:
factor - the eco factor, whose identifier will be used as the key.
Returns:
the previous eco factor with the same identifier (if any), otherwise null.

getIdentifier

public String getIdentifier()
Description copied from interface: Identifiable
Method to get the specific identifier for an object.

Specified by:
getIdentifier in interface Identifiable
Returns:
the identifier

environmentChanged

protected void environmentChanged()
This method should be called whenever the environment has changed.