org.primordion.xholon.base
Class Xholon

java.lang.Object
  extended byorg.primordion.xholon.base.Xholon
All Implemented Interfaces:
IXholon
Direct Known Subclasses:
Activity, Application, Attribute, ContainmentHierarchy, Control, InheritanceHierarchy, Interaction, Message, Port, PortXhym, Queue, StateMachineEntity, StateMachineXhym, TreeNodeFactoryDynamic, TreeNodeFactoryStatic, XholonClass, XholonWithPorts, XholonXhym, XhymAgent

public abstract class Xholon
extends java.lang.Object
implements IXholon

Xholon is an abstract class that implements a lot of the functionality defined in the IXholon interface.

Since:
0.1 (Created on Jun 8, 2005)
Author:
Ken Webb
See Also:
IXholon

Field Summary
static int DEFAULT_LEVEL
           
static IInteraction interaction
           
static boolean 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
Xholon()
          Constructor.
 
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.
static int getNextId()
          Get the next available id for assignment to an instance of Xholon.
 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 doFullSubtree)
          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.
static int getSizeMessageQ()
          Get the current maximum size of the message queue.
 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 newLeftSibling)
          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.
static void resetNextId()
          Set the next available id back to 0.
 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.
static void setFactory(ITreeNodeFactory fact)
          Specify the factory.
 void setFirstChild(IXholon treeNode)
          Set first (leftmost) child of this node.
 void setId(int entityId)
          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.
static void setSizeMessageQ(int sizeMessageQueue)
          Set the size of the message queue, and allocate a queue of that size.
 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.
 java.lang.String toString()
           
 int treeSize()
          Get number of nodes in tree.
 void writeXml(int level, java.io.Writer fw)
          Write self to a file as XML.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_LEVEL

public static final int DEFAULT_LEVEL
See Also:
Constant Field Values

interactionsEnabled

public static boolean interactionsEnabled

interaction

public static IInteraction interaction
Constructor Detail

Xholon

public Xholon()
Constructor.

Method Detail

remove

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

Specified by:
remove in interface IXholon

setFactory

public static void setFactory(ITreeNodeFactory fact)
Specify the factory.

Parameters:
fact - The factory.

getParentNode

public IXholon getParentNode()
Description copied from interface: IXholon
Get parent of this node.

Specified by:
getParentNode in interface IXholon
Returns:
This node's current parent.

getFirstChild

public IXholon getFirstChild()
Description copied from interface: IXholon
Get first (leftmost) child of this node.

Specified by:
getFirstChild in interface IXholon
Returns:
First child, or null.

getNextSibling

public IXholon getNextSibling()
Description copied from interface: IXholon
Get next (right) sibling of this node.

Specified by:
getNextSibling in interface IXholon
Returns:
Next sibling, or null.

getPreviousSibling

public IXholon getPreviousSibling()
Description copied from interface: IXholon
Get previous (left) sibling of this node. (may be expensive in processing time)

Specified by:
getPreviousSibling in interface IXholon
Returns:
Previous Sibling, or null.

setParentNode

public void setParentNode(IXholon treeNode)
Description copied from interface: IXholon
Set parent of this node.

Specified by:
setParentNode in interface IXholon
Parameters:
treeNode - This node's new parent.

setFirstChild

public void setFirstChild(IXholon treeNode)
Description copied from interface: IXholon
Set first (leftmost) child of this node.

Specified by:
setFirstChild in interface IXholon
Parameters:
treeNode - This node's new first child.

setNextSibling

public void setNextSibling(IXholon treeNode)
Description copied from interface: IXholon
Set next (right) sibling of this node.

Specified by:
setNextSibling in interface IXholon
Parameters:
treeNode - This node's new next sibling.

getRootNode

public IXholon getRootNode()
Description copied from interface: IXholon
Get root of the tree that this node is a part of.

Specified by:
getRootNode in interface IXholon
Returns:
Root. If this node is the root, it returns itself.

setParentChildLinks

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

Specified by:
setParentChildLinks in interface IXholon
Parameters:
parent - This node's new parent.

setParentSiblingLinks

public void setParentSiblingLinks(IXholon previousSibling)
Description copied from interface: IXholon
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 );

Specified by:
setParentSiblingLinks in interface IXholon
Parameters:
previousSibling - This node's new previous sibling.

removeChild

public void removeChild()
Description copied from interface: IXholon
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.

Specified by:
removeChild in interface IXholon

insertAfter

public void insertAfter(IXholon newLeftSibling)
Description copied from interface: IXholon
Insert this node after its new previous sibling node.

Specified by:
insertAfter in interface IXholon
Parameters:
newLeftSibling - New previous sibling of this node.

insertBefore

public void insertBefore(IXholon newNextSibling)
Description copied from interface: IXholon
Insert this node before its new next sibling node.

Specified by:
insertBefore in interface IXholon
Parameters:
newNextSibling - New next sibling of this node.

insertFirstChild

public void insertFirstChild(IXholon newParentNode)
Description copied from interface: IXholon
Insert this node as the first child of its new parent node.

Specified by:
insertFirstChild in interface IXholon
Parameters:
newParentNode - New parent of this node.

appendChild

public void appendChild(IXholon newParentNode)
Description copied from interface: IXholon
Append this node as the last child of its new parent node.

Specified by:
appendChild in interface IXholon
Parameters:
newParentNode - New parent of this node.

swapNode

public void swapNode(IXholon otherNode)
Description copied from interface: IXholon
Swap this node with otherNode.

Specified by:
swapNode in interface IXholon
Parameters:
otherNode - The node to swap position with.

depth

public int depth()
Description copied from interface: IXholon
Get the number of ancestors of this node, excluding this node itself. The depth of the root node in the tree is 0.

Specified by:
depth in interface IXholon

height

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

Specified by:
height in interface IXholon
Returns:
Height of the tree starting from this node.

treeSize

public int treeSize()
Description copied from interface: IXholon
Get number of nodes in tree.

Specified by:
treeSize in interface IXholon
Returns:
Total number of nodes in the tree, starting from and including this node.

isRootNode

public boolean isRootNode()
Description copied from interface: IXholon
Is this the root node of the tree (does it have a parent).

Specified by:
isRootNode in interface IXholon
Returns:
true or false

isExternal

public boolean isExternal()
Description copied from interface: IXholon
Is this an external node (no child or siblings).

Specified by:
isExternal in interface IXholon
Returns:
true or false

isInternal

public boolean isInternal()
Description copied from interface: IXholon
Is this an internal node (has child and/or siblings).

Specified by:
isInternal in interface IXholon
Returns:
true or false

isLeaf

public boolean isLeaf()
Description copied from interface: IXholon
Is this a leaf node (has no child, but may have siblings).

Specified by:
isLeaf in interface IXholon
Returns:
true or false

getChildNodes

public java.util.Vector getChildNodes(boolean deep)
Description copied from interface: IXholon
Get all children of this node.

Specified by:
getChildNodes in interface IXholon
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)
Description copied from interface: IXholon
Get the nth child of this node, where 0 <= n < number of children.

Specified by:
getNthChild in interface IXholon
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()
Description copied from interface: IXholon
Does this node have a parent.

Specified by:
hasParentNode in interface IXholon
Returns:
true or false

hasChildNodes

public boolean hasChildNodes()
Description copied from interface: IXholon
Does this node have a first (left) child.

Specified by:
hasChildNodes in interface IXholon
Returns:
true or false

hasNextSibling

public boolean hasNextSibling()
Description copied from interface: IXholon
Does this node have a next (right) sibling.

Specified by:
hasNextSibling in interface IXholon
Returns:
true or false

hasChildOrSiblingNodes

public boolean hasChildOrSiblingNodes()
Description copied from interface: IXholon
Does this node have either a first child or a next sibling or both.

Specified by:
hasChildOrSiblingNodes in interface IXholon
Returns:
true or false

getNumChildren

public int getNumChildren(boolean doFullSubtree)
Description copied from interface: IXholon
Get number of children that this node has.

Specified by:
getNumChildren in interface IXholon
Parameters:
doFullSubtree - If true then return entire nested subtree, if false return only immediate children.
Returns:
Number of children.

getLastChild

public IXholon getLastChild()
Description copied from interface: IXholon
Get last (rightmost) child.

Specified by:
getLastChild in interface IXholon
Returns:
Last child, or null.

getLastSibling

public IXholon getLastSibling()
Description copied from interface: IXholon
Get last (rightmost) sibling.

Specified by:
getLastSibling in interface IXholon
Returns:
Last sibling, or null.

getFirstSibling

public IXholon getFirstSibling()
Description copied from interface: IXholon
Get first (leftmost) sibling.

Specified by:
getFirstSibling in interface IXholon
Returns:
First sibling, or null.

getSiblings

public java.util.Vector getSiblings()
Description copied from interface: IXholon
Get siblings.

Specified by:
getSiblings in interface IXholon
Returns:
Vector containing all siblings.

getNthSibling

public IXholon getNthSibling(int n)
Description copied from interface: IXholon
Get nth sibling.

Specified by:
getNthSibling in interface IXholon
Parameters:
n - The index of the sibling being requested.
Returns:
The nth sibling, or null.

getNumSiblings

public int getNumSiblings()
Description copied from interface: IXholon
Get number of siblings.

Specified by:
getNumSiblings in interface IXholon
Returns:
The number of siblings.

getNeighbors

public java.util.Vector getNeighbors(int distance,
                                     int include,
                                     java.lang.String excludeBecName)
Description copied from interface: IXholon
Get neighbors.

Specified by:
getNeighbors in interface IXholon
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).

draw

public void draw()
Description copied from interface: IXholon
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."

Specified by:
draw in interface IXholon

initStatics

public void initStatics()
Description copied from interface: IXholon
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.

Specified by:
initStatics in interface IXholon

preConfigure

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

Specified by:
preConfigure in interface IXholon

configure

public int configure(java.lang.String instructions,
                     int instructIx)
Description copied from interface: IXholon
Configure something based on a configure instruction.

Specified by:
configure in interface IXholon
Parameters:
instructions - A String that contains a configure instruction.
instructIx - An index into the instructions String.
Returns:
An updated index into the instructions String.

print

public void print(java.lang.Object obj)
Description copied from interface: IXholon
Write an object to standard out.

Specified by:
print in interface IXholon
Parameters:
obj - The object to write.

println

public void println(java.lang.Object obj)
Description copied from interface: IXholon
Write an object to standard out, terminated with an end-of-line.

Specified by:
println in interface IXholon
Parameters:
obj - The object to write.

initialize

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

Specified by:
initialize in interface IXholon

getNextId

public static int getNextId()
Get the next available id for assignment to an instance of Xholon.

Returns:
A unique ID.

resetNextId

public static void resetNextId()
Set the next available id back to 0. This should only be called when loading a new model in, to replace an existing one.


setSizeMessageQ

public static void setSizeMessageQ(int sizeMessageQueue)
Set the size of the message queue, and allocate a queue of that size. This should only be called when the application starts up, to initially set the size. If the message queue is not empty, then any items in the queue will be lost.

Parameters:
sizeMessageQueue - The size of the queue.

getSizeMessageQ

public static int getSizeMessageQ()
Get the current maximum size of the message queue.

Returns:
The maximum size.

getId

public int getId()
Description copied from interface: IXholon
Get ID of this TreeNode instance.

Specified by:
getId in interface IXholon
Returns:
An integer ID, unique within this application, that is assigned when the TreeNode is created.

getName

public java.lang.String getName()
Description copied from interface: IXholon
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"

Specified by:
getName in interface IXholon
Returns:
The unique name of this Xholon instance.

setId

public void setId(int entityId)
Description copied from interface: IXholon
Set the ID of this TreeNode instance.

Specified by:
setId in interface IXholon
Parameters:
entityId - The ID of this TreeNode.

getVal

public double getVal()
Description copied from interface: IXholon
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()

Specified by:
getVal in interface IXholon
Returns:
A double value.

setVal

public void setVal(double val)
Description copied from interface: IXholon
Set the value of a "double" maintained by this xholon instance.

Specified by:
setVal in interface IXholon
Parameters:
val - The new value.

incVal

public void incVal(double incAmount)
Description copied from interface: IXholon
Increment an internal double value by a specified amount. This is a convenience method.

Specified by:
incVal in interface IXholon
Parameters:
incAmount - Increment amount.

incVal

public void incVal(int incAmount)
Description copied from interface: IXholon
Increment an internal int value by a specified amount. This is a convenience method.

Specified by:
incVal in interface IXholon
Parameters:
incAmount - Increment amount.

decVal

public void decVal(double decAmount)
Description copied from interface: IXholon
Decrement an internal double value by a specified amount. This is a convenience method.

Specified by:
decVal in interface IXholon
Parameters:
decAmount - Decrement amount.

decVal

public void decVal(int decAmount)
Description copied from interface: IXholon
Decrement an internal int value by a specified amount. This is a convenience method.

Specified by:
decVal in interface IXholon
Parameters:
decAmount - Decrement amount.

getVal_boolean

public boolean getVal_boolean()
Description copied from interface: IXholon
Get the value of a "boolean" maintained by this xholon instance.

Specified by:
getVal_boolean in interface IXholon

getVal_byte

public byte getVal_byte()
Description copied from interface: IXholon
Get the value of a "byte" maintained by this xholon instance.

Specified by:
getVal_byte in interface IXholon

getVal_char

public char getVal_char()
Description copied from interface: IXholon
Get the value of a "char" maintained by this xholon instance.

Specified by:
getVal_char in interface IXholon

getVal_double

public double getVal_double()
Description copied from interface: IXholon
Get the value of a "double" maintained by this xholon instance.

Specified by:
getVal_double in interface IXholon

getVal_float

public float getVal_float()
Description copied from interface: IXholon
Get the value of a "float" maintained by this xholon instance.

Specified by:
getVal_float in interface IXholon

getVal_int

public int getVal_int()
Description copied from interface: IXholon
Get the value of a "int" maintained by this xholon instance.

Specified by:
getVal_int in interface IXholon

getVal_long

public long getVal_long()
Description copied from interface: IXholon
Get the value of a "long" maintained by this xholon instance.

Specified by:
getVal_long in interface IXholon

getVal_Object

public java.lang.Object getVal_Object()
Description copied from interface: IXholon
Get the value of a "Object" maintained by this xholon instance.

Specified by:
getVal_Object in interface IXholon

getVal_short

public short getVal_short()
Description copied from interface: IXholon
Get the value of a "short" maintained by this xholon instance.

Specified by:
getVal_short in interface IXholon

getVal_String

public java.lang.String getVal_String()
Description copied from interface: IXholon
Get the value of a "String" maintained by this xholon instance.

Specified by:
getVal_String in interface IXholon

setVal

public void setVal(boolean val)
Description copied from interface: IXholon
Set the value of a "boolean" maintained by this xholon instance.

Specified by:
setVal in interface IXholon

setVal

public void setVal(byte val)
Description copied from interface: IXholon
Set the value of a "byte" maintained by this xholon instance.

Specified by:
setVal in interface IXholon

setVal

public void setVal(char val)
Description copied from interface: IXholon
Set the value of a "char" maintained by this xholon instance.

Specified by:
setVal in interface IXholon

setVal

public void setVal(float val)
Description copied from interface: IXholon
Set the value of a "float" maintained by this xholon instance.

Specified by:
setVal in interface IXholon

setVal

public void setVal(int val)
Description copied from interface: IXholon
Set the value of a "int" maintained by this xholon instance.

Specified by:
setVal in interface IXholon

setVal

public void setVal(long val)
Description copied from interface: IXholon
Set the value of a "long" maintained by this xholon instance.

Specified by:
setVal in interface IXholon

setVal

public void setVal(java.lang.Object val)
Description copied from interface: IXholon
Set the value of a "Object" maintained by this xholon instance.

Specified by:
setVal in interface IXholon

setVal

public void setVal(short val)
Description copied from interface: IXholon
Set the value of a "short" maintained by this xholon instance.

Specified by:
setVal in interface IXholon

setVal

public void setVal(java.lang.String val)
Description copied from interface: IXholon
Set the value of a "String" maintained by this xholon instance.

Specified by:
setVal in interface IXholon

setAttributeVal

public int setAttributeVal(java.lang.String attrName,
                           java.lang.String attrVal)
Description copied from interface: IXholon
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.

Specified by:
setAttributeVal in interface IXholon
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.

getXhc

public IXholonClass getXhc()
Description copied from interface: IXholon
Get the IXholonClass to which this Xholon instance is a member.

Specified by:
getXhc in interface IXholon
Returns:
The IXholonClass.

getXhcId

public int getXhcId()
Description copied from interface: IXholon
Get the ID of the IXholonClass to which this Xholon instance is a member.

Specified by:
getXhcId in interface IXholon
Returns:
The ID of the IXholonClass.

getXhcName

public java.lang.String getXhcName()
Description copied from interface: IXholon
Get the name of the IXholonClass to which this Xholon instance is a member.

Specified by:
getXhcName in interface IXholon
Returns:
The name of the IXholonClass.

setXhc

public void setXhc(IXholonClass xhcNode)
Description copied from interface: IXholon
Set the IXholonClass to which this Xholon instance belongs.

Specified by:
setXhc in interface IXholon
Parameters:
xhcNode - The IXholonClass.

getXhType

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

Specified by:
getXhType in interface IXholon
Returns:
The Xholon type.

isContainer

public boolean isContainer()
Description copied from interface: IXholon
Is this xholon or xholon class a Container?

Specified by:
isContainer in interface IXholon
Returns:
true or false

isActiveObject

public boolean isActiveObject()
Description copied from interface: IXholon
Is this xholon or xholon class an Active Object?

Specified by:
isActiveObject in interface IXholon
Returns:
true or false

isPassiveObject

public boolean isPassiveObject()
Description copied from interface: IXholon
Is this xholon or xholon class a Passive Object?

Specified by:
isPassiveObject in interface IXholon
Returns:
true or false

hasAncestor

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

Specified by:
hasAncestor in interface IXholon
Parameters:
tnName - the searched-for ancestor
Returns:
true or false

createStructure

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

Specified by:
createStructure in interface IXholon
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()
Description copied from interface: IXholon
Set ports, by creating an array of ports. A port is a reference to a Xholon somewhere else in the tree.

Specified by:
setPorts in interface IXholon

configure

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

Specified by:
configure in interface IXholon

postConfigure

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

Specified by:
postConfigure in interface IXholon

preReconfigure

public void preReconfigure()
Description copied from interface: IXholon
Pre-Reconfigure, such as at the start of a new GP generation.

Specified by:
preReconfigure in interface IXholon

reconfigure

public void reconfigure()
Description copied from interface: IXholon
Reconfigure, such as at the start of a new GP generation.

Specified by:
reconfigure in interface IXholon

postReconfigure

public void postReconfigure()
Description copied from interface: IXholon
Post-reconfigure.

Specified by:
postReconfigure in interface IXholon

setVariableValue

public int setVariableValue(java.lang.String instructions,
                            int instructIx)
Description copied from interface: IXholon
Set the value of a variable using reflection.

Specified by:
setVariableValue in interface IXholon
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.

preAct

public void preAct()
Description copied from interface: IXholon
Do any setup required before doing the main action during a time step.

Specified by:
preAct in interface IXholon

act

public void act()
Description copied from interface: IXholon
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).

Specified by:
act in interface IXholon

postAct

public void postAct()
Description copied from interface: IXholon
Do any required work after doing the main action during a time step.

Specified by:
postAct in interface IXholon

cleanup

public void cleanup()
Description copied from interface: IXholon
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.

Specified by:
cleanup in interface IXholon

preOrderPrint

public void preOrderPrint(int level)
Description copied from interface: IXholon
Pre-order print. Print current node; then traverse children and siblings.

Specified by:
preOrderPrint in interface IXholon
Parameters:
level - Level in the tree, where the root node is level 0.

inOrderPrint

public void inOrderPrint(int level)
Description copied from interface: IXholon
In-order print. Traverse children; then print current node; then traverse siblings.

Specified by:
inOrderPrint in interface IXholon
Parameters:
level - Level in the tree, where the root node is level 0.

postOrderPrint

public void postOrderPrint(int level)
Description copied from interface: IXholon
Post-order print. Traverse children and siblings; then print current node.

Specified by:
postOrderPrint in interface IXholon
Parameters:
level - Level in the tree, where the root node is level 0.

writeXml

public void writeXml(int level,
                     java.io.Writer fw)
Description copied from interface: IXholon
Write self to a file as XML.

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

handleNodeSelection

public java.lang.String handleNodeSelection()
Description copied from interface: IXholon
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.

Specified by:
handleNodeSelection in interface IXholon
Returns:
A String with information about that node, that could for example be displayed.

sendMessage

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

Specified by:
sendMessage in interface IXholon
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)
Description copied from interface: IXholon
Send a ROOM/UML2 message to a receiving Xholon instance.

Specified by:
sendMessage in interface IXholon
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)
Description copied from interface: IXholon
Send a ROOM/UML2 message to a receiving Xholon instance.

Specified by:
sendMessage in interface IXholon
Parameters:
msg - An already existing message.

processReceivedMessage

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

Specified by:
processReceivedMessage in interface IXholon
Parameters:
msg - The message that was received.

processMessageQ

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

Specified by:
processMessageQ in interface IXholon

terminate

public void terminate()
Description copied from interface: IXholon
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.

Specified by:
terminate in interface IXholon

performActivity

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

Specified by:
performActivity in interface IXholon
Parameters:
activityId - An ID that uniquely identifies an activity to invoke.
msg - The message that triggered this Transition.

performBooleanActivity

public boolean performBooleanActivity(int activityId)
Description copied from interface: IXholon
Do the UML2 Activity identified by the activityId. This is code called during an Activity.

Specified by:
performBooleanActivity in interface IXholon
Parameters:
activityId - An ID that uniquely identifies an activity to invoke.
Returns:
true or false

performGuard

public boolean performGuard(int activityId,
                            IMessage msg)
Description copied from interface: IXholon
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.

Specified by:
performGuard in interface IXholon
Parameters:
activityId - An ID that uniquely identifies an activity to invoke.
Returns:
true or false

performActivity

public void performActivity(int activityId)
Description copied from interface: IXholon
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.

Specified by:
performActivity in interface IXholon
Parameters:
activityId - An ID that uniquely identifies an activity to invoke.

performVoidActivity

public void performVoidActivity(IXholon activity)
Description copied from interface: IXholon
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.

Specified by:
performVoidActivity in interface IXholon
Parameters:
activity - IXholon representation of the activity.

performDoubleActivity

public double performDoubleActivity(IXholon activity)
Description copied from interface: IXholon
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.

Specified by:
performDoubleActivity in interface IXholon
Parameters:
activity - IXholon representation of the activity.
Returns:
The result (a double) of performing this activity.

performBooleanActivity

public boolean performBooleanActivity(IXholon activity)
Description copied from interface: IXholon
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.

Specified by:
performBooleanActivity in interface IXholon
Parameters:
activity - IXholon representation of the activity.
Returns:
The result (a boolean) of performing this activity.

getPort

public IXholon getPort(int portNum)
Description copied from interface: IXholon
Get the port that corresponds to this index (0 indexed).

Specified by:
getPort in interface IXholon
Parameters:
portNum - The index of the port within this Xholon's port array.
Returns:
The port.

isBound

public boolean isBound(IXholon port)
Description copied from interface: IXholon
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.

Specified by:
isBound in interface IXholon
Returns:
true or false

setRoleName

public void setRoleName(java.lang.String roleName)
Description copied from interface: IXholon
Set name of the role played by this Xholon within a specific context.

Specified by:
setRoleName in interface IXholon
Parameters:
roleName - An optional name that identifies the role.

getRoleName

public java.lang.String getRoleName()
Description copied from interface: IXholon
Get name of the role played by this Xholon within a specific context.

Specified by:
getRoleName in interface IXholon
Returns:
A name that identifies the role, or null.

setUid

public void setUid(java.lang.String uid)
Description copied from interface: IXholon
Set globally unique ID.

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

getUid

public java.lang.String getUid()
Description copied from interface: IXholon
Get globally unique ID.

Specified by:
getUid in interface IXholon
Returns:
A globally unique ID, typically assigned by some external tool such as a UML modeling tool.

appendChild

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

Specified by:
appendChild in interface IXholon
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)
Description copied from interface: IXholon
Create a new child, and append it as the last child of this node. Make it an instance of a designated Java class.

Specified by:
appendChild in interface IXholon
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.

toString

public java.lang.String toString()