Class DefaultControllerRegistry
- java.lang.Object
-
- repast.simphony.engine.controller.DefaultControllerRegistry
-
- All Implemented Interfaces:
Cloneable
,ControllerRegistry
public class DefaultControllerRegistry extends Object implements ControllerRegistry
Basic implementation of aControllerRegistry
.- Author:
- Jerry Vos
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<ParameterSetter>
paramSetters
-
Fields inherited from interface repast.simphony.engine.environment.ControllerRegistry
ACTION_TREE_ROOT, DEFAULT_MASTER_CONTEXT_ID
-
-
Constructor Summary
Constructors Constructor Description DefaultControllerRegistry()
Constructs the SimpleControllerRegistry with no actions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAction(Object contextId, ControllerAction parent, ControllerAction action)
Adds an action to those for the specified context, under the specified parent action.void
addContextId(Object parentId, Object newId)
void
addParameterSetter(ParameterSetter paramInit)
ControllerRegistry
clone()
ControllerAction
findAction(Object contextID, String actionID)
Finds a registered action.Tree<ControllerAction>
getActionTree(Object contextId)
Returns the root node for the tree of actions that occur for a specified context type.Tree<Object>
getContextIdTree()
Object
getMasterContextId()
String
getName()
Collection<ParameterSetter>
getParameterSetters()
void
registerAction(Object contextID, String id, ControllerAction action)
Registers an action so that it can be found later.boolean
removeAction(Object contextId, ControllerAction action)
Removes an action.void
removeContextId(Object id)
void
removeParameterSetter(ParameterSetter paramInit)
void
replaceAction(Object contextId, ControllerAction oldAction, ControllerAction newAction)
Replaces a given action with the specified action.void
replaceContextId(Object idToReplace, Object newId)
void
setMasterContextId(Object id)
void
setName(String name)
-
-
-
Field Detail
-
paramSetters
protected ArrayList<ParameterSetter> paramSetters
-
-
Method Detail
-
clone
public ControllerRegistry clone()
- Specified by:
clone
in interfaceControllerRegistry
- Overrides:
clone
in classObject
-
addAction
public void addAction(Object contextId, ControllerAction parent, ControllerAction action)
Adds an action to those for the specified context, under the specified parent action. If the specified parent is null then the parent is assumed to be the root of the tree. Also, if the specified context id has not already been added to the controller, it will be added as a child of the top level context.- Specified by:
addAction
in interfaceControllerRegistry
- Parameters:
contextId
- the id of the context this applies toparent
- the action under which this action occurs, can be nullaction
- the action to add
-
getActionTree
public Tree<ControllerAction> getActionTree(Object contextId)
Description copied from interface:ControllerRegistry
Returns the root node for the tree of actions that occur for a specified context type.- Specified by:
getActionTree
in interfaceControllerRegistry
- Parameters:
contextId
- the type id of the context who's action tree to return- Returns:
- the root node in the tree of actions
-
removeAction
public boolean removeAction(Object contextId, ControllerAction action)
Removes an action. Since the actions are stored as a tree, this has the side-effect of also removing all actions nested under the given action. If this behavior is not wanted use the#replaceAction(ControllerAction, ControllerAction)
method with aDefaultControllerAction
.- Specified by:
removeAction
in interfaceControllerRegistry
- Parameters:
action
- the action to remove- Returns:
- true if the action was removed, false if it was not in the registry
- See Also:
DefaultControllerAction
-
replaceAction
public void replaceAction(Object contextId, ControllerAction oldAction, ControllerAction newAction)
Replaces a given action with the specified action. This will result in an action tree with the old action replaced with the new one. Any actions nested under the old action will now be nested under the new action. If the new action is aDefaultControllerAction
this is the same as removing the given action without removing its children. This will not accept null as an argument, as it would not make sense as either an old action or as the new one that is replacing it. If null is received anInvalidParameterException
will be thrown.- Specified by:
replaceAction
in interfaceControllerRegistry
- Parameters:
oldAction
- the action to replacenewAction
- the action with which to replace the old one
-
getContextIdTree
public Tree<Object> getContextIdTree()
- Specified by:
getContextIdTree
in interfaceControllerRegistry
-
addContextId
public void addContextId(Object parentId, Object newId)
- Specified by:
addContextId
in interfaceControllerRegistry
-
removeContextId
public void removeContextId(Object id)
- Specified by:
removeContextId
in interfaceControllerRegistry
-
setMasterContextId
public void setMasterContextId(Object id)
- Specified by:
setMasterContextId
in interfaceControllerRegistry
-
getMasterContextId
public Object getMasterContextId()
- Specified by:
getMasterContextId
in interfaceControllerRegistry
-
replaceContextId
public void replaceContextId(Object idToReplace, Object newId)
- Specified by:
replaceContextId
in interfaceControllerRegistry
-
getName
public String getName()
- Specified by:
getName
in interfaceControllerRegistry
-
setName
public void setName(String name)
- Specified by:
setName
in interfaceControllerRegistry
-
registerAction
public void registerAction(Object contextID, String id, ControllerAction action)
Description copied from interface:ControllerRegistry
Registers an action so that it can be found later.- Specified by:
registerAction
in interfaceControllerRegistry
-
findAction
public ControllerAction findAction(Object contextID, String actionID)
Description copied from interface:ControllerRegistry
Finds a registered action.- Specified by:
findAction
in interfaceControllerRegistry
- Parameters:
contextID
- the context of the actionactionID
- the id of the action- Returns:
- the found action
-
addParameterSetter
public void addParameterSetter(ParameterSetter paramInit)
- Specified by:
addParameterSetter
in interfaceControllerRegistry
-
removeParameterSetter
public void removeParameterSetter(ParameterSetter paramInit)
- Specified by:
removeParameterSetter
in interfaceControllerRegistry
-
getParameterSetters
public Collection<ParameterSetter> getParameterSetters()
- Specified by:
getParameterSetters
in interfaceControllerRegistry
-
-