API Docs for:
Show:

ixholon Class

Defined in: XholonJsApi.js:258
Module: XholonJsApi

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

()

Defined in XholonJsApi.js:258

Methods

action

(
  • action
)
IXholon chainable

Defined in XholonJsApi.js:804

Do a specific action that this xholon knows how to do.

Parameters:

  • action String

    The name of a specific action.

Returns:

IXholon:

this

Example:

node.action("Do your thing");

actions

() String

Defined in XholonJsApi.js:792

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:

String:

A list of actions, or null.

Example:

console.log(node.actions());

after

(
  • content
)
IXholon chainable

Defined in XholonJsApi.js:464

Insert a node after this node.

Parameters:

  • content IXholon | String

    An existing IXholon node, or an XML String that defines a new node or subtree.

Returns:

IXholon:

this

Example:

node.after(otherNode.remove());
node.after('<One/>');
node.after('<One><Two roleName="subtreeNode"/></One>');

anno

(
  • [annotation]
)
String chainable

Defined in XholonJsApi.js:615

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 optional

    Some text.

Returns:

String:

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
)
IXholon chainable

Defined in XholonJsApi.js:350

Append a node as the last child of this node.

Parameters:

  • content IXholon | String

    An existing IXholon node, or an XML String that defines a new node or subtree.

Returns:

IXholon:

this

Example:

node.append(otherNode.remove());
node.append('<One/>');
node.append('<One><Two roleName="subtreeNode"/></One>');

appendTo

(
  • target
)
IXholon chainable

Defined in XholonJsApi.js:374

Append this node as the last child of its new parent node.

Parameters:

  • target IXholon

    New parent of this node.

Returns:

IXholon:

this

Example:

node.remove().appendTo(target);

attr

(
  • attrName
  • [attrVal]
)
String | IXholon chainable

Defined in XholonJsApi.js:904

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 String

    An attribute name.

  • [attrVal] String optional

    An attribute value.

Returns:

String | IXholon:

An attribute value, or null, or this.

Example:

console.log(node.attr("myAttr"));
node.attr("myAttr", "myAttrVal");
console.log(node.attr("myAttr"));

attrs

(
  • returnAll
)
Object[]

Defined in XholonJsApi.js:947

Get all app-specific attributes.

Parameters:

  • returnAll Boolean

    Whether to return just the app-specific attributes (false), or also the attributes of base superclasses (true).

Returns:

Object[]:

Example:

console.log(node.attrs(false));

before

(
  • content
)
IXholon chainable

Defined in XholonJsApi.js:426

Insert a node before this node.

Parameters:

  • content IXholon | String

    An existing IXholon node, or an XML String that defines a new node or subtree.

Returns:

IXholon:

this

Example:

node.before(otherNode.remove());
node.before('<One/>');
node.before('<One><Two roleName="subtreeNode"/></One>');

call

(
  • signal
  • data
  • sender
  • [index]
)
Object

Defined in XholonJsApi.js:764

Send a Synchronous message to a receiving IXholon instance.

Parameters:

  • signal Number

    A distinguishing identifier for this message.

  • data Object

    Any data that needs to be sent, or null.

  • sender IXholon

    The sender of the message.

  • [index] Number optional

    The index of a replicated port.

Returns:

Object:

A response message, or null.

Example:

var responseMsg = receiverNode.call(102, "What is 2 + 3 ?", thisNode);
console.log(responseMsg.data);

dec

(
  • decAmount
)
IXholon chainable

Defined in XholonJsApi.js:679

Decrement an internal number by a specified amount. This is a convenience method.

Parameters:

  • decAmount Number

    Decrement amount.

Returns:

IXholon:

this

Example:

console.log(node.val());
node.val(1234.5678);
console.log(node.val());
node.dec(1111.1111);
console.log(node.val());

first

() IXholon

Defined in XholonJsApi.js:286

Get first (leftmost) child of this node.

Returns:

IXholon:

First child, or null.

Example:

var f = node.first();

hasClass

(
  • className
)
Boolean

Defined in XholonJsApi.js:976

Report whether or not this node has the specified Xholon class.

Parameters:

  • className String

    The name of a XholonClass (xhc).

Returns:

Boolean:

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

Defined in XholonJsApi.js:502

Get ID of this IXholon instance.

Returns:

Number:

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
)
IXholon chainable

Defined in XholonJsApi.js:661

Increment an internal number by a specified amount. This is a convenience method.

Parameters:

  • incAmount Number

    Increment amount.

Returns:

IXholon:

this

Example:

console.log(node.val());
node.val(1234.5678);
console.log(node.val());
node.inc(1111.1111);
console.log(node.val());

insertAfter

(
  • target
)
IXholon chainable

Defined in XholonJsApi.js:488

Insert this node after its new previous sibling node.

Parameters:

  • target IXholon

    New previous sibling of this node.

Returns:

IXholon:

this

Example:

node.insertAfter(target);

insertBefore

(
  • target
)
IXholon chainable

Defined in XholonJsApi.js:450

Insert this node before its new next sibling node.

Parameters:

  • target IXholon

    New next sibling of this node.

Returns:

IXholon:

this

Example:

node.insertBefore(target);

isAttr

(
  • attrName
)
Boolean

Defined in XholonJsApi.js:932

Is there an attribute with the specified name.

Parameters:

  • attrName String

    An attribute name.

Returns:

Boolean:

true or false

Example:

console.log(node.isAttr("myAttr"));

last

() IXholon

Defined in XholonJsApi.js:297

Get last (rightmost) child of this node.

Returns:

IXholon:

Last child, or null.

Example:

var f = node.last();

msg

(
  • signal
  • data
  • sender
  • [index]
)
IXholon chainable

Defined in XholonJsApi.js:741

Send a message to a receiving IXholon instance.

Parameters:

  • signal Number

    A distinguishing identifier for this message.

  • data Object

    Any data that needs to be sent, or null.

  • sender IXholon

    The sender of the message.

  • [index] Number optional

    The index of a replicated port.

Returns:

IXholon:

this

Example:

receiverNode.msg(101, "This is some data", thisNode);

name

(
  • [template="r:c_i^"]
)
String

Defined in XholonJsApi.js:514

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 optional

    A 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:

String:

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

Defined in XholonJsApi.js:308

Get next (right) sibling of this node.

Returns:

IXholon:

Next sibling, or null.

Example:

var n = node.next();

obj

(
  • [val]
)
Object chainable

Defined in XholonJsApi.js:721

Get or set the value of a Object maintained by this xholon instance.

Parameters:

  • [val] Object optional

    An object.

Returns:

Object:

An object. Or {IXholon} this

Example:

var obj = node.obj();

parent

() IXholon

Defined in XholonJsApi.js:275

Get parent of this node.

Returns:

IXholon:

This node's current parent, or null if this is a root node.

Example:

var p = node.parent();

port

(
  • portName
  • [portRef]
)
IXholon chainable

Defined in XholonJsApi.js:818

Get or set the node referenced by a port with a specified name or index (0-based).

Parameters:

  • portName String | Number

    The name of the port, or the index of the port within this Xholon's port array.

  • [portRef] IXholon optional

    The IXholon instance that can be accessed through this port.

Returns:

IXholon:

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

Defined in XholonJsApi.js:890

Get the names of all ports.

Returns:

String:

A comma-separated list of port names and indexes.

Example:

console.log(node.portNames());

ports

() PortInformation

Defined in XholonJsApi.js:868

Get all ports as an array.

Returns:

PortInformation:

An array of PortInformation objects, or an empty array.

Example:

console.log(node.ports()[0].obj().reffedNode.toString());

portSpec

() PortInformation

Defined in XholonJsApi.js:879

Get all ports as an array.

Returns:

PortInformation:

An array of PortInformation objects, or an empty array.

Example:

console.log(node.portSpec()[0].obj().reffedNode.toString());

prepend

(
  • content
)
IXholon chainable

Defined in XholonJsApi.js:388

Insert a node as the first child of this node.

Parameters:

  • content IXholon | String

    An existing IXholon node, or an XML String that defines a new node or subtree.

Returns:

IXholon:

this

Example:

node.prepend(otherNode.remove());
node.prepend('<One/>');
node.prepend('<One><Two roleName="subtreeNode"/></One>');

prependTo

(
  • target
)
IXholon chainable

Defined in XholonJsApi.js:412

Insert this node as the first child of its new parent node.

Parameters:

  • target IXholon

    New parent of this node.

Returns:

IXholon:

this

Example:

node.remove().prependTo(target);

prev

() IXholon

Defined in XholonJsApi.js:319

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

Returns:

IXholon:

Previous sibling, or null.

Example:

var p = node.prev();

print

(
  • obj
)
IXholon chainable

Defined in XholonJsApi.js:575

Write an object to the out tab.

Parameters:

  • obj Object

    The object to write. Currently, this must be a String.

Returns:

IXholon:

this

Example:

node.print("Hello ");

println

(
  • obj
)
IXholon chainable

Defined in XholonJsApi.js:589

Write an object to the out tab, terminated with an end-of-line.

Parameters:

  • obj Object

    The object to write. Currently, this must be a String.

Returns:

IXholon:

this

Example:

node.println("World");

remove

() IXholon chainable

Defined in XholonJsApi.js:330

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:

IXholon:

this

Example:

node.remove().appendTo(target);

role

(
  • [roleName]
)
String chainable

Defined in XholonJsApi.js:553

Get or set the name of the role played by this Xholon within a specific context.

Parameters:

  • [roleName] String optional

    An optional string that identifies the role.

Returns:

String:

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]
)
String chainable

Defined in XholonJsApi.js:697

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 optional

    Some text.

Returns:

String:

Some text, or null. Or {IXholon} this

Example:

console.log(node.text());
node.val("one,two.three");
console.log(node.text());

val

(
  • [val]
)
Number chainable

Defined in XholonJsApi.js:638

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 optional

    A number.

Returns:

Number:

A number. Or {IXholon} this

Example:

console.log(node.val());
node.val(1234.5678);
console.log(node.val());

xhc

() IXholonClass

Defined in XholonJsApi.js:603

Get the IXholonClass to which this Xholon instance is a member.

Returns:

IXholonClass:

The IXholonClass, which is a subclass of IXholon.

Example:

var xhc = node.xhc();
console.log(xhc.name());

xpath

(
  • expression
)
IXholon

Defined in XholonJsApi.js:963

Evaluate an XPath 1.0 expression.

Parameters:

  • expression String

    An XPath 1.0 String expression (ex: "ancestor::HelloWorldSystem/World");

Returns:

IXholon:

An IXholon node, or null.

Example:

var hello = $wnd.xh.root().first();
var world = hello.xpath("ancestor::HelloWorldSystem/World");