// Reads a record from the file. Returns an array where each
// element is a record value.
public String[] read(int recNo) throws RecordNotFoundException;
SCJP 1.4<br />SCJD 1.4
SCJP 1.4<br />SCJD 1.4
Originally posted by Matt Sheehan.:
zeroOffset is the offset to the start of record zero. It could also be viewed as the length, in bytes, of the schema description data.
In my implementation I use a RandomAccessFile. When I need to read or write to a record I must first call 'file.seek(offset)', using the offset computation I mentioned, to get the file pointer to the correct place in the file.
Matt
Maybe I am just a little confused about how I use this method, if that makes sense. The parameter just takes a record number, which looking at it, just seems like some arbitrary number. Maybe it's late and i'm not thinking clearly. What exactly do I use this method for, besides the stated obvious of the comments? I can see reading the record, returning the string array, editing it, and calling the update method on the record; that makes sense. But how would I know what record I wanted if I only have a set of arbitray record numbers from 0 to whatever the last record number is? I hope my question makes sense. Thanks!// Reads a record from the file. Returns an array where each
// element is a record value.
public String[] read(int recNo) throws RecordNotFoundException;
SCJP 1.4<br />SCJD 1.4
The parameter just takes a record number, which looking at it, just seems like some arbitrary number. Maybe it's late and i'm not thinking clearly. What exactly do I use this method for, besides the stated obvious of the comments? I can see reading the record, returning the string array, editing it, and calling the update method on the record; that makes sense. But how would I know what record I wanted if I only have a set of arbitray record numbers from 0 to whatever the last record number is?
Maybe it's late and i'm not thinking clearly.
B.S. University of Wisconsin<br />SCJP 1.4 (85%)<br />SCJD 1.4 (92%) B&S Contractors
SCJP 1.4<br />SCJD 1.4
B.S. University of Wisconsin<br />SCJP 1.4 (85%)<br />SCJD 1.4 (92%) B&S Contractors
Originally posted by Jared Chapman:
My Data class doesn't give a $@#% about B&S contractors. It's only job is to provide basic database functionality for a file that follows the provided format. So, for example, if an ice cream company creates a database file using this format, my Data class would work with their database file. Again, my Data class has nothing to do with contractors, and it doesn't know what functionality the client side program will have. So therefore it is justifiable to implement all database functionality.
When I get to the parts of my program where I implement program-specific stuff, I never end up using create or delete, so you are correct, they are never accessible to the end user. But lets say B&S were to say "oh, by the way, we need you to write a small maintenance program to create, modify, and delete records on the server." If this happened, you could simply reuse your Data class for this program (assuming you implemented create and delete).
Perhaps an easier way of looking at it is that Sun requires you to implement the supplied interface, the little extra code of delete and create is painless, so just do it.
So to answer, I implemented the entire interface in Data, and I also read in and stored the schema in my Data class.
[ November 19, 2004: Message edited by: Jared Chapman ]
I didn't say it. I'm just telling you what this tiny ad said.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|