org.primordion.xholon.base
Interface IXholon

All Known Subinterfaces:
IApplication, IAttribute, IBioXholon, IBioXholonClass, IContainmentHierarchy, ICtrnn, IInheritanceHierarchy, IInteraction, IMembraneComputing, IMessage, IObservable, IPatch, IPort, IQueue, IStateMachineEntity, ITreeNodeFactory, ITurtle, IXholonClass
All Known Implementing Classes:
Application, Attribute.Attribute_boolean, Attribute.Attribute_byte, Attribute.Attribute_char, Attribute.Attribute_double, Attribute.Attribute_float, Attribute.Attribute_int, Attribute.Attribute_long, Attribute.Attribute_Object, Attribute.Attribute_short, Attribute.Attribute_String, BioXholonClass, ContainmentHierarchy, ec.gp.GPNode, InheritanceHierarchy, Interaction, Message, ObservableStateMachineEntity, ObservableXholonWithPorts, Patch, PatchOwner, Port, Queue, QueueStupidModel10, QueueStupidModel11, QueueStupidModel12, QueueStupidModel13, QueueStupidModel14, QueueStupidModel15, QueueStupidModel16, QueueStupidModel16nl, QueueStupidModel9, StateMachineEntity, TreeNodeFactoryDynamic, TreeNodeFactoryStatic, Turtle, XhAbstractCtrnn, XhAbstractMemComp, XhAbstractSbml, XhAdapSysLab, XhCell, XhCellAutop, XhCoopPSys00ex0, XhCoopSys02ex32_1, XhCoopSys02ex343_1, XhCoopSys02ex343_2, XhFsm06ex1, XhLife, Xholon, XholonClass, XholonTime, XhSymAnti02ex41

public interface IXholon

A Xholon is a node within a hierarchical tree structure, and builds on the capabilities of tree nodes. A tree node is a node in a tree. It has one parent (none if it's the root), and may have one or more children, and one or more siblings. A Xholon is both a whole, and a part of some other Xholon, at the same time. A Xholon is an instance of a IXholonClass. A Xholon can be an active object, a passive object, a container, or any combination of these three, as defined by its IXholonClass.

Since:
0.1 (Created on Jul 8, 2005)
Author:
Ken Webb

Field Summary
static int DEFAULT_SIZE_MSG_Q
           
static int NINCLUDE_PSC
           
static int NINCLUDE_PSx
           
static int NINCLUDE_PxC
           
static int NINCLUDE_Pxx
           
static int NINCLUDE_xSC
           
static int NINCLUDE_xSx
           
static int NINCLUDE_xxC
           
static int NINCLUDE_xxx
           
 
Method Summary
 void act()
          Do some action during this time step.
 void appendChild(IXholon newParentNode)
          Append this node as the last child of its new parent node.
 IXholon appendChild(java.lang.String xhClassName, java.lang.String roleName)
          Create a new child, and append it as the last child of this node.
 IXholon appendChild(java.lang.String xhClassName, java.lang.String roleName, java.lang.String implName)
          Create a new child, and append it as the last child of this node.
 void cleanup()
          Do any required cleanup work once the application has stopped executing.
 void configure()
          Perform some action, typically once at start up; MAY be overridden.
 int configure(java.lang.String instructions, int instructIx)
          Configure something based on a configure instruction.
 int createStructure(java.util.Vector containmentData, int myIx, ITreeNodeFactory factory, IInheritanceHierarchy inherHier)
          Recursively create this Xholon and its internal part structure, as nodes within the overall composite structure tree.
 void decVal(double decAmount)
          Decrement an internal double value by a specified amount.
 void decVal(int decAmount)
          Decrement an internal int value by a specified amount.
 int depth()
          Get the number of ancestors of this node, excluding this node itself.
 void draw()
          Draw a 2D representation of the tree, using inorder traversal.
 java.util.Vector getChildNodes(boolean deep)
          Get all children of this node.
 IXholon getFirstChild()
          Get first (leftmost) child of this node.
 IXholon getFirstSibling()
          Get first (leftmost) sibling.
 int getId()
          Get ID of this TreeNode instance.
 IXholon getLastChild()
          Get last (rightmost) child.
 IXholon getLastSibling()
          Get last (rightmost) sibling.
 java.lang.String getName()
          Get name, unique within this application, of this Xholon instance.
 java.util.Vector getNeighbors(int distance, int include, java.lang.String excludeBecName)
          Get neighbors.
 IXholon getNextSibling()
          Get next (right) sibling of this node.
 IXholon getNthChild(int n, boolean deep)
          Get the nth child of this node, where 0 <= n < number of children.
 IXholon getNthSibling(int n)
          Get nth sibling.
 int getNumChildren(boolean deep)
          Get number of children that this node has.
 int getNumSiblings()
          Get number of siblings.
 IXholon getParentNode()
          Get parent of this node.
 IXholon getPort(int portNum)
          Get the port that corresponds to this index (0 indexed).
 IXholon getPreviousSibling()
          Get previous (left) sibling of this node.
 java.lang.String getRoleName()
          Get name of the role played by this Xholon within a specific context.
 IXholon getRootNode()
          Get root of the tree that this node is a part of.
 java.util.Vector getSiblings()
          Get siblings.
 java.lang.String getUid()
          Get globally unique ID.
 boolean getVal_boolean()
          Get the value of a "boolean" maintained by this xholon instance.
 byte getVal_byte()
          Get the value of a "byte" maintained by this xholon instance.
 char getVal_char()
          Get the value of a "char" maintained by this xholon instance.
 double getVal_double()
          Get the value of a "double" maintained by this xholon instance.
 float getVal_float()
          Get the value of a "float" maintained by this xholon instance.
 int getVal_int()
          Get the value of a "int" maintained by this xholon instance.
 long getVal_long()
          Get the value of a "long" maintained by this xholon instance.
 java.lang.Object getVal_Object()
          Get the value of a "Object" maintained by this xholon instance.
 short getVal_short()
          Get the value of a "short" maintained by this xholon instance.
 java.lang.String getVal_String()
          Get the value of a "String" maintained by this xholon instance.
 double getVal()
          Get the value of a "double" maintained by this xholon instance.
 IXholonClass getXhc()
          Get the IXholonClass to which this Xholon instance is a member.
 int getXhcId()
          Get the ID of the IXholonClass to which this Xholon instance is a member.
 java.lang.String getXhcName()
          Get the name of the IXholonClass to which this Xholon instance is a member.
 int getXhType()
          Get the Xholon type, as known to this Xholon's IXholonClass.
 java.lang.String handleNodeSelection()
          Handle selection of a tree node by a user, as when a person clicks on a JTree node in the default viewer.
 boolean hasAncestor(java.lang.String tnName)
          Does this instance of Xholon have the specified node as one of its ancestors (parent, grandparent, etc.), within its containment tree.
 boolean hasChildNodes()
          Does this node have a first (left) child.
 boolean hasChildOrSiblingNodes()
          Does this node have either a first child or a next sibling or both.
 boolean hasNextSibling()
          Does this node have a next (right) sibling.
 boolean hasParentNode()
          Does this node have a parent.
 int height()
          Get number of levels in hierarchical tree.
 void incVal(double incAmount)
          Increment an internal double value by a specified amount.
 void incVal(int incAmount)
          Increment an internal int value by a specified amount.
 void initialize()
          Initialize the tree node.
 void initStatics()
          Initialize any static varibles that can't be statically initialized.
 void inOrderPrint(int level)
          In-order print.
 void insertAfter(IXholon newPreviousSibling)
          Insert this node after its new previous sibling node.
 void insertBefore(IXholon newNextSibling)
          Insert this node before its new next sibling node.
 void insertFirstChild(IXholon newParentNode)
          Insert this node as the first child of its new parent node.
 boolean isActiveObject()
          Is this xholon or xholon class an Active Object?
 boolean isBound(IXholon port)
          Is this port bound to anything? If a port is bound, then it will be possible for the local IXholon to send a message to, or get/set a val on, a remote IXholon.
 boolean isContainer()
          Is this xholon or xholon class a Container?
 boolean isExternal()
          Is this an external node (no child or siblings).
 boolean isInternal()
          Is this an internal node (has child and/or siblings).
 boolean isLeaf()
          Is this a leaf node (has no child, but may have siblings).
 boolean isPassiveObject()
          Is this xholon or xholon class a Passive Object?
 boolean isRootNode()
          Is this the root node of the tree (does it have a parent).
 void performActivity(int activityId)
          Do the activity identified by the activityId.
 void performActivity(int activityId, IMessage msg)
          Do the UML2 Activity identified by the activityId.
 boolean performBooleanActivity(int activityId)
          Do the UML2 Activity identified by the activityId.
 boolean performBooleanActivity(IXholon activity)
          Perform an activity including the entire activity subtree.
 double performDoubleActivity(IXholon activity)
          Perform an activity including the entire activity subtree.
 boolean performGuard(int activityId, IMessage msg)
          Do the UML2 Activity identified by the activityId.
 void performVoidActivity(IXholon activity)
          Perform an activity including the entire activity subtree.
 void postAct()
          Do any required work after doing the main action during a time step.
 void postConfigure()
          Perform some action, typically once at start up; MAY be overridden.
 void postOrderPrint(int level)
          Post-order print.
 void postReconfigure()
          Post-reconfigure.
 void preAct()
          Do any setup required before doing the main action during a time step.
 void preConfigure()
          Perform some action, typically once at start up; MAY be overridden.
 void preOrderPrint(int level)
          Pre-order print.
 void preReconfigure()
          Pre-Reconfigure, such as at the start of a new GP generation.
 void print(java.lang.Object obj)
          Write an object to standard out.
 void println(java.lang.Object obj)
          Write an object to standard out, terminated with an end-of-line.
 void processMessageQ()
          Process ROOM/UML2 messages that are on the message queue.
 void processReceivedMessage(Message msg)
          Process a received ROOM/UML2 message taken from the message queue.
 void reconfigure()
          Reconfigure, such as at the start of a new GP generation.
 void remove()
          Remove this node from the model, by recursively removing all children and next siblings, and by then returning it to the factory.
 void removeChild()
          Detach this node from its parent and from any siblings.
 void sendMessage(int signal, java.lang.Object data, IXholon sender)
          Send a ROOM/UML2 message to a receiving Xholon instance.
 void sendMessage(int signal, java.lang.Object data, IXholon sender, int index)
          Send a ROOM/UML2 message to a receiving Xholon instance.
 void sendMessage(Message msg)
          Send a ROOM/UML2 message to a receiving Xholon instance.
 int setAttributeVal(java.lang.String attrName, java.lang.String attrVal)
          Set the value of an attribute, given it's name.
 void setFirstChild(IXholon treeNode)
          Set first (leftmost) child of this node.
 void setId(int id)
          Set the ID of this TreeNode instance.
 void setNextSibling(IXholon treeNode)
          Set next (right) sibling of this node.
 void setParentChildLinks(IXholon parent)
          Set parent child links.
 void setParentNode(IXholon treeNode)
          Set parent of this node.
 void setParentSiblingLinks(IXholon previousSibling)
          Set parent sibling links.
 void setPorts()
          Set ports, by creating an array of ports.
 void setRoleName(java.lang.String roleName)
          Set name of the role played by this Xholon within a specific context.
 void setUid(java.lang.String uid)
          Set globally unique ID.
 void setVal(boolean val)
          Set the value of a "boolean" maintained by this xholon instance.
 void setVal(byte val)
          Set the value of a "byte" maintained by this xholon instance.
 void setVal(char val)
          Set the value of a "char" maintained by this xholon instance.
 void setVal(double val)
          Set the value of a "double" maintained by this xholon instance.
 void setVal(float val)
          Set the value of a "float" maintained by this xholon instance.
 void setVal(int val)
          Set the value of a "int" maintained by this xholon instance.
 void setVal(long val)
          Set the value of a "long" maintained by this xholon instance.
 void setVal(java.lang.Object val)
          Set the value of a "Object" maintained by this xholon instance.
 void setVal(short val)
          Set the value of a "short" maintained by this xholon instance.
 void setVal(java.lang.String val)
          Set the value of a "String" maintained by this xholon instance.
 int setVariableValue(java.lang.String instructions, int instructIx)
          Set the value of a variable using reflection.
 void setXhc(IXholonClass xhcNode)
          Set the IXholonClass to which this Xholon instance belongs.
 void swapNode(IXholon otherNode)
          Swap this node with otherNode.
 void terminate()
          Terminate a UML2 state machine, and optionally terminate the xholon that owns the state machine.
 int treeSize()
          Get number of nodes in tree.
 void writeXml(int level, java.io.Writer fw)
          Write self to a file as XML.
 

Field Detail

DEFAULT_SIZE_MSG_Q

public static final int DEFAULT_SIZE_MSG_Q
See Also:
Constant Field Values

NINCLUDE_xxx

public static final int NINCLUDE_xxx
See Also:
Constant Field Values

NINCLUDE_xxC

public static final int NINCLUDE_xxC
See Also:
Constant Field Values

NINCLUDE_xSx

public static final int NINCLUDE_xSx
See Also:
Constant Field Values

NINCLUDE_xSC

public static final int NINCLUDE_xSC
See Also:
Constant Field Values

NINCLUDE_Pxx

public static final int NINCLUDE_Pxx
See Also:
Constant Field Values

NINCLUDE_PxC

public static final int NINCLUDE_PxC
See Also:
Constant Field Values

NINCLUDE_PSx

public static final int NINCLUDE_PSx
See Also:
Constant Field Values

NINCLUDE_PSC

public static final int NINCLUDE_PSC
See Also:
Constant Field Values
Method Detail

remove

public void remove()
Remove this node from the model, by recursively removing all children and next siblings, and by then returning it to the factory.


getParentNode

public IXholon getParentNode()
Get parent of this node.

Returns:
This node's current parent.

setParentNode

public void setParentNode(IXholon treeNode)
Set parent of this node.

Parameters:
treeNode - This node's new parent.

getFirstChild

public IXholon getFirstChild()
Get first (leftmost) child of this node.

Returns:
First child, or null.

setFirstChild

public void setFirstChild(IXholon treeNode)
Set first (leftmost) child of this node.

Parameters:
treeNode - This node's new first child.

getNextSibling

public IXholon getNextSibling()
Get next (right) sibling of this node.

Returns:
Next sibling, or null.

setNextSibling

public void setNextSibling(IXholon treeNode)
Set next (right) sibling of this node.

Parameters:
treeNode - This node's new next sibling.

getPreviousSibling

public IXholon getPreviousSibling()
Get previous (left) sibling of this node. (may be expensive in processing time)

Returns:
Previous Sibling, or null.

getRootNode

public IXholon getRootNode()
Get root of the tree that this node is a part of.

Returns:
Root. If this node is the root, it returns itself.

setParentChildLinks

public void setParentChildLinks(IXholon parent)
Set parent child links. Call this function on the firstChild of a parent. equivalent to: node->setParent( parent ); parent->setFirstChild( node );

Parameters:
parent - This node's new parent.

setParentSiblingLinks

public void setParentSiblingLinks(IXholon previousSibling)
Set parent sibling links. Call this function on the node that is pointed to by the previousSibling. equivalent to: node->setParent( previousSibling->getParent() ); previousSibling->setNextSibling( node );

Parameters:
previousSibling - This node's new previous sibling.

setAttributeVal

public int setAttributeVal(java.lang.String attrName,
                           java.lang.String attrVal)
Set the value of an attribute, given it's name. The default implementation of this should handle any variable with the name "val". Concrete subclasses may handle any other variables, which would be required if using JavaMicro reflection.

Parameters:
attrName - The name of an attribute.
attrVal - The intended value of the attribute.
Returns:
The Java class type of the input val. Returns JAVACLASS_UNKNOWN if the attribute cannot be set.

removeChild

public void removeChild()
Detach this node from its parent and from any siblings. Any siblings are reattached to each other. If there was a previous sibling and a next sibling, these will be attached to each other. If there was only a previous sibling, it's next sibling will now be null. If this node was the parent's firstChild, the parent's firstChild link will be appropriately adjusted. Any children are left intact. The entire subtree is detached. The node is NOT deleted or returned to the factory.


insertAfter

public void insertAfter(IXholon newPreviousSibling)
Insert this node after its new previous sibling node.

Parameters:
newPreviousSibling - New previous sibling of this node.

insertBefore

public void insertBefore(IXholon newNextSibling)
Insert this node before its new next sibling node.

Parameters:
newNextSibling - New next sibling of this node.

insertFirstChild

public void insertFirstChild(IXholon newParentNode)
Insert this node as the first child of its new parent node.

Parameters:
newParentNode - New parent of this node.

appendChild

public void appendChild(IXholon newParentNode)
Append this node as the last child of its new parent node.

Parameters:
newParentNode - New parent of this node.

swapNode

public void swapNode(IXholon otherNode)
Swap this node with otherNode.

Parameters:
otherNode - The node to swap position with.

depth

public int depth()
Get the number of ancestors of this node, excluding this node itself. The depth of the root node in the tree is 0.


height

public int height()
Get number of levels in hierarchical tree. The height is computed by traversing both the firstChild and nextSibling nodes.

Returns:
Height of the tree starting from this node.

treeSize

public int treeSize()
Get number of nodes in tree.

Returns:
Total number of nodes in the tree, starting from and including this node.

isRootNode

public boolean isRootNode()
Is this the root node of the tree (does it have a parent).

Returns:
true or false

isExternal

public boolean isExternal()
Is this an external node (no child or siblings).

Returns:
true or false

isInternal

public boolean isInternal()
Is this an internal node (has child and/or siblings).

Returns:
true or false

isLeaf

public boolean isLeaf()
Is this a leaf node (has no child, but may have siblings).

Returns:
true or false

getChildNodes

public java.util.Vector getChildNodes(boolean deep)
Get all children of this node.

Parameters:
deep - If true then return entire nested subtree, if false return only immediate children.
Returns:
Vector containining all the children.

getNthChild

public IXholon getNthChild(int n,
                           boolean deep)
Get the nth child of this node, where 0 <= n < number of children.

Parameters:
n - The index of the child being requested.
deep - If true then return entire nested subtree, if false return only immediate children.
Returns:
The nth child, or null.

hasParentNode

public boolean hasParentNode()
Does this node have a parent.

Returns:
true or false

hasChildNodes

public boolean hasChildNodes()
Does this node have a first (left) child.

Returns:
true or false

hasNextSibling

public boolean hasNextSibling()
Does this node have a next (right) sibling.

Returns:
true or false

hasChildOrSiblingNodes

public boolean hasChildOrSiblingNodes()
Does this node have either a first child or a next sibling or both.

Returns:
true or false

getNumChildren

public int getNumChildren(boolean deep)
Get number of children that this node has.

Parameters:
deep - If true then return entire nested subtree, if false return only immediate children.
Returns:
Number of children.

getLastChild

public IXholon getLastChild()
Get last (rightmost) child.

Returns:
Last child, or null.

getLastSibling

public IXholon getLastSibling()
Get last (rightmost) sibling.

Returns:
Last sibling, or null.

getFirstSibling

public IXholon getFirstSibling()
Get first (leftmost) sibling.

Returns:
First sibling, or null.

getSiblings

public java.util.Vector getSiblings()
Get siblings.

Returns:
Vector containing all siblings.

getNthSibling

public IXholon getNthSibling(int n)
Get nth sibling.

Parameters:
n - The index of the sibling being requested.
Returns:
The nth sibling, or null.

getNumSiblings

public int getNumSiblings()
Get number of siblings.

Returns:
The number of siblings.

getNeighbors

public java.util.Vector getNeighbors(int distance,
                                     int include,
                                     java.lang.String excludeBecName)
Get neighbors.

Parameters:
distance - How far within the tree to search for neighbors.
include - Whether to include (P)arent and/or (S)iblings and/or (C)hildren.
excludeBecName - Name of a XholonClass, used to limit the scope of the returned Vector. TODO this uses an IXholon method
Returns:
Vector containing all neighbors (instances of TreeNode).

preOrderPrint

public void preOrderPrint(int level)
Pre-order print. Print current node; then traverse children and siblings.

Parameters:
level - Level in the tree, where the root node is level 0.

inOrderPrint

public void inOrderPrint(int level)
In-order print. Traverse children; then print current node; then traverse siblings.

Parameters:
level - Level in the tree, where the root node is level 0.

postOrderPrint

public void postOrderPrint(int level)
Post-order print. Traverse children and siblings; then print current node.

Parameters:
level - Level in the tree, where the root node is level 0.

writeXml

public void writeXml(int level,
                     java.io.Writer fw)
Write self to a file as XML.

Parameters:
level - Level in the tree, where the root node is level 0.
fw - The file to write to.

draw

public void draw()
Draw a 2D representation of the tree, using inorder traversal. source: Goodrich & Tamassia (2001) p. 255 "We can draw a binary tree T with an algorithm that assigns x- and y-coordinates to a node v of T using the follosing two rules: 1) x(v) is equal to the number of nodes visited before v in the inorder traversal of T. 2) y(v) is equal to the depth of v in T."


initialize

public void initialize()
Initialize the tree node. Typically this is only used to re-initialize a node, such as when it is reused through the TreeNodeFactoryStatic.


initStatics

public void initStatics()
Initialize any static varibles that can't be statically initialized. ex: Rcs2 needs to initialize some static variables after XholonClass instances have been read in.


preConfigure

public void preConfigure()
Perform some action, typically once at start up; MAY be overridden. Recursive; application should call this only for root.


configure

public void configure()
Perform some action, typically once at start up; MAY be overridden. Recursive; application should call this only for root.


configure

public int configure(java.lang.String instructions,
                     int instructIx)
Configure something based on a configure instruction.

Parameters:
instructions - A String that contains a configure instruction.
instructIx - An index into the instructions String.
Returns:
An updated index into the instructions String.

postConfigure

public void postConfigure()
Perform some action, typically once at start up; MAY be overridden. Recursive; application should call this only for root.


preReconfigure

public void preReconfigure()
Pre-Reconfigure, such as at the start of a new GP generation.


reconfigure

public void reconfigure()
Reconfigure, such as at the start of a new GP generation.


postReconfigure

public void postReconfigure()
Post-reconfigure.


preAct

public void preAct()
Do any setup required before doing the main action during a time step.


act

public void act()
Do some action during this time step. Typically all nodes in the tree will do their pre-actions (optional), then all will do their actions, and then all will do their post-actions (optional).


postAct

public void postAct()
Do any required work after doing the main action during a time step.


cleanup

public void cleanup()
Do any required cleanup work once the application has stopped executing. This could be used for example to delete or cancel any timers that have been set, which would be especially important if another application is subsequently opened.


getId

public int getId()
Get ID of this TreeNode instance.

Returns:
An integer ID, unique within this application, that is assigned when the TreeNode is created.

setId

public void setId(int id)
Set the ID of this TreeNode instance.

Parameters:
id - The ID of this TreeNode.

print

public void print(java.lang.Object obj)
Write an object to standard out.

Parameters:
obj - The object to write.

println

public void println(java.lang.Object obj)
Write an object to standard out, terminated with an end-of-line.

Parameters:
obj - The object to write.

getName

public java.lang.String getName()
Get name, unique within this application, of this Xholon instance. The name is a concatenation of the IXholonClass name and the Xholon unique ID. The first letter is converted to lowercase, and a "_" is used to separate the name and ID. ex: "helloWorld_123"

Returns:
The unique name of this Xholon instance.

getXhc

public IXholonClass getXhc()
Get the IXholonClass to which this Xholon instance is a member.

Returns:
The IXholonClass.

getXhcId

public int getXhcId()
Get the ID of the IXholonClass to which this Xholon instance is a member.

Returns:
The ID of the IXholonClass.

getXhcName

public java.lang.String getXhcName()
Get the name of the IXholonClass to which this Xholon instance is a member.

Returns:
The name of the IXholonClass.

setXhc

public void setXhc(IXholonClass xhcNode)
Set the IXholonClass to which this Xholon instance belongs.

Parameters:
xhcNode - The IXholonClass.

getXhType

public int getXhType()
Get the Xholon type, as known to this Xholon's IXholonClass. Typical values include XhtypePureActiveObject, XhtypePurePassiveObject, XhtypePureContainer.

Returns:
The Xholon type.

isContainer

public boolean isContainer()
Is this xholon or xholon class a Container?

Returns:
true or false

isActiveObject

public boolean isActiveObject()
Is this xholon or xholon class an Active Object?

Returns:
true or false

isPassiveObject

public boolean isPassiveObject()
Is this xholon or xholon class a Passive Object?

Returns:
true or false

hasAncestor

public boolean hasAncestor(java.lang.String tnName)
Does this instance of Xholon have the specified node as one of its ancestors (parent, grandparent, etc.), within its containment tree.

Parameters:
tnName - the searched-for ancestor
Returns:
true or false

createStructure

public int createStructure(java.util.Vector containmentData,
                           int myIx,
                           ITreeNodeFactory factory,
                           IInheritanceHierarchy inherHier)
Recursively create this Xholon and its internal part structure, as nodes within the overall composite structure tree.

Parameters:
containmentData - Vector of containment data (composite structure) read in from a file.
myIx - Current index into the containment data vector.
factory - Where Xholon instances are made.
inherHier - Inheritance hierarchy tree containing instances of IXholonClass.
Returns:
Updated index into the containment data vector.

setPorts

public void setPorts()
Set ports, by creating an array of ports. A port is a reference to a Xholon somewhere else in the tree.


getPort

public IXholon getPort(int portNum)
Get the port that corresponds to this index (0 indexed).

Parameters:
portNum - The index of the port within this Xholon's port array.
Returns:
The port.

isBound

public boolean isBound(IXholon port)
Is this port bound to anything? If a port is bound, then it will be possible for the local IXholon to send a message to, or get/set a val on, a remote IXholon.

If the port is intended to be a direct reference to another IXholon, then isBound() will return true if the port actually references a concrete IXholon, and will return false if the port value is null.

If the port is intended to be an IPort, then isBound() will return true if there is an end-to-end connection to a remote IXholon, and will return false if the port value is null or if it does not connect all the way through to a remote IXholon.

Returns:
true or false

setRoleName

public void setRoleName(java.lang.String roleName)
Set name of the role played by this Xholon within a specific context.

Parameters:
roleName - An optional name that identifies the role.

getRoleName

public java.lang.String getRoleName()
Get name of the role played by this Xholon within a specific context.

Returns:
A name that identifies the role, or null.

setUid

public void setUid(java.lang.String uid)
Set globally unique ID.

Parameters:
uid - A globally unique ID, typically assigned by some external tool such as a UML modeling tool.

getUid

public java.lang.String getUid()
Get globally unique ID.

Returns:
A globally unique ID, typically assigned by some external tool such as a UML modeling tool.

getVal

public double getVal()
Get the value of a "double" maintained by this xholon instance. If a class that implements this interface does not maintain such a value, it should return 0.0 This method can be used in place of getVal_double()

Returns:
A double value.

setVal

public void setVal(double val)
Set the value of a "double" maintained by this xholon instance.

Parameters:
val - The new value.

incVal

public void incVal(double incAmount)
Increment an internal double value by a specified amount. This is a convenience method.

Parameters:
incAmount - Increment amount.

incVal

public void incVal(int incAmount)
Increment an internal int value by a specified amount. This is a convenience method.

Parameters:
incAmount - Increment amount.

decVal

public void decVal(double decAmount)
Decrement an internal double value by a specified amount. This is a convenience method.

Parameters:
decAmount - Decrement amount.

decVal

public void decVal(int decAmount)
Decrement an internal int value by a specified amount. This is a convenience method.

Parameters:
decAmount - Decrement amount.

getVal_boolean

public boolean getVal_boolean()
Get the value of a "boolean" maintained by this xholon instance.


setVal

public void setVal(boolean val)
Set the value of a "boolean" maintained by this xholon instance.


getVal_byte

public byte getVal_byte()
Get the value of a "byte" maintained by this xholon instance.


setVal

public void setVal(byte val)
Set the value of a "byte" maintained by this xholon instance.


getVal_char

public char getVal_char()
Get the value of a "char" maintained by this xholon instance.


setVal

public void setVal(char val)
Set the value of a "char" maintained by this xholon instance.


getVal_double

public double getVal_double()
Get the value of a "double" maintained by this xholon instance.


getVal_float

public float getVal_float()
Get the value of a "float" maintained by this xholon instance.


setVal

public void setVal(float val)
Set the value of a "float" maintained by this xholon instance.


getVal_int

public int getVal_int()
Get the value of a "int" maintained by this xholon instance.


setVal

public void setVal(int val)
Set the value of a "int" maintained by this xholon instance.


getVal_long

public long getVal_long()
Get the value of a "long" maintained by this xholon instance.


setVal

public void setVal(long val)
Set the value of a "long" maintained by this xholon instance.


getVal_short

public short getVal_short()
Get the value of a "short" maintained by this xholon instance.


setVal

public void setVal(short val)
Set the value of a "short" maintained by this xholon instance.


getVal_String

public java.lang.String getVal_String()
Get the value of a "String" maintained by this xholon instance.


setVal

public void setVal(java.lang.String val)
Set the value of a "String" maintained by this xholon instance.


getVal_Object

public java.lang.Object getVal_Object()
Get the value of a "Object" maintained by this xholon instance.


setVal

public void setVal(java.lang.Object val)
Set the value of a "Object" maintained by this xholon instance.


setVariableValue

public int setVariableValue(java.lang.String instructions,
                            int instructIx)
Set the value of a variable using reflection.

Parameters:
instructions - A string containing the variable.
instructIx - An index into the string.
Returns:
Updated index into the string, past the end of the variable.

handleNodeSelection

public java.lang.String handleNodeSelection()
Handle selection of a tree node by a user, as when a person clicks on a JTree node in the default viewer. Any action performed here should be minimal. Ideally there should be no side effects. WARNING: There may be thread issues.

Returns:
A String with information about that node, that could for example be displayed.

appendChild

public IXholon appendChild(java.lang.String xhClassName,
                           java.lang.String roleName)
Create a new child, and append it as the last child of this node.

Parameters:
xhClassName - Name of an existing IXholonClass.
roleName - Optional role name.
Returns:
The newly created node. It's optional if the calling method wants to use this in any way.

appendChild

public IXholon appendChild(java.lang.String xhClassName,
                           java.lang.String roleName,
                           java.lang.String implName)
Create a new child, and append it as the last child of this node. Make it an instance of a designated Java class.

Parameters:
xhClassName - Name of an existing IXholonClass.
roleName - Optional role name.
implName - Full-package name of a Java class.
Returns:
The newly created node. It's optional if the calling method wants to use this in any way.

sendMessage

public void sendMessage(int signal,
                        java.lang.Object data,
                        IXholon sender)
Send a ROOM/UML2 message to a receiving Xholon instance.

Parameters:
signal - A distinguishing identifier for this message.
data - Any data that needs to be sent (optional).
sender - The sender of the message.

sendMessage

public void sendMessage(int signal,
                        java.lang.Object data,
                        IXholon sender,
                        int index)
Send a ROOM/UML2 message to a receiving Xholon instance.

Parameters:
signal - A distinguishing identifier for this message.
data - Any data that needs to be sent (optional).
sender - The sender of the message.
index - The index of a replicated port.

sendMessage

public void sendMessage(Message msg)
Send a ROOM/UML2 message to a receiving Xholon instance.

Parameters:
msg - An already existing message.

processReceivedMessage

public void processReceivedMessage(Message msg)
Process a received ROOM/UML2 message taken from the message queue. All sent messages are placed in queues before they are processed.

Parameters:
msg - The message that was received.

processMessageQ

public void processMessageQ()
Process ROOM/UML2 messages that are on the message queue. Typically, this will involve calling processReceivedMessage() for each message.


terminate

public void terminate()
Terminate a UML2 state machine, and optionally terminate the xholon that owns the state machine. The UML 2.1.1 specification states (section 15.3.8): "Entering a terminate pseudostate implies that the execution of this state machine by means of its context object is terminated. The state machine does not exit any states nor does it perform any exit actions other than those associated with the transition leading to the terminate pseudostate. Entering a terminate pseudostate is equivalent to invoking a DestroyObjectAction." The same action is performed if a state machine reaches its top level FinalState.


performActivity

public void performActivity(int activityId,
                            IMessage msg)
Do the UML2 Activity identified by the activityId. This is code called during a state Transition, or while entering, exiting, or within a State.

Parameters:
activityId - An ID that uniquely identifies an activity to invoke.
msg - The message that triggered this Transition.

performBooleanActivity

public boolean performBooleanActivity(int activityId)
Do the UML2 Activity identified by the activityId. This is code called during an Activity.

Parameters:
activityId - An ID that uniquely identifies an activity to invoke.
Returns:
true or false

performGuard

public boolean performGuard(int activityId,
                            IMessage msg)
Do the UML2 Activity identified by the activityId. This is code called before a Transition from a State or Choice, to check the Guard conditions.

Parameters:
activityId - An ID that uniquely identifies an activity to invoke.
Returns:
true or false

performActivity

public void performActivity(int activityId)
Do the activity identified by the activityId. This is code called on certain Turtle functions that include a set of commands. ex: ask turtles [set color yellow] This method can also be used in other situations as a general call-back mechanism.

Parameters:
activityId - An ID that uniquely identifies an activity to invoke.

performVoidActivity

public void performVoidActivity(IXholon activity)
Perform an activity including the entire activity subtree. This is intended to be used in Behavior encoded as an Activity subtree, and in GP and other evolutionary computation such as ECJ integration with Xholon. This will typically be a side effect, instead of computing and returning a value.

Parameters:
activity - IXholon representation of the activity.

performDoubleActivity

public double performDoubleActivity(IXholon activity)
Perform an activity including the entire activity subtree. This is intended to be used in Behavior encoded as an Activity subtree, and in GP and other evolutionary computation such as ECJ integration with Xholon.

Parameters:
activity - IXholon representation of the activity.
Returns:
The result (a double) of performing this activity.

performBooleanActivity

public boolean performBooleanActivity(IXholon activity)
Perform an activity including the entire activity subtree. This is intended to be used in Behavior encoded as an Activity subtree, and in GP and other evolutionary computation such as ECJ integration with Xholon.

Parameters:
activity - IXholon representation of the activity.
Returns:
The result (a boolean) of performing this activity.