Any method that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file
Now, to check if the record is deleted is done simply by checking the flag value. But how about if the record is missing? Currently I'm thinking of something like:
Would this "check" cover both "deleted" and "missing"? Or how do you fellow ranchers solve this?
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.
[ May 08, 2007: Message edited by: Romeo Son ]
I also store all valid record numbers in a static attribute so that I know which record numbers are valid. If the record number is not stored, I throw the RecordNotFoundException.
I have a question to your statement:
Originally posted by Tai Hu:
recNo < 0 || recNo > validRecNos.last() + 1 || deletedRecNos.contains(recNo), I through a RecordNotFoundException
I do not get why you have the second operator