This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
When you delete a record, you do so by marking it with the delete flag in the file. So when you read a record, you should read first its flag and see if it is the valid flag or the deleted flag. If the file pointer is beyond the end of the file, for example recNo = 100, of course the record is missing. My original dbFile doesn't have deleted records, but you need to implement the behavior.
Regards, [ May 08, 2007: Message edited by: Romeo Son ]
My recNo is an sequence starting from 0 (same as position in the db file). Then I stored all valid and deleted recNos into 2 separated sortedSet. When recNo < 0 || recNo > validRecNos.last() + 1 || deletedRecNos.contains(recNo), I through a RecordNotFoundException
Actually the second operator should be recNo > validRecNo.last() I stored all the valid recNo into a SortedSet. So the validRecNo.last() represent the maximum recNo. If a given recNo is larger than the maximum recNo, it is out of range.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com