ti.chimera.registry
Class Node

java.lang.Object
  extended byti.chimera.registry.Node
Direct Known Subclasses:
PersistentNode, RegistryCore.DirectoryNode

public class Node
extends java.lang.Object

Base class for a node in the tree. A node can have an optional contract, which constraints what values can be assigned to this node. If no contract is specified, the null-contract (ie. accept any value) will be used.

Clients can subscribe to the value of the node, in which case every time the node's value is changed, the new value will be published to them. (Also, the current value is immediately published, upon subscription.) All changes to a node are published in the order they occur.

NOTE: currently it is possible that a value be published to a subscriber after the subscriber has been unsubscribed, but only if the change that is being published occurred before the subscriber unsubscribed.

Version:
0.1
Author:
;Rob Clark;a0873619;San Diego;;

Nested Class Summary
static class Node.NonSwingWorker
           
static class Node.SwingWorker
           
 
Constructor Summary
Node(java.lang.Object value, NodeContract contract, java.lang.String comment)
          Class Constructor.
 
Method Summary
 java.lang.String getComment()
          Get the node's comment.
 NodeContract getNodeContract()
          Get the node's contract.
 java.lang.String getPrimaryPath()
          Get the primary path of this node.
 java.lang.Object getValue()
          Get the current value of the node.
 void setValue(java.lang.Object value)
          Set the value of this node, and publish the new value to all the subscribers.
 void subscribe(NodeSubscriber s)
          Add the subscriber to the list of registered subscribers, and immediately publish the current value.
 java.lang.String toString()
          For debug
 void unsubscribe(NodeSubscriber s)
          Remove the subscriber from the list of registered subscribers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node(java.lang.Object value,
            NodeContract contract,
            java.lang.String comment)
Class Constructor.

Parameters:
value - the node's initial value
contract - the node's contract, or null
comment - a string containing a description of the purpose of this node, the node's usage, etc. Can contain HTML markup.
Method Detail

getNodeContract

public NodeContract getNodeContract()
Get the node's contract.

Returns:
the NodeContract

getComment

public java.lang.String getComment()
Get the node's comment.

Returns:
a string

setValue

public void setValue(java.lang.Object value)
Set the value of this node, and publish the new value to all the subscribers.

Parameters:
value - the node's new value

getValue

public java.lang.Object getValue()
Get the current value of the node.

Returns:
the node's current value

getPrimaryPath

public java.lang.String getPrimaryPath()
Get the primary path of this node. If the node is not linked into the registry tree, then this will be null. Otherwise this will be the first path this node is linked in to but has not yet been unlinked from.

Returns:
a path or null.

subscribe

public void subscribe(NodeSubscriber s)
Add the subscriber to the list of registered subscribers, and immediately publish the current value.

Parameters:
s - the subscriber

unsubscribe

public void unsubscribe(NodeSubscriber s)
Remove the subscriber from the list of registered subscribers.

Parameters:
s - the subscriber

toString

public java.lang.String toString()
For debug