• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S: the length of returned array

 
Steve Taiwan
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the readRecord method, does it return an array of 7 fields, including flag?
Or it just return 6 field without flag?

// Reads a record from the file. Returns an array where each
// element is a record value.
public String [] readRecord(long recNo)
throws RecordNotFoundException;

In the updateRecord method, does it also accept an array of 7 fields?

2 byte numerica, number of fields in each record in db file is 6 when I read db file by readShort().

I hope to confirm this.
Thank you in advance for reply to me .
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

where do you guys get all those strange ideas? I find it only makes sense to handle the deleted flag as part of the file format specification that matters only for the part of the implementation that deals with the file directly rather than passing around deleted records.

I had B & S version 2.3.2, and the method signature in DBMain was public String[] read(int recNo). I got 24/40 for the GUI and 100 % for the rest (96 % total).

Conan
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Conan,

Please remember JavaRanch's primary rule: be nice! All questions are welcome here. Something that might be blindingly obvious to you might not be as obvious to others. And the reverse may also apply.

Thanks and regards, Andrew.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,

I think that you would not want to pass the deleted flag back to the client. Logically you would never send a deleted record to a client, so that flag would have no meaning to the client.

Or, to look at it from a different perspective, consider the following from the instructions:

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


The "deleted" flag is mentioned separately from the "Record" data. So it would not be included.

Regards, Andrew
 
Steve Taiwan
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Andrew, Conan

Thank you for the reply.
Now, I know the fields should not include flag.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic