The KnownSpace Datamanager
"Halfway To Anywhere"

Active Entity Value Writing

To write an active entity value, first implement interface ActiveEntityValue (which extends interface EntityValue). Then write the code to do the required computation in a getEntityValue() method of your subclass. This method must be public and it must return an EntityValue.

Note that the method can only throw DataManagerExceptions; it cannot throw arbitrary exceptions. So any exceptions you might wish to throw (for example, IOExceptions) will have to be caught and then passed on as DataManagerExceptions.

To install an active entity you must write a simpleton to do so, just as for passive entities. The simpleton must first create an instance of your particular subtype of ActiveEntityValue, then use Entity.setValue() to install it as the value of the entity it is to be stored in. When simpletons execute the Entity.getValue() method on that active entity, the kernel executes the getEntityValue() method of the active entity value instance then returns the entity value it returns.

Although an active entity value is stored in a particular entity, it need not apply to that entity (except that its computation will execute every time that entity's getValue() method is invoked). If you wish your active entity value to apply to a particular entity (even if it's to be the one it is stored in), you must write a constructor that accepts an entity then pass that entity to the constructor on creation.

This is particularly useful to do computations on a base entity of the entity the active entity value is stored in (that is, an entity that the entity it is stored in is an attribute of). For example, an active entity might report how many entities are currently linked to its base entity---that is, the entity to which it itself is linked---or it might periodically save its base entity's value, write its number of accesses to a log file, ping the network, popup a window for a user to enter a password, and so on. An active entity may do even more general things, since there is no limitation on its action. It may, for example, analyze or manipulate an entire subset of entities.