ixholon Class
These methods apply to individual IXholon nodes in the Xholon application. 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.
Constructor
ixholon
()
Item Index
Methods
action
-
action
Do a specific action that this xholon knows how to do.
Parameters:
-
action
StringThe name of a specific action.
Returns:
this
Example:
node.action("Do your thing");
actions
()
String
Get a list of actions that this xholon can do. These actions can be presented to users in a GUI, or used for other purposes.
Returns:
A list of actions, or null.
Example:
console.log(node.actions());
after
-
content
Insert a node after this node.
Parameters:
-
content
IXholon | StringAn existing IXholon node, or an XML String that defines a new node or subtree.
Returns:
this
Example:
node.after(otherNode.remove());
node.after('<One/>');
node.after('<One><Two roleName="subtreeNode"/></One>');
anno
-
[annotation]
Get or set the contents of the annotation for this Xholon. The annotation is intended to be read by a human user.
Parameters:
-
[annotation]
String optionalSome text.
Returns:
Some text, or null. Or {IXholon} this
Example:
console.log(node.anno());
node.anno("Here is my new description of the current node.");
console.log(node.anno());
append
-
content
Append a node as the last child of this node.
Parameters:
-
content
IXholon | StringAn existing IXholon node, or an XML String that defines a new node or subtree.
Returns:
this
Example:
node.append(otherNode.remove());
node.append('<One/>');
node.append('<One><Two roleName="subtreeNode"/></One>');
appendTo
-
target
Append this node as the last child of its new parent node.
Parameters:
-
target
IXholonNew parent of this node.
Returns:
this
Example:
node.remove().appendTo(target);
attr
-
attrName
-
[attrVal]
Get or set the value of an attribute. setter ex: root.attr("State", "9"); setter ex: root.attr("State", 17); getter ex: Number(root.attr("state")) + 11;
Parameters:
-
attrName
StringAn attribute name.
-
[attrVal]
String optionalAn attribute value.
Returns:
An attribute value, or null, or this.
Example:
console.log(node.attr("myAttr"));
node.attr("myAttr", "myAttrVal");
console.log(node.attr("myAttr"));
attrs
-
returnAll
Get all app-specific attributes.
Parameters:
-
returnAll
BooleanWhether to return just the app-specific attributes (false), or also the attributes of base superclasses (true).
Returns:
Example:
console.log(node.attrs(false));
before
-
content
Insert a node before this node.
Parameters:
-
content
IXholon | StringAn existing IXholon node, or an XML String that defines a new node or subtree.
Returns:
this
Example:
node.before(otherNode.remove());
node.before('<One/>');
node.before('<One><Two roleName="subtreeNode"/></One>');
call
-
signal
-
data
-
sender
-
[index]
Send a Synchronous message to a receiving IXholon instance.
Parameters:
-
signal
NumberA distinguishing identifier for this message.
-
data
ObjectAny data that needs to be sent, or null.
-
sender
IXholonThe sender of the message.
-
[index]
Number optionalThe index of a replicated port.
Returns:
A response message, or null.
Example:
var responseMsg = receiverNode.call(102, "What is 2 + 3 ?", thisNode);
console.log(responseMsg.data);
dec
-
decAmount
Decrement an internal number by a specified amount. This is a convenience method.
Parameters:
-
decAmount
NumberDecrement amount.
Returns:
this
Example:
console.log(node.val());
node.val(1234.5678);
console.log(node.val());
node.dec(1111.1111);
console.log(node.val());
first
()
IXholon
Get first (leftmost) child of this node.
Returns:
First child, or null.
Example:
var f = node.first();
hasClass
-
className
Report whether or not this node has the specified Xholon class.
Parameters:
-
className
StringThe name of a XholonClass (xhc).
Returns:
true if the node's XholonClass (xhc) matches the className, or if any ancestor (superclass) of the xhc matches.
Example:
var x = $wnd.xh.root().first().hasClass("Hello");
id
()
Number
Get ID of this IXholon instance.
Returns:
An integer ID, unique within this application, that is assigned when the IXholon is created.
Example:
var id = node.id();
console.log("The id for node " + node.toString() + " is " + id);
inc
-
incAmount
Increment an internal number by a specified amount. This is a convenience method.
Parameters:
-
incAmount
NumberIncrement amount.
Returns:
this
Example:
console.log(node.val());
node.val(1234.5678);
console.log(node.val());
node.inc(1111.1111);
console.log(node.val());
insertAfter
-
target
Insert this node after its new previous sibling node.
Parameters:
-
target
IXholonNew previous sibling of this node.
Returns:
this
Example:
node.insertAfter(target);
insertBefore
-
target
Insert this node before its new next sibling node.
Parameters:
-
target
IXholonNew next sibling of this node.
Returns:
this
Example:
node.insertBefore(target);
isAttr
-
attrName
Is there an attribute with the specified name.
Parameters:
-
attrName
StringAn attribute name.
Returns:
true or false
Example:
console.log(node.isAttr("myAttr"));
last
()
IXholon
Get last (rightmost) child of this node.
Returns:
Last child, or null.
Example:
var f = node.last();
msg
-
signal
-
data
-
sender
-
[index]
Send a message to a receiving IXholon instance.
Parameters:
-
signal
NumberA distinguishing identifier for this message.
-
data
ObjectAny data that needs to be sent, or null.
-
sender
IXholonThe sender of the message.
-
[index]
Number optionalThe index of a replicated port.
Returns:
this
Example:
receiverNode.msg(101, "This is some data", thisNode);
name
-
[template="r:c_i^"]
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"). If the Xholon instance has a roleName, it is included in front of the other two elements, and separated from the IXholonClass name by a ":" (ex: "helloRole:helloWorld_123").
Parameters:
-
[template="r:c_i^"]
String optionalA fixed length template that specifies what elements are included as part of the name. ex: "r:ci^" is roleName + ":" + className with first letter lowercase + "" + id The template fields are in fixed positions, and may have the following values: (1) r include roleName, ^ don't include role name (2) : ^ (3) c className lowercase, C classname lowercase, l local part, L local part (4) _ ^ (5) i include id (6) ^ If an invalid template is input, then the returned name will be in the default format, as defined by the GETNAME_DEFAULT constant. The default format is exactly the same as what would be returned by calling getName() without specifying a template.
Returns:
The default or formatted name of this IXholon instance.
Example:
var name = node.name();
console.log(name);
name = node.name("R^^^^^");
console.log(name);
next
()
IXholon
Get next (right) sibling of this node.
Returns:
Next sibling, or null.
Example:
var n = node.next();
obj
-
[val]
Get or set the value of a Object maintained by this xholon instance.
Parameters:
-
[val]
Object optionalAn object.
Returns:
An object. Or {IXholon} this
Example:
var obj = node.obj();
parent
()
IXholon
Get parent of this node.
Returns:
This node's current parent, or null if this is a root node.
Example:
var p = node.parent();
port
-
portName
-
[portRef]
Get or set the node referenced by a port with a specified name or index (0-based).
Parameters:
-
portName
String | NumberThe name of the port, or the index of the port within this Xholon's port array.
-
[portRef]
IXholon optionalThe IXholon instance that can be accessed through this port.
Returns:
A reference to an IXholon instance that can be accessed through this port, or null, or this.
Example:
console.log(node.port("world"));
console.log(node.port(1));
node
.port(0, nodeA)
.port(1, nodeB)
.port("world", nodeC);
portNames
()
String
Get the names of all ports.
Returns:
A comma-separated list of port names and indexes.
Example:
console.log(node.portNames());
ports
()
PortInformation
Get all ports as an array.
Returns:
An array of PortInformation objects, or an empty array.
Example:
console.log(node.ports()[0].obj().reffedNode.toString());
portSpec
()
PortInformation
Get all ports as an array.
Returns:
An array of PortInformation objects, or an empty array.
Example:
console.log(node.portSpec()[0].obj().reffedNode.toString());
prepend
-
content
Insert a node as the first child of this node.
Parameters:
-
content
IXholon | StringAn existing IXholon node, or an XML String that defines a new node or subtree.
Returns:
this
Example:
node.prepend(otherNode.remove());
node.prepend('<One/>');
node.prepend('<One><Two roleName="subtreeNode"/></One>');
prependTo
-
target
Insert this node as the first child of its new parent node.
Parameters:
-
target
IXholonNew parent of this node.
Returns:
this
Example:
node.remove().prependTo(target);
prev
()
IXholon
Get previous (left) sibling of this node. (may be expensive in processing time)
Returns:
Previous sibling, or null.
Example:
var p = node.prev();
print
-
obj
Write an object to the out tab.
Parameters:
-
obj
ObjectThe object to write. Currently, this must be a String.
Returns:
this
Example:
node.print("Hello ");
println
-
obj
Write an object to the out tab, terminated with an end-of-line.
Parameters:
-
obj
ObjectThe object to write. Currently, this must be a String.
Returns:
this
Example:
node.println("World");
remove
()
IXholon
chainable
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.
Returns:
this
Example:
node.remove().appendTo(target);
role
-
[roleName]
Get or set the name of the role played by this Xholon within a specific context.
Parameters:
-
[roleName]
String optionalAn optional string that identifies the role.
Returns:
A name that identifies the role, or null. Or {IXholon} this
Example:
console.log(node.role());
node.role("myNewRole");
console.log(node.role());
text
-
[val]
Get or set the value of a String maintained by this xholon instance. The text is intended to be read and processed by the application, for its own internal purposes.
Parameters:
-
[val]
String optionalSome text.
Returns:
Some text, or null. Or {IXholon} this
Example:
console.log(node.text());
node.val("one,two.three");
console.log(node.text());
val
-
[val]
Get or set a numeric value maintained by this xholon instance. If a class that implements this interface does not maintain a numeric value, it should return 0.0
Parameters:
-
[val]
Number optionalA number.
Returns:
A number. Or {IXholon} this
Example:
console.log(node.val());
node.val(1234.5678);
console.log(node.val());
xhc
()
IXholonClass
Get the IXholonClass to which this Xholon instance is a member.
Returns:
The IXholonClass, which is a subclass of IXholon.
Example:
var xhc = node.xhc();
console.log(xhc.name());
xpath
-
expression
Evaluate an XPath 1.0 expression.
Parameters:
-
expression
StringAn XPath 1.0 String expression (ex: "ancestor::HelloWorldSystem/World");
Returns:
An IXholon node, or null.
Example:
var hello = $wnd.xh.root().first();
var world = hello.xpath("ancestor::HelloWorldSystem/World");