edu.memphis.ccrg.lida.framework.shared
Class ElementFactory

java.lang.Object
  extended by edu.memphis.ccrg.lida.framework.shared.ElementFactory

public class ElementFactory
extends java.lang.Object

Standard factory for the basic elements of the framework. Support for Node, Link, FrameworkTask, and NodeStructure

Author:
Javier Snaider, Ryan J. McCall

Method Summary
 void addDecayStrategy(java.lang.String name, StrategyDef decayDef)
          Adds a DecayStrategy indexed by specified name.
 void addExciteStrategy(java.lang.String name, StrategyDef exciteDef)
          Adds an excite strategy indexed by specified name.
 void addFrameworkTaskType(FrameworkTaskDef taskDef)
          Adds the FrameworkTask type.
 void addLinkType(LinkableDef linkDef)
          Adds a Link type to this factory
 void addLinkType(java.lang.String typeName, java.lang.String className)
          Adds a link type indexed by specified typeName
 void addNodeType(LinkableDef nodeDef)
          Adds a Node type to this factory
 void addNodeType(java.lang.String typeName, java.lang.String className)
          Adds a Node type indexed by specified typeName
 void addStrategy(java.lang.String name, StrategyDef strategyDef)
          Adds a strategy to this factory indexed by specified name.
 boolean containsLinkType(java.lang.String linkTypeName)
          Returns whether this factory contains specified Link type.
 boolean containsNodeType(java.lang.String nodeTypeName)
          Returns whether this factory contains specified Node type.
 boolean containsStrategy(java.lang.String strategyTypeName)
          Returns whether this factory contains specified Strategy type.
 boolean containsTaskType(java.lang.String typeName)
          Returns whether this factory contains specified FrameworkTask type.
 Behavior getBehavior(Scheme s)
          Returns a new Behavior based on specified Scheme of default behavior type.
 Behavior getBehavior(Scheme s, java.lang.String className)
          Returns a new Behavior of specified class based on specified Scheme.
 DecayStrategy getDecayStrategy(java.lang.String strategyTypeName)
          Gets decay strategy.
 DecayStrategy getDefaultDecayStrategy()
          Returns the default DecayStrategy
 java.lang.String getDefaultDecayType()
          Gets default decay type.
 ExciteStrategy getDefaultExciteStrategy()
          Returns the default ExciteStrategy
 java.lang.String getDefaultExciteType()
          Gets default excite type.
 java.lang.String getDefaultLinkType()
          Gets default link type.
 java.lang.String getDefaultNodeType()
          Gets default node type.
 ExciteStrategy getExciteStrategy(java.lang.String strategyTypeName)
          Gets excite strategy.
 FrameworkTask getFrameworkTask(java.lang.String taskType, java.util.Map<java.lang.String,? extends java.lang.Object> params)
          Returns a new FrameworkTask having specified attributes.
 FrameworkTask getFrameworkTask(java.lang.String taskType, java.util.Map<java.lang.String,? extends java.lang.Object> params, java.util.Map<ModuleName,FrameworkModule> modules)
          Returns a new FrameworkTask having specified attributes.
 FrameworkTask getFrameworkTask(java.lang.String taskType, java.lang.String decayStrategy, java.lang.String exciteStrategy, int ticksPerRun, double activation, double removalThreshold, java.util.Map<java.lang.String,? extends java.lang.Object> params, java.util.Map<ModuleName,FrameworkModule> modules)
          Returns a new FrameworkTask with specified attributes.
static ElementFactory getInstance()
          Returns the sole instance of this factory.
 Link getLink(Node source, Linkable sink, LinkCategory category)
          Creates and returns a new Link with specified source, sink, and category.
 Link getLink(Node source, Linkable sink, LinkCategory category, double activation, double removalThreshold)
          Creates and returns a new Link with specified source, sink, category, and activation.
 Link getLink(java.lang.String linkType, Node source, Linkable sink, LinkCategory category)
          Creates and returns a new Link with specified type, source, sink, and category.
 Link getLink(java.lang.String linkType, Node source, Linkable sink, LinkCategory category, java.lang.String decayStrategy, java.lang.String exciteStrategy, double activation, double removalThreshold)
          Creates and returns a new Link of specified type with specified source, sink, LinkCategory, DecayStrategy, ExciteStrategy, and category.
 Link getLink(java.lang.String requiredType, java.lang.String desiredType, Node source, Linkable sink, LinkCategory category)
          Checks if desiredType is-a requiredType.
 Node getNode()
          Creates a default node with the default strategies and default activation.
 Node getNode(Node oNode)
          Creates a copy of the supplied node with the default strategies.
 Node getNode(Node oNode, java.lang.String nodeType)
          Creates a copy of specified Node.
 Node getNode(Node oNode, java.lang.String decayStrategy, java.lang.String exciteStrategy)
          Creates a copy of oNode with the specified decay and excite strategies.
 Node getNode(java.lang.String nodeType)
          Creates new node of specified type.
 Node getNode(java.lang.String requiredType, Node oNode, java.lang.String desiredType)
          Creates a copy of specified node of desired type.
 Node getNode(java.lang.String type, java.lang.String label)
          Creates new node of specified type with specified label.
 Node getNode(java.lang.String nodeType, java.lang.String decayStrategy, java.lang.String exciteStrategy, java.lang.String nodeLabel, double activation, double removalThreshold)
          Creates a new node of specified type, strategies, label, and initial activation.
 NodeStructure getNodeStructure()
          Returns a new default NodeStructure.
 NodeStructure getNodeStructure(java.lang.String nodeType, java.lang.String linkType)
          Returns a new NodeStructure with specified Node and Link types.
 Strategy getStrategy(java.lang.String typeName)
          Get a strategy by type.
 void setDefaultDecayType(java.lang.String decayTypeName)
          Sets default decay type.
 void setDefaultExciteType(java.lang.String exciteTypeName)
          Sets default excite type.
 void setDefaultLinkType(java.lang.String linkTypeName)
          Set the default Link type used by this factory.
 void setDefaultNodeType(java.lang.String nodeTypeName)
          Set the default Node type used by this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ElementFactory getInstance()
Returns the sole instance of this factory. Implements the Singleton pattern.

Returns:
the sole ElementFactory instance of this class

addDecayStrategy

public void addDecayStrategy(java.lang.String name,
                             StrategyDef decayDef)
Adds a DecayStrategy indexed by specified name.

Parameters:
name - the name used to refer to the strategy
decayDef - the decay strategy's StrategyDef

addExciteStrategy

public void addExciteStrategy(java.lang.String name,
                              StrategyDef exciteDef)
Adds an excite strategy indexed by specified name.

Parameters:
name - the name used to reference the strategy
exciteDef - the excite strategy StrategyDef

addStrategy

public void addStrategy(java.lang.String name,
                        StrategyDef strategyDef)
Adds a strategy to this factory indexed by specified name.

Parameters:
name - the name
strategyDef - the StrategyDef

addLinkType

public void addLinkType(LinkableDef linkDef)
Adds a Link type to this factory

Parameters:
linkDef - the link def

addLinkType

public void addLinkType(java.lang.String typeName,
                        java.lang.String className)
Adds a link type indexed by specified typeName

Parameters:
typeName - the link type
className - the class name

addNodeType

public void addNodeType(LinkableDef nodeDef)
Adds a Node type to this factory

Parameters:
nodeDef - the node def

addNodeType

public void addNodeType(java.lang.String typeName,
                        java.lang.String className)
Adds a Node type indexed by specified typeName

Parameters:
typeName - the simple node name
className - the canonical node name

addFrameworkTaskType

public void addFrameworkTaskType(FrameworkTaskDef taskDef)
Adds the FrameworkTask type.

Parameters:
taskDef - FrameworkTaskDef

getDefaultLinkType

public java.lang.String getDefaultLinkType()
Gets default link type.

Returns:
the default link type

getDefaultNodeType

public java.lang.String getDefaultNodeType()
Gets default node type.

Returns:
the default node type

containsStrategy

public boolean containsStrategy(java.lang.String strategyTypeName)
Returns whether this factory contains specified Strategy type.

Parameters:
strategyTypeName - name of strategy type
Returns:
true if factory contains type or false if not

containsNodeType

public boolean containsNodeType(java.lang.String nodeTypeName)
Returns whether this factory contains specified Node type.

Parameters:
nodeTypeName - name of node type
Returns:
true if factory contains type or false if not

containsLinkType

public boolean containsLinkType(java.lang.String linkTypeName)
Returns whether this factory contains specified Link type.

Parameters:
linkTypeName - name of Link type
Returns:
true if factory contains type or false if not

containsTaskType

public boolean containsTaskType(java.lang.String typeName)
Returns whether this factory contains specified FrameworkTask type.

Parameters:
typeName - String
Returns:
true if factory contains type or false if not

getDecayStrategy

public DecayStrategy getDecayStrategy(java.lang.String strategyTypeName)
Gets decay strategy.

Parameters:
strategyTypeName - name of DecayStrategy type
Returns:
the decay strategy

getExciteStrategy

public ExciteStrategy getExciteStrategy(java.lang.String strategyTypeName)
Gets excite strategy.

Parameters:
strategyTypeName - name of excite strategy type
Returns:
the excite strategy

getStrategy

public Strategy getStrategy(java.lang.String typeName)
Get a strategy by type.

Parameters:
typeName - Name of sought strategy.
Returns:
Strategy if found or null.

getLink

public Link getLink(Node source,
                    Linkable sink,
                    LinkCategory category,
                    double activation,
                    double removalThreshold)
Creates and returns a new Link with specified source, sink, category, and activation.

Parameters:
source - Node that is link's source
sink - Linkable that is link's sink
category - LinkCategory
activation - initial activation
removalThreshold - threshold to remain in NodeStructure
Returns:
new Link

getLink

public Link getLink(Node source,
                    Linkable sink,
                    LinkCategory category)
Creates and returns a new Link with specified source, sink, and category. Zero initial activation.

Parameters:
source - Node that is link's source
sink - Linkable that is link's sink
category - LinkCategory
Returns:
new Link

getLink

public Link getLink(java.lang.String requiredType,
                    java.lang.String desiredType,
                    Node source,
                    Linkable sink,
                    LinkCategory category)
Checks if desiredType is-a requiredType. Creates and returns a Link of desiredType with specified parameters.

Parameters:
requiredType - Required Link type for NodeStructure
desiredType - Desired Link type for returned Link. Must be a subtype of required type.
source - Link's source
sink - Link's sink
category - Link's LinkCategory
Returns:
new Link with specified attributes.

getLink

public Link getLink(java.lang.String linkType,
                    Node source,
                    Linkable sink,
                    LinkCategory category)
Creates and returns a new Link with specified type, source, sink, and category.

Parameters:
linkType - the link type
source - Node that is link's source
sink - Linkable that is link's sink
category - LinkCategory
Returns:
new Link

getLink

public Link getLink(java.lang.String linkType,
                    Node source,
                    Linkable sink,
                    LinkCategory category,
                    java.lang.String decayStrategy,
                    java.lang.String exciteStrategy,
                    double activation,
                    double removalThreshold)
Creates and returns a new Link of specified type with specified source, sink, LinkCategory, DecayStrategy, ExciteStrategy, and category.

Parameters:
linkType - Link type
source - Link's source
sink - Link's sink
category - Link's category
decayStrategy - Link's DecayStrategy
exciteStrategy - Link's ExciteStrategy
activation - initial activation
removalThreshold - threshold of activation required to remain active
Returns:
new Link

getNode

public Node getNode()
Creates a default node with the default strategies and default activation.

Returns:
the node
See Also:
Activatible

getNode

public Node getNode(Node oNode)
Creates a copy of the supplied node with the default strategies. Note that the new node is of a default type regardless of the node passed in the parameter.

Parameters:
oNode - supplied node
Returns:
the node

getNode

public Node getNode(Node oNode,
                    java.lang.String nodeType)
Creates a copy of specified Node. The second argument specifies the type of the new node. The Activatible strategies of the new node are based on those specified by the Node type's LinkableDef (specified by factoriesData.xml) If the Node type does not specify default Activatible strategies then the default strategies are used. All other values of the specified Node are copied to the new Node, e.g. activation.

Parameters:
oNode - supplied node
nodeType - type of returned node
Returns:
the node

getNode

public Node getNode(java.lang.String type,
                    java.lang.String label)
Creates new node of specified type with specified label. Uses strategies based on specified node type, or the default strategies if the node type has no strategies defined.

Parameters:
type - type of new node
label - label of new node
Returns:
the node

getNode

public Node getNode(java.lang.String requiredType,
                    Node oNode,
                    java.lang.String desiredType)
Creates a copy of specified node of desired type. Desired type must pass is-a test with requireType.

Parameters:
requiredType - Default node type of NodeStructure
oNode - Node to be copied.
desiredType - type of copied node
Returns:
copy of oNode of desired type, or a new node of desired type, or null

getNode

public Node getNode(Node oNode,
                    java.lang.String decayStrategy,
                    java.lang.String exciteStrategy)
Creates a copy of oNode with the specified decay and excite strategies. The type of the new node will be the default node type.

Parameters:
oNode - supplied node
decayStrategy - new node's decay strategy
exciteStrategy - new node's excite strategy
Returns:
the node

getNode

public Node getNode(java.lang.String nodeType)
Creates new node of specified type. Uses strategies based on specified node type, or the default strategies if the node type has no strategies defined.

Parameters:
nodeType - type of desired node
Returns:
the node

getNode

public Node getNode(java.lang.String nodeType,
                    java.lang.String decayStrategy,
                    java.lang.String exciteStrategy,
                    java.lang.String nodeLabel,
                    double activation,
                    double removalThreshold)
Creates a new node of specified type, strategies, label, and initial activation.

Parameters:
nodeType - type of new node
decayStrategy - decay strategy of new node
exciteStrategy - excite strategy of new node
nodeLabel - label of new node
activation - activation of new node
removalThreshold - threshold node needs to remain in containing NodeStructures
Returns:
the node

setDefaultLinkType

public void setDefaultLinkType(java.lang.String linkTypeName)
Set the default Link type used by this factory.

Parameters:
linkTypeName - type of links created by this factory

setDefaultNodeType

public void setDefaultNodeType(java.lang.String nodeTypeName)
Set the default Node type used by this factory.

Parameters:
nodeTypeName - type of nodes created by this factory

getDefaultDecayType

public java.lang.String getDefaultDecayType()
Gets default decay type.

Returns:
the defaultDecayType

getDefaultDecayStrategy

public DecayStrategy getDefaultDecayStrategy()
Returns the default DecayStrategy

Returns:
Factory's default DecayStrategy

setDefaultDecayType

public void setDefaultDecayType(java.lang.String decayTypeName)
Sets default decay type.

Parameters:
decayTypeName - DecayType to be used

getDefaultExciteType

public java.lang.String getDefaultExciteType()
Gets default excite type.

Returns:
defaultExciteType ExciteType to be used

getDefaultExciteStrategy

public ExciteStrategy getDefaultExciteStrategy()
Returns the default ExciteStrategy

Returns:
Factory's default excite strategy

setDefaultExciteType

public void setDefaultExciteType(java.lang.String exciteTypeName)
Sets default excite type.

Parameters:
exciteTypeName - the defaultExciteType to set

getFrameworkTask

public FrameworkTask getFrameworkTask(java.lang.String taskType,
                                      java.util.Map<java.lang.String,? extends java.lang.Object> params)
Returns a new FrameworkTask having specified attributes. FrameworkTask will have strategies specified for the taskType. Task will not have any associate modules.

Parameters:
taskType - type of FrameworkTask
params - optional parameters to be set in object's init method
Returns:
the new FrameworkTask

getFrameworkTask

public FrameworkTask getFrameworkTask(java.lang.String taskType,
                                      java.util.Map<java.lang.String,? extends java.lang.Object> params,
                                      java.util.Map<ModuleName,FrameworkModule> modules)
Returns a new FrameworkTask having specified attributes. FrameworkTask will have strategies specified for the taskType

Parameters:
taskType - type of FrameworkTask
params - optional parameters to be set in object's init method
modules - map of modules for association.
Returns:
the new FrameworkTask

getFrameworkTask

public FrameworkTask getFrameworkTask(java.lang.String taskType,
                                      java.lang.String decayStrategy,
                                      java.lang.String exciteStrategy,
                                      int ticksPerRun,
                                      double activation,
                                      double removalThreshold,
                                      java.util.Map<java.lang.String,? extends java.lang.Object> params,
                                      java.util.Map<ModuleName,FrameworkModule> modules)
Returns a new FrameworkTask with specified attributes.

Parameters:
taskType - label for task
decayStrategy - DecayStrategy used by task
exciteStrategy - ExciteStrategy used by task
ticksPerRun - execution frequency
activation - initial activation
removalThreshold - activation needed to remain active
params - optional parameters to be set in object's init method
modules - map of modules for association.
Returns:
the new FrameworkTask

getNodeStructure

public NodeStructure getNodeStructure()
Returns a new default NodeStructure.

Returns:
a new NodeStructure with default Node type and default Link type.

getNodeStructure

public NodeStructure getNodeStructure(java.lang.String nodeType,
                                      java.lang.String linkType)
Returns a new NodeStructure with specified Node and Link types.

Parameters:
nodeType - type of node in returned NodeStructure
linkType - type of Link in returned NodeStructure
Returns:
a new NodeStructure with specified node type and specified link type or null if types do not exist in this factory.

getBehavior

public Behavior getBehavior(Scheme s)
Returns a new Behavior based on specified Scheme of default behavior type.

Parameters:
s - a Scheme
Returns:
a new Behavior

getBehavior

public Behavior getBehavior(Scheme s,
                            java.lang.String className)
Returns a new Behavior of specified class based on specified Scheme.

Parameters:
s - the Scheme generating the behavior.
className - qualified name of the desired Behavior class
Returns:
a new Behavior