page = nextPage; p = db.getCurrentPage(nextPage); db.addToBuffer(p); offset = 0; }  lastTID = ByteConversion.byteToShort(p.data, offset); short l = ByteConversion.byteToShort(p.data, offset + 2); if(l == DOMFile.OVERFLOW) {  l = 8; final long overflow = ByteConversion.byteToLong(p.data, offset + 4); final byte[] odata = db.getOverflowValue(overflow); nextNode = NodeImpl.deserialize(odata, 0, odata.length, doc); } else { nextNode = NodeImpl.deserialize(p.data, offset + 4, l, doc); } nextNode.setInternalAddress(StorageAddress.createPointer((int) page, lastTID)); nextNode.setOwnerDocument(doc); offset = offset + 4 + l;
lastTID = ByteConversion.byteToShort(p.data, offset); if(ItemId.getId(lastTID) < 0) LOG.debug("tid < 0: " + lastTID + " at "+ p.page.getPageInfo()); offset += 2;  if(ItemId.isLink(lastTID)) {  offset += 8; continue; }  short l = ByteConversion.byteToShort(p.data, offset); offset += 2; if(ItemId.isRelocated(lastTID)) {  offset += 8; }  if(l == DOMFile.OVERFLOW) { l = 8; final long overflow = ByteConversion.byteToLong(p.data, offset); offset += 8; final byte[] odata = db.getOverflowValue(overflow); nextNode = NodeImpl.deserialize(odata, 0, odata.length, doc);  } else { nextNode = NodeImpl.deserialize(p.data, offset, l, doc); offset += l; } nextNode.setInternalAddress( StorageAddress.createPointer((int) page, ItemId.getId(lastTID)) ); nextNode.setOwnerDocument(doc); } while(nextNode == null);
	public Object next() {		Lock lock = db.getLock();		NodeImpl nextNode = null;		try {			try {				lock.acquire(Lock.READ_LOCK);			} catch (LockException e) {				return null;			}			if(gotoNextPosition()) {				final DOMFile.DOMFilePageHeader ph = p.getPageHeader();				// next value larger than length of the current page?				if (offset >= ph.getDataLength()) {					// load next page in chain					final long nextPage = ph.getNextDataPage();					if (nextPage < 0) {						LOG.debug("bad link to next " + p.page.getPageInfo());						return null;					}					page = nextPage;					p = db.getCurrentPage(nextPage);					db.addToBuffer(p);					offset = 0;				}				// extract the value				lastTID = ByteConversion.byteToShort(p.data, offset);				short l = ByteConversion.byteToShort(p.data, offset + 2);				if(l == DOMFile.OVERFLOW) {					// overflow page: load the overflow value					l = 8;					final long overflow = ByteConversion.byteToLong(p.data, offset + 4);					final byte[] odata = db.getOverflowValue(overflow);					nextNode = NodeImpl.deserialize(odata, 0, odata.length, doc);				} else {					nextNode = NodeImpl.deserialize(p.data, offset + 4, l, doc);				}				nextNode.setInternalAddress(StorageAddress.createPointer((int) page, lastTID));				nextNode.setOwnerDocument(doc);				offset = offset + 4 + l;			}			return nextNode;		} catch (BTreeException e) {			Thread.dumpStack();			LOG.warn(e);		} catch (IOException e) {			LOG.warn(e);		} finally {			lock.release();		}		return null;	}