This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Do we need to return the deletedFlag in readRecord method?

 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I got a sort of dumb doubt.
In the readRecord method, that is provied by Sun it says to return the record as follows.

Should we also return the 1 byte deleted flag that is present before each record? Obviously the flag is 0 as the record exists. So, do we need to return this in the String []?
Also the comment above method says "Reads a record from the file. Returns an array where each element is a record value." Here record value is field value right? like name, location and so on...of one record with given recNo.
Appreaciate your help, thanks.
[ February 19, 2004: Message edited by: Satish Avadhanam ]
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satish,
Originally posted by Satish Avadhanam:
Should we also return the 1 byte deleted flag that is present before each record? Obviously the flag is 0 as the record exists. So, do we need to return this in the String []?

No, yes, and no.
There are two cases to consider for a record. Either
1) the record is marked as deleted
2) the record is valid (not marked as deleted)
If 1, then you're throwing the RecordNotFoundException, right?
If 2, then you're returning a record in String[]. The fact that you return a record and did not throw the RecordNotFoundException indicates that the record must have been valid. It's never valid to read a record that is marked for deletion (that is, a non-valid record), is it?
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by George Marinkovich:
Hi Satish,
No, yes, and no.
There are two cases to consider for a record. Either
1) the record is marked as deleted
2) the record is valid (not marked as deleted)
If 1, then you're throwing the RecordNotFoundException, right?
Yes, obviously. That's what is one of the MUST requirements by Sun.

If 2, then you're returning a record in String[]. The fact that you return a record and did not throw the RecordNotFoundException indicates that the record must have been valid. It's never valid to read a record that is marked for deletion (that is, a non-valid record), is it?
Yes George. I think its upto us right. I mean deleted flag does not include as part of a record, it says whether a record is present or not. So if we document about our idea, then that's ok, I think.

Appreciate your help, thanks.
[ February 19, 2004: Message edited by: Satish Avadhanam ]
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satish,
So, do we need to return this in the String []?

No (because the deleted flag is not a field).
Regards,
Phil.
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Phil. I will not return the deleted flag.
When I first replied it, I guess, I forgot to say "not". I have been working for 2 days continously and was and Anyway, thanks Phil.
[ February 23, 2004: Message edited by: Satish Avadhanam ]
[ February 23, 2004: Message edited by: Satish Avadhanam ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic