File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[B&S] some questions about "Required Interface"

 
Jimmy Chen
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, I got some questions about the required interface

first, in the interface sun gives us the read method it says:

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


As I understand, it returns ONE record each time and the string array should carry the field values for this record. like array[0] stores the first field's value. Here "a record value" should be a field value. Is it right?

another question, what's the value of recNo? I can't find it from the database schema. Is it just a index of the record or other id? Is it in the database or just used for the program(record index)?

third question, when I use the "Data.java" to implement the interface, Can I use another class to wrap "Data.java"?


thanks in advance!!!
[ June 26, 2006: Message edited by: Nova Chen ]
 
Bob Nedwor
hangman
Ranch Hand
Posts: 215
Eclipse IDE Oracle Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I understand, it returns ONE record each time and the string array should carry the field values for this record. like array[0] stores the first field's value. Here "a record value" should be a field value. Is it right?
Yes, that is the way I interpreted it.

public String [] read(int recNo) throws RecordNotFoundException;
Are you sure? In my project it was:
public String [] readRecord(long recNo) throws RecordNotFoundException; I am not sure why you get to use an "int" and I had to use a "long." No fair. ...But this is basically the unique, "nth" record in the datafile.

when I use the "Data.java" to implement the interface, Can I use another class to wrap "Data.java"?
Yes, as a matter of fact, I would find it difficult to do it any other way..

I hope this helps.
 
Anna Hays
Ranch Hand
Posts: 131
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the Adaptor pattern instead of wrapping to make it an object oriented data layer package. I think Sun will use the Data.java to mark your assignment so becareful. Better to be safe than sorry.

When you say wrapping I assume you mean subclassing it then you can use the interface like DB db = new SubDataClass();
 
Jimmy Chen
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Bob and Anna very much!

Bob, I can't find any long parameters in the interface of my assignment

Anna, I just want to use the adaptor as in Andrew's book (that's what I saying wrap).
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several different versions of the assignment with small differences like different datatypes and method signatures.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic