Class NodeHandle

java.lang.Object
helma.objectmodel.db.NodeHandle
All Implemented Interfaces:
INodeState, Serializable

public final class NodeHandle extends Object implements INodeState, Serializable
This class is a handle or reference to a Node. This is to abstract from different methods of reference: Transient Nodes are referred to directly, while persistent nodes are referred to via key/node manager. A handle is used to refer to a node in a safe way over a longer period. While a direct reference may point to a node that has been evicted from the cache and reinstanciated since being set, NodeHandle will always return an up-to-date instance of its node. Helma tries to ensure the following rules on NodeHandles:
  1. For transient nodes there exists only one NodeHandle.
  2. If a transient node becomes persistent its node handle is notified and converted into a persistent NodeHandle.
These two properties guarantee that NodeHandle comparisons are easy and usually correct.
See Also:
  • Constructor Details

    • NodeHandle

      public NodeHandle(Key key)
      Builds a handle given a node's retrieval information. At the time this is called, the node is ususally not yet created. It will be fetched on demand when accessed by application code.
      Parameters:
      key - the key
  • Method Details

    • getNode

      public Node getNode(WrappedNodeManager nodemgr)
      Get the node described by this node handle
    • hasNode

      public boolean hasNode()
      Check if the node is available without fetching it from the node manager
      Returns:
      true if we alreay have a reference to our node
    • getKey

      public Key getKey()
      Get the key for the node described by this handle. This will return null for transient Nodes.
    • getID

      public String getID()
      Get the ID for the node described by this handle. This may only be called on persistent Nodes.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
      Parameters:
      other - ...
      Returns:
      ...
    • becomePersistent

      protected void becomePersistent()
      This is to notify the handle that the underlying node is becoming persistent and we have to refer to it via the key from now on.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      ...