File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Delete Flag Empty -does this imply record valid? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Delete Flag Empty -does this imply record valid?" Watch "Delete Flag Empty -does this imply record valid?" New topic
Author

Delete Flag Empty -does this imply record valid?

James Clinton
Ranch Hand

Joined: Jun 23, 2003
Posts: 190
Background: At the moment I am implementing the 'find(cret)' method to build a list of records which match some criteria. This function invokes 'read(recNo)' to grab a record for some processing and catches any RecordNotFoundException's etc etc.

My Assignment:In my assignment '1' indicates deleted, '0' indicates valid record.

Question:When I read in the 'delete byte' the value is empty. Can I safely assume 'empty' implies record is valid, or do I have a bug to sort out? (I was expecting '0').



Thanks.
James Clinton
Ranch Hand

Joined: Jun 23, 2003
Posts: 190
corrupt?

I'm not so sure because all the other details are read OK, theres a total of approx 29/30 records.

Anton, did you have the same assignment as mine?


URLyBird
Data file Format
The format of data in the database file is as follows:

Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record

Schema description section.
Repeated for each field in a record:
2 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
2 byte numeric, field length in bytes
end of repeating block

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

End of file


James
[ November 26, 2004: Message edited by: James Clinton ]
Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
Hi, James! Thanks for posting the code. This makes things easier. When a byte has the value -1, the String constructor does not know how to convert it. There is no error. Try the following:



If it is -1 or 0, it is ok.
[ November 26, 2004: Message edited by: Anton Golovin ]

Anton Golovin (anton.golovin@gmail.com) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Delete Flag Empty -does this imply record valid?