org.primordion.xholon.base
Class TreeNodeFactoryDynamic

java.lang.Object
  extended byorg.primordion.xholon.base.Xholon
      extended byorg.primordion.xholon.base.TreeNodeFactoryDynamic
All Implemented Interfaces:
ITreeNodeFactory, IXholon

public class TreeNodeFactoryDynamic
extends Xholon
implements ITreeNodeFactory

TreeNodeFactoryDynamic manages concrete instances of TreeNode subclasses. Entities are dynamically created as needed. This class is designed to be compatible with TreeNodeFactoryStatic.

Since:
0.3 (Created on Feb 15, 2006)

TODO Keep track of how many instances of each type are instantiated, in order to be able to create applications where conservation is important.

TODO Another implementation of this class could keep all instantiated instances in a hash structure, allowing reuse of entities.

Author:
Ken Webb

Field Summary
 
Fields inherited from class org.primordion.xholon.base.Xholon
DEFAULT_LEVEL, interaction, interactionsEnabled
 
Fields inherited from interface org.primordion.xholon.base.IXholon
DEFAULT_SIZE_MSG_Q, NINCLUDE_PSC, NINCLUDE_PSx, NINCLUDE_PxC, NINCLUDE_Pxx, NINCLUDE_xSC, NINCLUDE_xSx, NINCLUDE_xxC, NINCLUDE_xxx
 
Constructor Summary
TreeNodeFactoryDynamic(java.lang.Class xholonSubclass, java.lang.Class xholonClassSubclass, java.lang.Class activitySubclass)
          Constructor.
 
Method Summary
 Activity getActivityNode()
          Get a Activity node from the factory.
 AbstractGrid getGridEntityNode()
          Get a GridEntity node from the factory.
 IXholon getNode(java.lang.Class xholonSubclass)
          Get a node instance of the specified Java class.
 IXholon getNode(int xhType)
          Get a node instance of the specified Xholon Type.
 int getNumAvailNodes(int resourceType)
          This is here for compatibility with TreeNodeFactoryStatic.
 StateMachineEntity getStateMachineEntityNode()
          Get a StateMaqchineEntity node from the factory.
 IXholonClass getXholonClassNode()
          Get a XholonClass instance from the factory.
 IXholon getXholonNode()
          Get a Xholon instance from the factory.
 IXholon getXholonNode(java.lang.String implName)
          Get a Xholon instance from the factory, based on its full package name.
 void returnTreeNode(IXholon node)
          Return a TreeNode to the factory.
 
Methods inherited from class org.primordion.xholon.base.Xholon
act, appendChild, appendChild, appendChild, cleanup, configure, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextId, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPort, getPreviousSibling, getRoleName, getRootNode, getSiblings, getSizeMessageQ, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, resetNextId, sendMessage, sendMessage, sendMessage, setAttributeVal, setFactory, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPorts, setRoleName, setSizeMessageQ, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, terminate, toString, treeSize, writeXml
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.primordion.xholon.base.IXholon
act, appendChild, appendChild, appendChild, cleanup, configure, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPort, getPreviousSibling, getRoleName, getRootNode, getSiblings, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, sendMessage, sendMessage, sendMessage, setAttributeVal, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPorts, setRoleName, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, terminate, treeSize, writeXml
 

Constructor Detail

TreeNodeFactoryDynamic

public TreeNodeFactoryDynamic(java.lang.Class xholonSubclass,
                              java.lang.Class xholonClassSubclass,
                              java.lang.Class activitySubclass)
Constructor. The three classes passed as parameters, are just defaults. It's still possible to call getNode(Class xholonSubclass) directly to get an instance of any Java class.

Parameters:
xholonSubclass - Which subclass of Xholon should be instantiated.
xholonClassSubclass - Which subclass of XholonClass should be instantiated.
activitySubclass - Which subclass of Activity should be instantiated.
Method Detail

getNumAvailNodes

public int getNumAvailNodes(int resourceType)
This is here for compatibility with TreeNodeFactoryStatic.

Specified by:
getNumAvailNodes in interface ITreeNodeFactory
Parameters:
resourceType - The type of node: Xholon, XholonClass, StateMachineEntity, or Activity.
Returns:
Number of available nodes.
See Also:
ITreeNodeFactory.getNumAvailNodes(int)

getNode

public IXholon getNode(java.lang.Class xholonSubclass)
Description copied from interface: ITreeNodeFactory
Get a node instance of the specified Java class.

Specified by:
getNode in interface ITreeNodeFactory
Parameters:
xholonSubclass -
Returns:
An IXholon instance.

getNode

public IXholon getNode(int xhType)
Description copied from interface: ITreeNodeFactory
Get a node instance of the specified Xholon Type.

Specified by:
getNode in interface ITreeNodeFactory
Parameters:
xhType -
Returns:
An IXholon instance.

getXholonNode

public IXholon getXholonNode()
Description copied from interface: ITreeNodeFactory
Get a Xholon instance from the factory.

Specified by:
getXholonNode in interface ITreeNodeFactory
Returns:
The next available instance, or null. TODO Need to handle null (Q_EMPTY) condition gracefully.

getXholonNode

public IXholon getXholonNode(java.lang.String implName)
Description copied from interface: ITreeNodeFactory
Get a Xholon instance from the factory, based on its full package name.

Specified by:
getXholonNode in interface ITreeNodeFactory
Parameters:
implName - The name of a Java class.
Returns:
An instance of that class, or null.

getXholonClassNode

public IXholonClass getXholonClassNode()
Description copied from interface: ITreeNodeFactory
Get a XholonClass instance from the factory.

Specified by:
getXholonClassNode in interface ITreeNodeFactory
Returns:
The next available instance, or null.

getActivityNode

public Activity getActivityNode()
Description copied from interface: ITreeNodeFactory
Get a Activity node from the factory.

Specified by:
getActivityNode in interface ITreeNodeFactory
Returns:
The next available instance, or null.

getStateMachineEntityNode

public StateMachineEntity getStateMachineEntityNode()
Description copied from interface: ITreeNodeFactory
Get a StateMaqchineEntity node from the factory.

Specified by:
getStateMachineEntityNode in interface ITreeNodeFactory
Returns:
The next available instance, or null.

getGridEntityNode

public AbstractGrid getGridEntityNode()
Description copied from interface: ITreeNodeFactory
Get a GridEntity node from the factory.

Specified by:
getGridEntityNode in interface ITreeNodeFactory
Returns:
The next available instance, or null.

returnTreeNode

public void returnTreeNode(IXholon node)
Description copied from interface: ITreeNodeFactory
Return a TreeNode to the factory.

Specified by:
returnTreeNode in interface ITreeNodeFactory
Parameters:
node - The TreeNode being returned.