Bodgitt and scraper, flag question

Hanna Habashy

Ranch Hand

Posts: 532

posted 12 years ago

hi: I have just downloaded the assignment, and I am trying to decipher the requerments. In the data section of the database it says: Repeat to end of file 1 byte "deleted" flag. 0 implies valid record, 1 implies deleted record. can someone tell me what is the location of this byte withen a record. Is is in the begining of the record, or the end or it. thanks

SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle

Hi Hanna, You will need to verify this in your instructions. Mine state:

Data section. Repeat to end of file: 1 byte "deleted" flag. 0 implies valid record, 1 implies deleted record Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information

hi Andrew: Thank you for your reply. I am going to write a simple test class to varify all the information. I have one more question. Is that mean the flag byte part of the record length or not? thanks

SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle

Richard Everhart

Ranch Hand

Posts: 54

posted 12 years ago

This stumped me for a bit. The deleted flag could be considered part of a record (that's the way I think of it) but it's not part of the the schema. So, I'd say that yes, the deleted flag is part of a record. Rich

Originally posted by Hanna Habashy: I am going to write a simple test class to varify all the information.

Excellent. So you probably have already determined the answer to your question...

Originally posted by Hanna Habashy: Is that mean the flag byte part of the record length or not?

I believe you will find it is not part of the record length. My copy of the instructions state:

Data section. Repeat to end of file: 1 byte "deleted" flag. 0 implies valid record, 1 implies deleted record Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information

So according to this, the record is the size as specified in the record length, and the deleted flag is outside of the record and not counted in the size. Symantically this is correct: the deleted flag logically cannot be part of the record since you have to read the record to find out whether it exists or not. Getting all metaphysical there Regards, Andrew

confirmed. The delete falg byte is not part of the record length. This is according to the .db file, which belongs to my project. I think other projects may vary.

SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle

Richard Everhart

Ranch Hand

Posts: 54

posted 12 years ago

My instructions are the same as yours, Andrew. However, while the deleted flag is not logically part of a record, as you say, you still have to read the byte containing the deleted flag value when you read a record. So, therefore, the deleted flag, while not part of a database schema, at least to me, is still part of a record's length for purposes of reading the record. Rich