Package helma.objectmodel.db

# 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:
  - Serialized Form

## Field Summary

### Fields inherited from interface helma.objectmodel.INodeState

`CLEAN, DELETED, INVALID, MODIFIED, NEW, TRANSIENT, VIRTUAL`

## Constructor Summary

Constructors
Constructor
Description
`NodeHandle(Key key)`
Builds a handle given a node's retrieval information.

## Method Summary

Modifier and Type
Method
Description
`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.
`boolean`
`equals(Object other)`
`String`
`getID()`
Get the ID for the node described by this handle.
`Key`
`getKey()`
Get the key for the node described by this handle.
`Node`
`getNode(WrappedNodeManager nodemgr)`
Get the node described by this node handle
`boolean`
`hasNode()`
Check if the node is available without fetching it from the node manager
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## 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:
  ...