public IRBTNode<E> getRootNode() throws RBTException {
DataRecordIdentifier dataRecordIdentifier;
try {
dataRecordIdentifier = getRootNodeIdentifier();
} catch (StoreException exception) {
throw new RBTException(exception);
}
IRBTNode<E> rootNode = null;
if (dataRecordIdentifier != null) {
rootNode = (IRBTNode<E>) heapRecordableManager
.getHeapRecordable(dataRecordIdentifier);
}
if (rootNode == null && dataRecordIdentifier != null) {
try {
final IHeapRecordable heapRecordable = newIHeapRecordableRBTNode(heapRecordableManager);
rootNode = (IRBTNode<E>) heapRecordable;
heapRecordable.setDataRecordIdentifier(
/**/dataRecordIdentifier,
/**/true/* exist in file */);
if (!heapRecordableManager.readAndSetState(heapRecordable)) {// NOPMD
throw new RBTException("failed read and set state: "
+ heapRecordableManager.getReadAndSetStateStatus()
+ ", " + dataRecordIdentifier);
}
} catch (HeapRecordableException exception) {
throw new RBTException(exception);
}
}
return rootNode;
}