Namespace $k

The K-Infinity namespace

Namespace Summary
Constructor Attributes Constructor Name and Description
 
$k

Method Summary

Namespace Detail

$k

Field Detail

<static> $k.LOG_DEBUG
Log level [DEBUG]
<static> $k.LOG_ERROR
Log level [ERROR]
<static> $k.LOG_NORMAL
Normal log level
<static> $k.LOG_WARNING
Log level [WARNING]
<static> $k.out
Returns the document that represents the output stream of some script environments. The kind of object depends on the environment, but is usually an instance of $k.TextDocument.
$k.out.print("Name: ", this.name());
See:
$k.TextDocument

Method Detail

  • <static> $k.define(id, dependencies, factory)
    Defines a module
    Parameters:
    {string} id Optional
    Optional module ID
    {string[]} dependencies
    IDs of required modules
    factory
    Factory that returns the value of the module
  • <static> $k.log(object, level, channel)
    Log an object on the current log stream (if available)
    $k.log("New instance created");
    $k.log("The cake is a lie", $k.LOG_WARNING, "Portal");
    Parameters:
    object
    Object to log. Will be converted with toString().
    level Optional
    Log level. Either a number or a string ("debug", "normal", "warning", "error").
    {string} channel
    Optional log channel.
  • <static> $k.mapInstances(internalName, proto)
    Map the prototype of instances of the type with the internal name to the prototype object
    function Person() { }
    Person.prototype.fullName = function() {
    	return this.attributeValue("familyName").toUpperCase() 
    		+ ", " + this.attributeValue("firstName");
    };
    $k.mapInstances("person", Person);
    var persons =  $k.Registry.type("person").instances();
    for (var p in persons)
    	$k.out.print(persons[p].fullName() + "\n");
    Parameters:
    {string} internalName
    Internal name of the type of instances to map
    proto
    Prototype object
  • <static> $k.mapModule(moduleName, registryID)
    Maps a module ID to the ID of a registered script. Allows to register scripts containing modules under a different ID
    Parameters:
    {string} moduleName
    The ID of the module
    {string} registryID
    The ID of the registered script
  • <static> $k.mapTypes(internalName, proto)
    Map the prototype of types with the internal name to the prototype object
    Parameters:
    {string} internalName
    Internal name of the type to map
    proto
    Prototype object
  • <static> $k.module(moduleName)
    Loads a module
    Parameters:
    {string} moduleName
    The ID of the module
    Throws:
    {$k.exception.ModuleError}
    If the module was not found or defined more than once
    Returns:
    The model value
  • <static> $k.optimisticTransaction(f)
    Evaluates the function in a transaction and returns its return value. Does not check if the transaction has been accepted or rejected. Allows to start a transaction within another transaction, the nested transaction will be a part of the outer transaction
    Parameters:
    {Function} f
    Function that should be evaluated in a transaction
    Throws:
    {$k.exception.TransactionError}
    If a read-only transaction is already active
    Returns:
    The return value of the function
    See:
    $k#.transaction
  • <static> $k.require(dependencies, callback)
    Calls a function with required modules. Passes the value of each required module
    Parameters:
    {string[]} dependencies
    IDs of required modules
    {function} callback
    Callback function
    Throws:
    {$k.exception.ModuleError}
    If a required module was not found, defined more than once, or a cyclic dependency was detected
    Returns:
    The return value of the callback function
  • <static> {$k.Type} $k.rootType()
    Returns the root type of the semantic network
    Returns:
    {$k.Type}
  • <static> {$k.Type} $k.shortcutRelationType()
    Returns the parent type of all shortcut relation types
    Returns:
    {$k.Type}
  • <static> {boolean} $k.symmetricRelationProperties()
    Returns true if symmetric relation properties are enabled
    Returns:
    {boolean}
  • <static> {$k.Type} $k.systemRelationType()
    Returns the parent type of all system relation types
    Returns:
    {$k.Type}
  • <static> {$k.Type} $k.topAttributeType()
    Returns the parent type of all attribute types
    Returns:
    {$k.Type}
  • <static> {$k.Type} $k.topRelationType()
    Returns the parent type of all relation types
    Returns:
    {$k.Type}
  • <static> {$k.Type[]} $k.topTypes()
    Returns all top types except the top attribute and relation types
    Returns:
    {$k.Type[]}
  • <static> $k.transaction(f, rejectFunction)
    Evaluates the function in a transaction and returns its return value if the transaction has been accepted. If the transaction is rejected due to concurrency conflicts, the optional reject function is performed. This function does not allow to start a transaction within an outer transaction, use optimisticTransaction() instead.
    Parameters:
    {Function} f
    Function that should be evaluated in a transaction
    {Function} rejectFunction Optional
    Optional function that is evaluated if the transaction is rejected.
    Throws:
    {$k.exception.TransactionError}
    If another transaction is already active
    Returns:
    The return value of the function. If the transaction is rejected, the return value of the reject function (if defined) or undefined is returned.
    See:
    $k#.optimisticTransaction
  • <static> {$k.User} $k.user()
    Returns the current user
    Returns:
    {$k.User}
  • <static> {$k.Type} $k.userRelationType()
    Returns the parent type of user-defined relation type
    Returns:
    {$k.Type}
  • <static> {string} $k.uuid()
    Generates a UUID
    Returns:
    {string}
  • <static> {string} $k.volume()
    Returns the name of the semantic network
    Returns:
    {string}